gradient descent method with Gerchberg–Saxton algorithm ?

4 次查看(过去 30 天)
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 个评论
Zulqarnain Sheikh
Zulqarnain Sheikh 2017-12-26
Thanks for response, I just want to implement gradient descent in GS algorithm, but I am unable to write the code of 2D gradient descent and I am unable to find one online. Any help will be much appreciated

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 MATLAB 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by