
close all
%Venn's Diagrams
  disp('Various Venn''s Diagrams')
  lw = 2; 
  set(0, 'DefaultAxesFontSize', 16);
  fs = 15;
  msize = 10;
  
  
xp = linspace(-1,1,256);
x = ones(size(xp))'*xp;
y = xp'*ones(size(xp));
a = sqrt((x+0.3).^2+y.^2)<0.6;
b = 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,:);
% imagesc(a);
% axis equal;z = and(a,b);
% p = ones(size(z));
% rgb = cat(3,p,p,and(p,z));
% imshow(rgb)

close all
figure(1)
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);
ue = double(and(u,~(ae|be)));
uea = double(and(u,~(ae)));

% generate example venn diagram
% z = or(and(a,~b), and(b, ~a)); sim diff
% z = and(a, ~b);
z = or(a, b);
rgb = cat(3,ue,ue,and(ue,~z));
imshow(rgb);
text(220, 190, '\fontsize{25} \bf B')
text(0, 190,'\fontsize{25} \bf A')
print -depsc 'C:\Springer\Probs\Probseps\vennuni.eps'

figure(2)
% generate example venn diagram
% z = or(and(a,~b), and(b, ~a)); sim diff
% z = and(a, ~b);
z = and(a, b);
rgb = cat(3,ue,ue,and(ue,~z));
imshow(rgb);
text(220, 190, '\fontsize{25} \bf B')
text(0, 190,'\fontsize{25} \bf A')
print -depsc 'C:\Springer\Probs\Probseps\vennint.eps'


figure(3)
% generate example venn diagram
% z = or(and(a,~b), and(b, ~a)); sim diff
% z = and(a, ~b);
z = ~a;
rgb = cat(3,uea,uea,and(uea,~z));
imshow(rgb);
%text(220, 190, '\fontsize{20} \bf B')
text(0, 190,'\fontsize{25} \bf A')
print -depsc 'C:\Springer\Probs\Probseps\venncom.eps'

figure(4)
% generate example venn diagram
% z = or(and(a,~b), and(b, ~a)); sim diff
 z = and(a, ~b);
rgb = cat(3,ue,ue,and(ue,~z));
imshow(rgb);
text(220, 190, '\fontsize{25} \bf B')
text(0, 190,'\fontsize{25} \bf A')
print -depsc 'C:\Springer\Probs\Probseps\venndif.eps'

figure(5)
% generate example venn diagram
 z = or(and(a,~b), and(b, ~a)); 
rgb = cat(3,ue,ue,and(ue,~z));
imshow(rgb);
text(220, 190, '\fontsize{25} \bf B')
text(0, 190,'\fontsize{25} \bf A')
print -depsc 'C:\Springer\Probs\Probseps\vennsdi.eps'

figure(6)
% generate example venn diagram
 z = and(~a,~b);
rgb = cat(3,ue,ue,and(ue,~z));
imshow(rgb);
text(220, 190, '\fontsize{25} \bf B')
text(0, 190,'\fontsize{25} \bf A')
print -depsc 'C:\Springer\Probs\Probseps\venndem.eps'
