Phase change/phase shift in leaf surface moisture
3 views (last 30 days)
Show older comments
Hi, I am writing a phase retrieval algorithm, I have few different images that represent different milliliter of water on the leaf surface( leaf surface moisture) that needed to be inserted into the algorithm to see the phase change/phase shift that happened in each millimeter of water on the leaf surface, but I am not too sure how to see the phase change/phase shift of each image and compare it. Do I represent the phase change/phase shift in the graph or there are other methods to see the phase change/phase shift? Do I plot the phase or get a value? May I get some helps with this? I will attach all of the input images here. Thank you.
Here is the code:
close all; clc; workspace;
Iterations = 1100; %Number of iterations
p = 0.1; %Time to pause between display of images
tic; %Timer Initialization
error = [];
%This whole part is to generate a mesh plot, i still dont know what info
%can get from here but just leave it first.
x = linspace(-10,10,256);
y = linspace(-10,10,256);
[X,Y] = meshgrid(x,y);
x0 = 0; % Center
y0 = 0; % Center
sigma = 2; % Beam Waistfringes
A = 1; % Peak of the Beam
%These 2 lines, res and Source, is basically input intensity. U need
%this in order to get the exponential image to process ltr.
res = ((X-x0).^2 + (Y-y0).^2)./(2*sigma^2);
Source = A .* exp(-res);
%These 2 lines is for mesh plot also, ignore first
surf(Source);
shading interp
%Reading Fringe Image (Target)
Target = imread('0ml(1).jpeg');
Target = rgb2gray(Target);
Target = im2double(Target);
%Get the size of Target
[rowsimgA, colsimgA, numberOfColorChannelsimgA] = size(Source);
[rowsimgB, colsimgB, numberOfColorChannelsimgB] = size(Target);
%imresize function is basically to resize any image to a particular size.
%In this code u can see that i resize the Source beam input to the same
%size as the target image in the format of (Target, [rows, columns])
if rowsimgB ~= rowsimgA || colsimgA ~= colsimgB
Target = imresize(Target, [rowsimgA colsimgA]);
end
%FFT process
A = fftshift(ifft2(fftshift(Target)));
%Initiate loop
% The loop im not too sure yet, but basically when u multiplay the source
% and the phase, u produce exponential image, and then u do fft and ifft in
% order to reconstruct the image.
for i = 1:Iterations
B = abs(Source) .* exp(1i*angle(A));
C = fftshift(fft2(fftshift(B)));
D = abs(Target) .* exp(1i*angle(C));
A = fftshift(ifft2(fftshift(D)));
error = [error; (1/sqrt(rowsimgA*colsimgA)*sqrt(sum(sum(abs(C)-abs(Target)).^2)))];
end
%Display Outputs
figure(2), imagesc(Target), colorbar, title('Original Fringe')
figure(3), i = 1:1:i; plot(i,(error')); title('Error');
%Phase Mask
figure(4), imagesc(angle(A)), title('Phase Mask');
%Last Pattern
figure(5), imagesc(abs(C)), colorbar, title('Reconstructed Image');
%Reconstructed Image (Phase Only)
figure(6), imagesc(angle(D)), colorbar, title('Reconstructed Image (Phase Only)');
%Reconstructed Image (Amplitude Only)
figure(7), imagesc(abs(D)), colorbar, title('Reconstructed Image (Amplitude Only)');
%Display Total Time Taken for Phase Retrieval
toc;
2 Comments
Image Analyst
on 7 Nov 2020
Edited: Image Analyst
on 7 Nov 2020
Make it easy for us - format your code as code with the code icon.
And I see some magenta blobs that are in different locations in each image. Exactly what is phase in these images? How do I know that the phase is different for each image?
Answers (0)
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!