added codes
This commit is contained in:
75
matlab_code/unwrap_comparison.m
Normal file
75
matlab_code/unwrap_comparison.m
Normal file
@@ -0,0 +1,75 @@
|
||||
function [errors] = unwrap_comparison(file,t_end, noise_std_percent)
|
||||
%unwraps a given file with all five methods (Temporal, 3D Laplacian, 4D
|
||||
%Laplacian, Probability, OMME)
|
||||
%always uses file with Venc 75 and Venc 150
|
||||
%returns arrays of errors (as compared to OMME)
|
||||
struct = load('path_to_data_file');
|
||||
wrapped = struct.pca_p;
|
||||
mask_struct = load('path_to_mask_file');
|
||||
mask = mask_struct.labels;
|
||||
si = size(wrapped);
|
||||
si(3) = t_end;
|
||||
phi = zeros(si(1), si(2), 1, si(3));
|
||||
rng('default')
|
||||
rng(100 + str2double(file{1}(2)))
|
||||
noise_std = noise_std_percent * pi
|
||||
noise = noise_std.*randn(si);
|
||||
phi(:, :, 1, 1:si(3)) = (wrapped(:, :, 1:si(3)) + noise).*mask(1:si(1), 1:si(2), 1:si(3));
|
||||
phi_wn = zeros(si(1), si(2), 1, si(3));
|
||||
phi_wn(:, :, 1, 1:si(3)) = (wrapped(:, :, 1:si(3))).*mask(1:si(1), 1:si(2), 1:si(3));
|
||||
phi = phi - 2*pi*(phi > pi);
|
||||
phi = phi + 2*pi*(phi < -pi);
|
||||
|
||||
%%
|
||||
%laplacian unwrap
|
||||
n_u4 = unwrap_4D(phi);
|
||||
lap4d_phi = phi + double(n_u4).*2*pi;
|
||||
n_u3 = zeros(size(n_u4), 'int8');
|
||||
for i=1:si(3)
|
||||
n_u3(:, :, :, i) = unwrap_3D(phi(:, :, :, i));
|
||||
end
|
||||
lap3d_phi = phi + double(n_u3).*2*pi;
|
||||
|
||||
%%
|
||||
%temporal unwrap
|
||||
t_ref = t_end;
|
||||
temp_phi = temporal(phi, t_ref);
|
||||
|
||||
%%
|
||||
%probability unwrap
|
||||
w_s = 1.0;
|
||||
w_t = 2.5;
|
||||
t_low = 0.32;
|
||||
t_high = 0.75;
|
||||
prob_phi = probability(phi, t_low, t_high, w_s, w_t);
|
||||
|
||||
%%
|
||||
%omme
|
||||
struct = load('path_to_higher_venc_data_file');
|
||||
high_data = struct.pca_p;
|
||||
high_venc = zeros(size(phi));
|
||||
high_venc(:, :, 1, :) = (high_data(:, :, 1:si(3))).*mask(:, :, 1:si(3));
|
||||
highv = 150;
|
||||
lowv = 50;
|
||||
high_venc = high_venc.*(highv/pi);
|
||||
low_venc = phi_wn.*(lowv/pi);
|
||||
[omme_v, dyn, conf, std] = omme([high_venc(:), low_venc(:)], [highv, lowv]);
|
||||
omme_v = reshape(omme_v, [si(1), si(2), 1, si(3)]);
|
||||
|
||||
%%
|
||||
%evaluate!
|
||||
temp_v = temp_phi.*lowv/pi;
|
||||
lap3d_v = lap3d_phi.*lowv/pi;
|
||||
lap4d_v = lap4d_phi.*lowv/pi;
|
||||
prob_v = prob_phi.*lowv/pi;
|
||||
v = phi.*lowv/pi;
|
||||
|
||||
t = 1:si(3);
|
||||
base_error = eval_error(v(:, :, 1, t), high_venc(:, :, 1, t));
|
||||
t_error = eval_error(temp_v(:, :, 1, t), high_venc(:, :, 1, t));
|
||||
l4_error = eval_error(lap4d_v(:, :, 1, t), high_venc(:, :, 1, t));
|
||||
l3_error = eval_error(lap3d_v(:, :, 1, t), high_venc(:, :, 1, t));
|
||||
prob_error = eval_error(prob_v(:, :, 1, t), high_venc(:, :, 1, t));
|
||||
omme_error = eval_error(omme_v(:, :, 1, t), high_venc(:, :, 1, t));
|
||||
errors = [base_error, t_error, l3_error, l4_error, prob_error, omme_error]
|
||||
end
|
||||
Reference in New Issue
Block a user