-
Notifications
You must be signed in to change notification settings - Fork 1
/
smooth_unwrap_1d.m
46 lines (34 loc) · 1.13 KB
/
smooth_unwrap_1d.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
function [unwrapped,phase_f,unsmoothed_unwrapped] = smooth_unwrap_1d(twin_img,width)
% Transforming into cosine/sine space:
s = sin(twin_img);
c = cos(twin_img);
% Boxcar averaging (change the width parameter to change the size of the
% sliding boxcar window):
% width = 4;
sf = boxcar2(s,width);
cf = boxcar2(c,width);
% Inverting back to "phase space":
phase_F = atan2(sf,cf);
phase_f = phase_F(2*width+1:end-(2*width+1),:);
%%% unwrapping the extracted twin image:
unwrapped = zeros(size(phase_f,1),size(phase_f,2));
% unwrap rows
for i =1:size(phase_f,1)
unwrapped(i,:) = unwrap(phase_f(i,:));
end
% unwrap columns
% for j =1:size(phase_f,2)
% unwrapped(:,j) = unwrap(unwrapped(:,j));
% end
unwrapped = unwrapped - max(unwrapped(:));
%%% unwrapping the extracted twin image:
unsmoothed_unwrapped = zeros(size(twin_img,1),size(twin_img,2));
% unwrap rows
for i =1:size(phase_f,1)
unsmoothed_unwrapped(i,:) = unwrap(twin_img(i,:));
end
% unwrap columns
for j =1:size(phase_f,2)
unsmoothed_unwrapped(:,j) = unwrap(unsmoothed_unwrapped(:,j));
end
unsmoothed_unwrapped = unsmoothed_unwrapped - max(unsmoothed_unwrapped(:));