Modified G-S Algorithm - does not converge to target

4 views (last 30 days)
hi everyone,
i am trying to implement modified G-S algorithm to create Coded Phase Mask
the modification is that the mask should be pure phase so the constraint on the amplitude is to be 1 in mask plane, and sparse matrix on detector plane.
the issue is that i cannot converge to uniform amplitude in mask plane and also it converges to the sparse matrix imidiately and stays the same for all iterations.
i would appretiate any help!
;
clear all; close all;
num_of_Pixels=256; dot_N=100;
N=num_of_Pixels; dotN=dot_N; sigX=round(N/100); sigY=round(N/10);
Det_Plane = zeros(N); dp_amplitude1=zeros(N-2*sigX,N-2*sigY); dp_amplitude1(1:dotN,1)=255;
dp_amplitude1=reshape(dp_amplitude1(randperm((N-2*sigX)*(N-2*sigY))),N-2*sigX,N-2*sigY);
Det_Plane(sigX:(size(Det_Plane,1)-sigX-1),sigY:(size(Det_Plane,2)-sigY-1))= dp_amplitude1;
phase = (2*rand(N,N)-1)*pi;
CPM_Plane =255*exp(1i*phase);
error = []; error2 = [];
iteration_num = 200;
Norm_Det_Plane=(Det_Plane-min(min(Det_Plane)))./(max(max(Det_Plane))-min(min(Det_Plane))); %Normalized Det_Plane for error calculation
A=fftshift(fft2(fftshift(CPM_Plane)));%first fft of ones with rand phase
for j=1:iteration_num
B = Det_Plane.* exp(1i*angle(A)); %Det plane with set amp and calculated phase
C = fftshift(ifft2(fftshift(B))); % cpm plane
D = exp(1i*angle(C)); % cpm plane with ones and calculated phase
A = fftshift(fft2(fftshift(D))); % next fft of cpm plane: actual detector plane
Norm_Mask_on_Det=(abs(A)-min(min(abs(A))))./(max(max(abs(A)))-min(min(abs(A)))); %Normalized mask values for error calculation
error = [error; immse(Norm_Det_Plane,Norm_Mask_on_Det)];
error2 = [error2; immse(C,D)];
end
figure
subplot(2,2,1);
imagesc(Det_Plane);colormap('Gray'); colorbar;
title('Desired Mask on Detector')
subplot(2,2,2);
imagesc(abs(A)); colormap('Gray'); colorbar; %last pattern
title('Actual Mask on Detector');
subplot(2,2,3);
imagesc(abs(C)); colormap('Gray'); colorbar; %last pattern
title('Amp of Mask on CPM Plane');
subplot(2,2,4);
imagesc((angle(C))); colormap('Gray'); %colorbar; %last pattern
title('Phase of Mask on CPM Plane');
figure
j = 1:1:j;
subplot (1,2,1)
plot(j,(error));
title('Error of detector plane');
subplot (1,2,2)
plot(j,(error2)); %last pattern
title('error of cpm plane');

Answers (0)

Categories

Find more on MATLAB in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!