-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDICmatch_RG.m
More file actions
executable file
·95 lines (84 loc) · 3.44 KB
/
DICmatch_RG.m
File metadata and controls
executable file
·95 lines (84 loc) · 3.44 KB
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
function [Disp,strain,ZNCC,outIter] = DICmatch_RG(ImRef,ImDef,pCoord,p,Params,outP)
% Match image with reliabity guided strategy
% Author: Bin Chen;
% E-mail: binchen@kth.se
% Update: 2021-06-05
Lx = Params.Lx;
Ly = Params.Ly;
comptPoints = Params.comptPoints;
ZNCC = zeros(Params.NumCalPt,1);
outIter = zeros(Params.NumCalPt,1);
m = 1;
queue = [];
% used to find the four neighbored point in reliability guided strategy.
neighborLocal = [-1, 0, 1, 0;
0,-1, 0, 1];
Disp = zeros(Params.NumCalPt,2);
tic,
fprintf('Processing finished : ')
while length(queue)>0 || m<=2
if m==1
Params.thre = 1e-10;
[p,Czncc,Iter,disp] = corrIter(ImRef,ImDef,pCoord,p,Params);
ZNCC(Params.IndxInitP,:) = Czncc;
outP(Params.IndxInitP,:) = p;
Disp(Params.IndxInitP,:) = disp;
% Save the initial points.
Params.defRefInitPt = disp';
outIter(Params.IndxInitP,1) = Iter;
m = m+1;
[s,t] = ind2sub([Lx,Ly],Params.IndxInitP);
queue = [queue;s,t,Czncc];
pInit = p;
Params.thre = 1e-3;
end
% check the neighoring four points
for iNeighbor = 1:4
ii = neighborLocal(1,iNeighbor);
jj = neighborLocal(2,iNeighbor);
i = s+ii;
j = t+jj;
% if point (i,j) has been estimated before,
if i<1||j<1||i>Lx||j>Ly||ZNCC((j-1)*Lx+i,1) ~=0
continue
else
pointsIndx = (j-1)*Lx+i;
% pass initial value to next point
p = pInit';
p(1) = p(1)+p(2)*Params.Step*ii...
+p(3)*Params.Step*jj;
midTerm = 1+length(p)/2;
p(midTerm) = p(midTerm)+p(midTerm+1)*Params.Step*ii...
+p(midTerm+2)*Params.Step*jj;
pCoord = [comptPoints(pointsIndx,:)'; 1];
[p,Czncc,Iter,disp] = corrIter(ImRef,ImDef,pCoord,p,Params);
ZNCC(pointsIndx,:) = Czncc;
outP(pointsIndx,:) = p;
Disp(pointsIndx,:) = disp;
outIter(pointsIndx,1) = Iter;
%% (i, j) is the point to be calculated in next iteration
queue = [queue;i,j,Czncc];
m = m+1;
end
end
% (s, t) is the index of a point with best Czncc. In next loop, we
% will match its neighbored four points.
[~,znccindx] = sort(queue(:,3),'descend');
queue = queue(znccindx,:);
s = queue(1,1);
t = queue(1,2);
pInit = outP((t-1)*Lx+s,:);
queue(1,:) = [];
% printf
Num = floor(m/Params.NumCalPt*100);
if rem(Num,10)==0
fprintf(repmat('\b',1,length(num2str(Num))+6));
fprintf('%d %% ...',Num);
end
end
t = toc;
fprintf('\nSpeed: %.3d points/s',m/t)
fprintf('\nCompleted in %.3f seconds\n',t);
fprintf('Mean iteration: %0.2f\n\n',mean(outIter))
% Strain estimation
strain = strainEstPLS(Disp,Params);