gradient descent method with Gerchberg–Saxton algorithm ?

조회 수: 6 (최근 30일)
Zulqarnain Sheikh
Zulqarnain Sheikh 2017년 12월 23일
댓글: Zulqarnain Sheikh 2017년 12월 26일
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
Matt J
Matt J 2017년 12월 24일
You haven't mentioned what difficulty you are having.
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