gradient descent method with Gerchberg–Saxton algorithm ?

4 views (last 30 days)
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 Comments
Matt J
Matt J on 24 Dec 2017
You haven't mentioned what difficulty you are having.
Zulqarnain Sheikh
Zulqarnain Sheikh on 26 Dec 2017
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

Sign in to comment.

Answers (0)

Categories

Find more on MATLAB in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!