# Fragmented recovered image using a Phase Retrieval Algorithm named Error-Reduction

After reading the paper Phase retrieval algorithms: a comparison by J.R.Fienup. I implemented the Error-Reduction Algorithm in MATLAB. The initial phase input was randomly generated, so the final recovered image in each execution is different. The only information given is the Fourier Modulus of the original image.
Sometimes I can get a pretty well result, but most of the time the result is a fragmented version of the original image as the figures below shown:  As you can see, the image of $\pi$ is "almost" recovered except that the head and the body of $\pi$ had been cut and swapped.
My questions are:
1. Is this a common problem using phase retrieval algorithm? What causes this?
2. Is there any method to avoid this?
3. Is there any other great methods in phase retrieval?

• There is a $\pi /2$ phase shift in Matlab fft/fft2 Mar 18, 2015 at 13:26

• 1) Draw the white color pattern $\pi$ in a 100by100 black image; 2) Use imread to load the .bmp image as a matrix p; 3) Calculated its Fourier modulus matrix as absP; 4) Use random phase theta to form a Fourier domain guess G_pr. 5) Inverse transform G_pr to g_pr; 6) As the phase of p is a zero matrix, we let the some elements of g_pr, whose phase values are too big, be zero; 7) Keep the real part of g_pr ; 8)FFT g_pr into G and only keep its phase as theta then back to step 4. Mar 30, 2015 at 1:54
• Here is the Matlab code: <br/> format long p=imread('pi.bmp'); P=fftshift(fft2(p)); absP=abs(P); k=0; theta=2*pi.*rand(100)-pi; %[-pi,pi] figure(1) figure(2) while k<8000 G_pr=absP.*exp(1i.*theta); g_pr=ifft2(ifftshift(G_pr)); absPhase=abs(angle(g_pr)); maxPh=max(max(absPhase)); minPh=min(min(absPhase)); g_pr(absPhase>=(minPh+0.2*(maxPh-minPh)))=0; g_pr=real(g_pr); gg=255*g_pr/(max(max(g_pr))); figure(1),imshow(uint8(gg)); G=fftshift(fft2(g_pr)); G=G./abs(G); theta=angle(G); figure(2),imshow(theta),title(num2str(k)) k=k+1; end <br/> Mar 30, 2015 at 1:54