Issue while generating hologram

Hello everyone, I am trying to generate a Hologram using GS-like hybrid algorithm but unfortunately, I am unable to get the desired result. The resulting hologram I am getting is
but the desired one is
any help will be much appreciated.
ThanksH

13 comentarios

Walter Roberson
Walter Roberson el 19 de Feb. de 2018
The bug is in line 17.
Zulqarnain Sheikh
Zulqarnain Sheikh el 19 de Feb. de 2018
line 17? I did not get it. :(
Walter Roberson
Walter Roberson el 19 de Feb. de 2018
Notice that we did not get line 17 either. We did not receive any code at all.
Zulqarnain Sheikh
Zulqarnain Sheikh el 19 de Feb. de 2018
Editada: Walter Roberson el 20 de Feb. de 2018
Lol, Sorry for that
clc
close all
clear all
%Gaussian Beam
basenum = 1; %Any number but not 0
x = linspace(-2*basenum,2*basenum,5000); %10000 points between -2 to 2 in case basenum is 1
y = linspace(-2*basenum,2*basenum,5000); %10000 points between -2 to 2 in case basenum is 1
[X,Y] = meshgrid(x,y); %produced 2d array for plot
intensity = exp(-2 * (X.^2 + Y.^2) / basenum^2); % Formula to generate pattern of gaussian beam
% figure
I = mat2gray(intensity); % To convert rgb matrix into a grayscale image
gaussian_beam = I(2000:3000,2000:3000);
gaussian_beam = imresize(gaussian_beam, [500 500]); % Displaying only central portion of gaussian beam
figure(1)
imshow(gaussian_beam)
% Algo Initiate
% GS imRead
Object=im2double(imread('img1.jpg'));
figure(2)
imshow(Object)
Object_new=im2bw(Object);
Object_new=imresize(Object_new, [500 500]);
figure(2)
imshow(Object_new) % Visualizing the reference image alongwith Gaussian Beam
t = 0;
rmse = 1;
k = 1;
m = 1;
eps = 0.09;
B = 0.8;
while rmse>eps && m<50
Gr = Object_new.*exp(i.*gaussian_beam);
Fp = fft2(fftshift(Gr));
if t == 0
Gp = Fp;
if rmse > eps
Gp = ((2*B).*abs(Fp))-abs(Fp);
end
end
Gp = abs(Gp).*angle(Fp);
Fr = ifftshift(ifft2(Gp));
figure(4),imshow(Fr); colormap(gray), title(num2str(k));
k = k+1;
m = m+1;
B = B/2;
end
Zulqarnain Sheikh
Zulqarnain Sheikh el 19 de Feb. de 2018
Editada: Walter Roberson el 20 de Feb. de 2018
@Walter Roberson
Actually I am trying to implement GS-like hybrid algorithm to generate Hologram.. I successfully implemented GS Algorithm but i am having lots of problems in implementing this hybrid algorithm
Walter Roberson
Walter Roberson el 19 de Feb. de 2018
Is img1.jpg the same as your bottom image?
Zulqarnain Sheikh
Zulqarnain Sheikh el 20 de Feb. de 2018
yes, it was in RGB so I converted it to black and white. The image is same
Walter Roberson
Walter Roberson el 20 de Feb. de 2018
? None of the images look anything like the result you indicate you are getting.
Zulqarnain Sheikh
Zulqarnain Sheikh el 20 de Feb. de 2018
So this was the source image sir
Walter Roberson
Walter Roberson el 20 de Feb. de 2018
Okay, but none of the figures produced by the code you posted in https://www.mathworks.com/matlabcentral/answers/383481-issue-while-generating-hologram#comment_537027 look anything like what you posted as your output,
Zulqarnain Sheikh
Zulqarnain Sheikh el 20 de Feb. de 2018
please check the code again, Last time, I posted the code from mobile and mistakenly I pasted only a part of it :( . Please have a look again as I have edited it
Walter Roberson
Walter Roberson el 20 de Feb. de 2018
I notice that you do not update rmse inside the while loop?
I updated it before, but just for testing purpose, I removed it and made it a fixed value
if k>=2
rmse = sqrt(sum(abs(Fr(k))-Fr(k-1))^2/k);
end
k = k+1;
err(k) = rmse;
t(k) = 1*k;
end
figure(3)
plot(t,err);

Iniciar sesión para comentar.

Respuestas (0)

Productos

Preguntada:

el 19 de Feb. de 2018

Comentada:

el 20 de Feb. de 2018

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by