gradient descent method with Gerchberg–Saxton algorithm ?
Afficher commentaires plus anciens
Hello everyone, may anyone help me in using gradient descent method with Gerchberg–Saxton algorithm ?
the code for GS Algorithm is :
clc
close all
clear all
model=zeros(150);
model(5:20, 20:121)=1;
model(24:140, 40:50)=1;
model(24:140, 85:97)=1;
figure(1);imagesc(model); colormap(gray)
DS=model;
model=2*pi.*rand(150)-pi;
pi_signal1=double(imread('pi.bmp'));
pi_signal=rgb2gray(pi_signal1);
pi_signal=imresize(pi_signal, [150 150]);
j=fftshift(fft2(pi_signal));
j=abs(j)/(max(max(abs(j))));
j=imadjust(abs(j), [0; 0.01], [0; 1]);
for k=1:1:150;
step1=fftshift(fft2(model));
phase=angle(step1);
Gu=medfilt2(j).*exp(i*phase);
gx=fft2(fftshift(Gu));
model=pi_signal.*exp(i*angle(gx));
figure(7),imagesc(abs(gx)); colormap(gray), title(num2str(k));
err(k)=-sqrt(sum(abs(gx(1:k,1))-pi_signal1(1:k,1))^2/k);
t(k) = 10*k; %simulation time, where dt is time for one increment of loop
end
figure(3)
plot(err,t);
Thanks
2 commentaires
Matt J
le 24 Déc 2017
You haven't mentioned what difficulty you are having.
Zulqarnain Sheikh
le 26 Déc 2017
Réponses (0)
Catégories
En savoir plus sur MATLAB dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!