To Remove Spaces In Between The Images And Assign Indices For Each Image

Asked by Pranjal Pathak on 9 Aug 2012
Latest activity Commented on by Pranjal Pathak on 7 Sep 2012

Hi,

I have written a Matlab coding to generate an array of holograms(4x4) as follows:

a=-1:2/127:+1;
b=-1:2/127:+1;
[X, Y]=meshgrid(a,b);
r=sqrt(X.^2+Y.^2)<1;
Z4=sqrt(3).*(2.*(X.^2+Y.^2)-1);
Z5=2.*sqrt(6).*X.*Y;
Z6=sqrt(6).*(X.^2-Y.^2);
Phi=(Z4+Z5+Z6);
mx=30;
my=25;
i=sqrt(-1);
Tau=mx.*X+my.*Y;
Theta=Phi+Tau;
if cos(Theta)>=0
    t=1;
else 
    t=0;
end
t=(1/2)+(1/pi)*(exp(i*Theta)+exp(-i*Theta)-(1/3)*(exp(i*3*Theta)+(exp(-i*3*Theta)+(1/5)*(exp(i*5*Theta)+(exp(-i*5*Theta))))));
h=t.*r;
figure(1)
imagesc(h),colormap gray
xlabel('X-Cordinate');
ylabel('Y-Cordinate');
title('Binary Hologram');
b=fftshift(fft2(t,256,256));
figure(2)
imagesc(abs(b)),colormap gray
title('FFT Of Binary Hologram');
figure(3)
for k =1:16
    p(i,j)=subplot(4,4,k);
    imagesc(h),colormap gray;axis image;axis off
end

*****************

When you run the following program, in figure(3) you will find an array of holograms. My problem is that how can I remove the spaces in between the consecutive holograms so that one hologram just touches the other? Also how can I assign indices to each particular hologram in fig.(3), so that I can further modify any particular hologram according to my need?

Can anyone please help me out in this regard?

Thanking You!

0 Comments

Pranjal Pathak

Products

No products are associated with this question.

1 Answer

Answer by Margarita on 9 Aug 2012
Edited by Walter Roberson on 10 Aug 2012
Accepted answer

Hi Pranjal,

a simple solution is to make a matrix that contains 16 copies of your hologram in an arrangement of 4X4,then each location in this arrangement M(i,j) might have different holograms (h1, h2, h3... h16)

[a, b] = size(h);
M = zeros(size(h)*4);           %M(4X4)
h1  = h;    h2 = h;     h3 = h;     h4= h;
h5  = h;    h6 = h;     h7 = h;     h8= h;
h9  = h;    h10 = h;    h11 = h;    h12= h;
h13 = h;    h14 = h;    h15 = h;    h16= h;
M(1:a, 1:b) = h1;               %M(1, 1)
M(a+1:a*2, 1:b) = h2;           %M(2, 1)
M(2*a+1:a*3, 1:b) = h3;         %M(3, 1)
M(3*a+1:a*4, 1:b) = h4;         %M(4, 1)
M(1:a, b+1:b*2) = h5;           %M(1, 2)
M(a+1:a*2, b+1:b*2) = h6;       %M(2, 2)
M(2*a+1:a*3, b+1:b*2) = h7;     %M(3, 2)
M(3*a+1:a*4, b+1:b*2) = h8;     %M(4, 2)
M(1:a, 2*b+1:b*3) = h9;         %M(1, 3)
M(a+1:a*2, 2*b+1:b*3) = h10;    %M(2, 3)
M(2*a+1:a*3, 2*b+1:b*3) = h11;  %M(3, 3)
M(3*a+1:a*4, 2*b+1:b*3) = h12;  %M(4, 3)
M(1:a, 3*b+1:b*4) = h13;        %M(1, 4)
M(a+1:a*2, 3*b+1:b*4) = h14;    %M(2, 4)
M(2*a+1:a*3, 3*b+1:b*4) = h15;  %M(3, 4)
M(3*a+1:a*4, 3*b+1:b*4) = h16;  %M(4, 4)
figure(4)
imagesc(M);
axis off

1 Comment

Pranjal Pathak on 7 Sep 2012

Thanks a lot. It was a wonderful suggestion!

Margarita

Contact us