Info
La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.
To Place An Image One Above The Other With The Transparency Provided
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi,
I have a problem in the following code:
% Frequency Of The First Row
fx1=3.5;fy1=2;
fx2=7;fy2=2;
fx3=10.5;fy3=2;
fx4=14;fy4=2;
% Frequency Of The Second Row
fx5=17.5;fy5=2;
fx6=21;fy6=2;
fx7=24.5;fy7=2;
fx8=28;fy8=2;
% Frequency Of The Third Row
fx9=31.5;fy9=2;
fx10=35;fy10=2;
fx11=38.5;fy11=2;
fx12=42;fy12=2;
% Frequency Of The Fourth Row
fx13=45.5;fy13=2;
fx14=49;fy14=2;
fx15=52.5;fy15=2;
fx16=56;fy16=2;
% Background
[x1,y1]=meshgrid(-1:2/511:1, -1:2/511:1);
z4=sqrt(3).*(2.*(x1.^2+y1.^2)-1); % Defocous
% Aberrations
% z4=sqrt(3).*(2.*(x1.^2+y1.^2)-1); % Defocous
% z5=2.*sqrt(6).*x1.*y1; % Astigmatism at +/-45
% z6=sqrt(6).*(x1.^2-y1.^2); % Astigmatism at 0 or 90
% z7=sqrt(8).*(3.*(x1.^2+y1.^2)-2).*y1; % Primary Y Coma
% z8=sqrt(8).*(3.*(x1.^2+y1.^2)-2).*x1; % Primary X Coma
% z11=sqrt(5).*(6.*(x1.^2+y1.^2).^2-6.*(x1.^2+y1.^2)+1); % Primary Spherical Aberration
% Holograms
a=128;
b=128;
[x,y]=meshgrid(-1:2/127:+1, -1:2/127:+1);
circ=sqrt(x.^2+y.^2)<1;
% Generation Of Holograms
h1=circ.*(cos((x*pi*fx1)+(y*pi*fy1)))>0;
h2=circ.*(cos((x*pi*fx2)+(y*pi*fy2)))>0;
h3=circ.*(cos((x*pi*fx3)+(y*pi*fy3)))>0;
h4=circ.*(cos((x*pi*fx4)+(y*pi*fy4)))>0;
h5=circ.*(cos((x*pi*fx5)+(y*pi*fy5)))>0;
h6=circ.*(cos((x*pi*fx6)+(y*pi*fy6)))>0;
h7=circ.*(cos((x*pi*fx7)+(y*pi*fy7)))>0;
h8=circ.*(cos((x*pi*fx8)+(y*pi*fy8)))>0;
h9=circ.*(cos((x*pi*fx9)+(y*pi*fy9)))>0;
h10=circ.*(cos((x*pi*fx10)+(y*pi*fy10)))>0;
h11=circ.*(cos((x*pi*fx11)+(y*pi*fy11)))>0;
h12=circ.*(cos((x*pi*fx12)+(y*pi*fy12)))>0;
h13=circ.*(cos((x*pi*fx13)+(y*pi*fy13)))>0;
h14=circ.*(cos((x*pi*fx14)+(y*pi*fy14)))>0;
h15=circ.*(cos((x*pi*fx15)+(y*pi*fy15)))>0;
h16=circ.*(cos((x*pi*fx16)+(y*pi*fy16)))>0;
% An Array Of 4x4 Holograms(Concatenation)
%First Row Of Holograms
M(1:a, 1:b) = h1; %M(1, 1)
M(1:a, b+1:b*2) = h2; %M(2, 1)
M(1:a, 2*b+1:b*3) = h3; %M(3, 1)
M(1:a, 3*b+1:b*4) = h4; %M(4, 1)
% Second Row Of Holograms
M(a+1:a*2, 1:b) = h5;%M(1, 2)
M(a+1:a*2, b+1:b*2) = h6; %M(2, 2)
M(a+1:a*2, 2*b+1:b*3) = h7; %M(3, 2)
M(a+1:a*2, 3*b+1:b*4) = h8; %M(4, 2)
% Third Row Of Holograms
M(2*a+1:a*3, 1:b) = h9; %M(1, 3)
M(2*a+1:a*3, b+1:b*2) = h10; %M(2, 3)
M(2*a+1:a*3, 2*b+1:b*3) = h11; %M(3, 3)
M(2*a+1:a*3, 3*b+1:b*4) = h12; %M(4, 3)
% Fourth Row Of Holograms
M(3*a+1:a*4, 1:b) = h13; %M(1, 4)
M(3*a+1:a*4, b+1:b*2) = h14; %M(2, 4)
M(3*a+1:a*4, 2*b+1:b*3) = h15; %M(3, 4)
M(3*a+1:a*4, 3*b+1:b*4) = h16; %M(4, 4)
figure(1)
imagesc(z4); colormap gray; axis image; axis off
title('Background');
figure(2)
imagesc(M); colormap gray; axis image; axis off
title('Array Of 4x4 Holograms');
************
My problem is that, I want to place figure(2) above figure(1)(i.e. considering it to be the background) in such a way that transparency is allowed. Can anyone please help me out in this regard?
Thanking You!
1 comentario
Ryan
el 23 de Ag. de 2012
imagesc should be able to replace imread and I think from the reference page that 'AlphaData' can handle non-binary masks if needed, this example should also help.
Respuestas (0)
La pregunta está cerrada.
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!