
close all

xp = linspace(-1,1,256);
x = ones(size(xp))'*xp;
y = xp'*ones(size(xp));
a = sqrt((x).^2+(y+0.3).^2)<0.6;
b = sqrt((x+0.3).^2+y.^2)<0.6;
c = sqrt((x-0.3).^2+y.^2)<0.6;


r1 = max(find(xp<-0.95));
r2 = min(find(xp>0.65));
a = a(r1:r2,:);
b = b(r1:r2,:);
c = c(r1:r2,:);
% imagesc(a);
% axis equal;z = and(a,b);
% p = ones(size(z));
% rgb = cat(3,p,p,and(p,z));
% imshow(rgb)

close all
sz = size(a);
u = ones(sz);
u(1:2,:)=0;
u(:,1:2)=0;
u(sz(1)-(0:1),:)=0;
u(:,sz(2)-(0:1))=0;

% generate edge images
se = strel('disk',2);
ae = a - imerode(a,se);
be = b - imerode(b,se);
ce = c - imerode(c,se);

%ue = double(and(u,~(ae|be)));
ue = double(and(u,~(ae|be|ce)));

figure(1)
% generate example venn diagram
z = or(a,and(b,c));
rgb = cat(3,ue,ue,and(ue,~z));
imshow(rgb);
%check with Get Handle
text(55, 20, '\fontsize{25} \bf A')
text(0, 190, '\fontsize{25} \bf B')
text(230,190, '\fontsize{25} \bf C')
print -depsc 'C:\Springer\Probs\Probseps\vennabc1.eps'



figure(2)
% generate example venn diagram
z = or(a,b);
rgb = cat(3,ue,ue,and(ue,~z));
imshow(rgb);
%check with Get Handle
text(55, 20, '\fontsize{25} \bf A')
text(0, 190, '\fontsize{25} \bf B')
text(230,190, '\fontsize{25} \bf C')
print -depsc 'C:\Springer\Probs\Probseps\vennabc2.eps'


figure(3)
% generate example venn diagram
z = or(a,c);
rgb = cat(3,ue,ue,and(ue,~z));
imshow(rgb);
%check with Get Handle
text(55, 20, '\fontsize{25} \bf A')
text(0, 190, '\fontsize{25} \bf B')
text(230,190, '\fontsize{25} \bf C')
print -depsc 'C:\Springer\Probs\Probseps\vennabc3.eps'

figure(4)
% generate example venn diagram
z = or(or(a,b),c);
rgb = cat(3,ue,ue,and(ue,~z));
imshow(rgb);
%check with Get Handle
text(55, 20, '\fontsize{25} \bf A')
text(0, 190, '\fontsize{25} \bf B')
text(230,190, '\fontsize{25} \bf C')
print -depsc 'C:\Springer\Probs\Probseps\vennuni3.eps'

figure(5)
% generate example venn diagram
z = and(and(~a,~b),~c);
rgb = cat(3,ue,ue,and(ue,~z));
imshow(rgb);
%check with Get Handle
text(55, 20, '\fontsize{25} \bf A')
text(0, 190, '\fontsize{25} \bf B')
text(230,190, '\fontsize{25} \bf C')
print -depsc 'C:\Springer\Probs\Probseps\venndem3.eps'



