Skip to content
Snippets Groups Projects
Commit f83c482a authored by Nicola Vigano's avatar Nicola Vigano
Browse files

6D-reconstruction: moved primal updating function to the reconstruction class

parent 7c474aaf
No related branches found
No related tags found
No related merge requests found
......@@ -295,7 +295,7 @@ classdef Gt6DBlobReconstructor < Gt6DVolumeToBlobProjector
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Duals updating functions
%%% Primal and Duals updating functions
methods (Access = public)
function [q, mdivq] = update_dual_TV(self, q, new_enh_sol, lambda)
sigma = 1 ./ (2 * numel(new_enh_sol));
......@@ -356,6 +356,23 @@ classdef Gt6DBlobReconstructor < Gt6DVolumeToBlobProjector
q_odf = (q_odf + sigma .* (temp_odf - self.ODF)) .* sigma_1;
end
function [curr_sol, curr_enh_sol, app_time] = update_primal(self, curr_sol, curr_enh_sol, corr_tomo, corr_l1, tau)
c = tic();
if (self.algo_ops_c_functions)
% We actually re-use the same allocated volumes, saving time and
% reducing problems with matlab's garbage collection
[curr_sol, curr_enh_sol] = gt6DUpdatePrimal_c(curr_sol, curr_enh_sol, corr_tomo, corr_l1, tau, self.num_threads);
else
theta = 1;
v = curr_sol + (corr_tomo + corr_l1) .* tau;
v(v < 0) = 0;
curr_enh_sol = v + theta .* (v - curr_sol);
curr_sol = v;
end
app_time = toc(c);
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
......@@ -434,9 +451,8 @@ classdef Gt6DBlobReconstructor < Gt6DVolumeToBlobProjector
up_prim = compute_update_primal(ii_v);
[self.currentSolution{ii_v}, nextEnhancedSolution{ii_v}, app_time] ...
= gt6DUpdatePrimal(self.currentSolution{ii_v}, ...
nextEnhancedSolution{ii_v}, v{ii_gpu}, up_prim, tau{ii_v}, ...
self.algo_ops_c_functions, self.num_threads);
= self.update_primal(self.currentSolution{ii_v}, ...
nextEnhancedSolution{ii_v}, v{ii_gpu}, up_prim, tau{ii_v});
timing_app = timing_app + app_time;
end
clear v
......@@ -455,9 +471,8 @@ classdef Gt6DBlobReconstructor < Gt6DVolumeToBlobProjector
up_prim = compute_update_primal(n);
[self.currentSolution{n}, nextEnhancedSolution{n}, app_time] ...
= gt6DUpdatePrimal(self.currentSolution{n}, ...
nextEnhancedSolution{n}, v, up_prim, tau{n}, ...
self.algo_ops_c_functions, self.num_threads);
= self.update_primal(self.currentSolution{n}, ...
nextEnhancedSolution{n}, v, up_prim, tau{n});
timing_app = timing_app + app_time;
clear v
end
......
function [curr_sol, curr_enh_sol, app_time] = gt6DUpdatePrimal(curr_sol, curr_enh_sol, corr_tomo, corr_l1, tau, use_c_function, num_threads)
% function [new_sol, new_enh_sol] = gt6DUpdatePrimal(old_sol, corr_tomo, corr_l1, tau, use_c_function)
%
if (~exist('use_c_function', 'var'))
use_c_function = true;
end
if (~exist('num_threads', 'var'))
num_threads = 1;
end
c = tic();
if (use_c_function)
% We actually re-use the same allocated volumes, saving time and
% reducing problems with matlab's garbage collection
[curr_sol, curr_enh_sol] = gt6DUpdatePrimal_c(curr_sol, curr_enh_sol, corr_tomo, corr_l1, tau, num_threads);
else
theta = 1;
v = curr_sol + (corr_tomo + corr_l1) .* tau;
v(v < 0) = 0;
curr_enh_sol = v + theta .* (v - curr_sol);
curr_sol = v;
end
app_time = toc(c);
end
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment