Reputation: 3
I am having difficulty in implementing the 4-Step Phase-Shifting Technique with Matlab (R2016a), as the result is not what it's expected.
In this technique, pictures of an interferogram are taken after it's shifted by pi/2, from 0 to 270 degrees, and the phase encoded in these pictures' intensity is calculated with atan((I4-I1)./(I0-I3)), where I1, I2, I3, and I4 are the intensity of each captured interferogram.
Here's the result of these calculations and the color scaled version of the result: Result Color scaled result
here's the desired result (calculated with the program VisuIm4): Desired result
I also did the same without converting the initial data from uint8 to double (except when calculating atan2): Result (uint8 calculations) Color scaled (uint8 calculations)
While the first calculated image has more white/dark fringes, the second has low contrast and is different from VisuIm4's result. In this last case, I assume that the reason is that the negative numbers are being zeroed. I'm also thinking that in the first case the problem is how the arctangent function is being calculated, what I am missing?
I could use VisuIm4's result, but I'm trying to understand what the program is doing. Here's the code I'm using:
%Reads images
I1_8 = imread('Img0.tif');
I2_8 = imread('Img90.tif');
I3_8 = imread('Img180.tif');
I4_8 = imread('Img270.tif');
%Converts to double, calculates subtractions and divisions
I1 = double(I1_8); I2 = double(I2_8); I3 = double(I3_8); I4 = double(I4_8);
a1 = I4-I2;
b1 = I1-I3;
Id = a1./b1;
Id = double(Id);
%Calculates arctangent
dim = size(Id);
Iat = zeros(dim(1),dim(2));
for j=1:dim(2)
for i=1:dim(1)
Iat(i,j) = atan2(sin(Id(i,j)), cos(Id(i,j)));
end
end
%Rescales image
figure, colormap(gray(256)), imagesc(I)
Upvotes: 0
Views: 67
Reputation: 3
After 5 months I found a solution: It turns out that doing the calculations with matrixes instead of the atan((I4-I1)./(I0-I3)) formula gives the desired result (VisuIm4's result). The matrix aproach I used is described in Optical Metrology 3rd edition, chapter 11.
Upvotes: 0