-
Notifications
You must be signed in to change notification settings - Fork 0
/
Lucas_Kanade_Pyramidal_Optical_Flow_Main.m
64 lines (45 loc) · 2.35 KB
/
Lucas_Kanade_Pyramidal_Optical_Flow_Main.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
% This function calculates the deformation vector field (DVF) of 3D dicom image sequences using the pyramidal Lucas Kanade optical flow algorithm,
% provides images of that DVF projected in cross-sections and calculates the root-mean square registration error of the calculated DVF.
%
% Author : Pohl Michel
% Date : Sept 19th, 2022
% Version : v1.1
% License : 3-clause BSD License
clear all
close all
clc
addpath(genpath('1._Optical_flow_calculation'))
addpath(genpath('2._Optical_flow_evaluation'))
addpath(genpath('3._Auxiliary_functions_(calculus)'))
addpath(genpath('4._Auxiliary_functions_(loading_saving_files_and_parameters)'))
%% PARAMETERS
% Program behavior
beh_par = load_behavior_parameters3D();
% Directories
path_par = load_path_parameters3D();
% Input image sequences
input_im_dir_suffix_tab = [
string('111_HM10395 4DCT');
];
% The names of the image sequences for which the DVF needs to be calculated are placed inside the array above.
nb_seq = length(input_im_dir_suffix_tab);
for im_seq_idx = 1:nb_seq
% directory of the input images (text string inside the function)
path_par.input_im_dir_suffix = input_im_dir_suffix_tab(im_seq_idx);
path_par.input_im_dir = sprintf('%s\\%s', path_par.input_im_dir_pref, path_par.input_im_dir_suffix);
% Parameters concerning optical flow - depend on the input sequence - they are in an excel file
OF_par = load_3DOF_param(path_par);
% Image parameters
im_par = load_3Dim_param(path_par);
% Display parameters
disp_par = load_3Ddisplay_parameters(beh_par, im_par, path_par);
%% ---------------------------------------------------------------------------------------------------------------------------------------------------
% PROGRAM -------------------------------------------------------------------------------------------------------------------------------------------
% ---------------------------------------------------------------------------------------------------------------------------------------------------
compute_3Dof(OF_par, im_par, path_par);
if beh_par.SAVE_OF_PNG
save_3DOFpng(beh_par, path_par, disp_par, OF_par, im_par);
end
rms = evalOF(im_par,path_par,OF_par,beh_par);
write_log_file(path_par, beh_par, im_par, OF_par, rms);
end