-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcorrel4.m
88 lines (61 loc) · 3.31 KB
/
correl4.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
function [correlationRGB,centreCorr,ratio] = correl4(img,motif,RGB,Radius,Offset)
% pour des images 3D, par TF
if strcmp(RGB,'RGB')
correlationR = normxcorr2(motif(:,:,1),img(:,:,1));
correlationG = normxcorr2(motif(:,:,2),img(:,:,2));
correlationB = normxcorr2(motif(:,:,3),img(:,:,3));
correlationRGB = ((correlationR).*(correlationG).*(correlationB));
% correlationRGB = cat(3,correlationR,correlationG, correlationB);
ratio = [size(correlationRGB,1)/size(img,1) size(correlationRGB,2)/size(img,2)];
centreCorr = subpx2(correlationRGB);
centreCorr = floor(abs(centreCorr - [Radius, Radius] + [Offset(1), Offset(2)]));
return
elseif strcmp(RGB,'RG')
correlationR = normxcorr2(motif(:,:,1),img(:,:,1));
correlationG = normxcorr2(motif(:,:,2),img(:,:,2));
correlationRGB = ((correlationR).*(correlationG));
% correlationRGB = cat(3,correlationR,correlationG, correlationB);
ratio = [size(correlationRGB,1)/size(img,1) size(correlationRGB,2)/size(img,2)];
centreCorr = subpx2(correlationRGB);
centreCorr = floor(abs(centreCorr - [Radius, Radius] + [Offset(1), Offset(2)]));
return
elseif strcmp(RGB,'GB')
correlationG = normxcorr2(motif(:,:,2),img(:,:,2));
correlationB = normxcorr2(motif(:,:,3),img(:,:,3));
correlationRGB = ((correlationG).*(correlationB));
% correlationRGB = cat(3,correlationR,correlationG, correlationB);
ratio = [size(correlationRGB,1)/size(img,1) size(correlationRGB,2)/size(img,2)];
centreCorr = subpx2(correlationRGB);
% centreCorr = [centreCorr(1)*ratio(1) centreCorr(2)*ratio(2)];
% centreCorr = [centreCorr(1)*ratio(2) centreCorr(2)*ratio(1)];
% centreCorr = floor(abs(centreCorr - [Radius, Radius] + [Offset(1), Offset(2)]));
centreCorr = abs(centreCorr - [Radius, Radius] + [Offset(1), Offset(2)]);
return
elseif strcmp(RGB,'RB')
correlationR = normxcorr2(motif(:,:,1),img(:,:,1));
correlationB = normxcorr2(motif(:,:,3),img(:,:,3));
correlationRGB = ((correlationR).*(correlationB));
% correlationRGB = cat(3,correlationR,correlationG, correlationB);
ratio = [size(correlationRGB,1)/size(img,1) size(correlationRGB,2)/size(img,2)];
centreCorr = subpx2(correlationRGB);
centreCorr = floor(abs(centreCorr - [Radius, Radius] + [Offset(1), Offset(2)]));
return
elseif strcmp(RGB,'R')
correlationRGB = normxcorr2(motif(:,:,1),img(:,:,1));
ratio = [size(correlationRGB,1)/size(img,1) size(correlationRGB,2)/size(img,2)];
[centreCorr] = abs(floor(subpx2(correlationRGB)));
centreCorr = floor(abs(centreCorr - [Radius, Radius] + [Offset(1), Offset(2)]));
return
elseif strcmp(RGB,'G')
correlationRGB = normxcorr2(motif(:,:,2),img(:,:,2));
ratio = [size(correlationRGB,1)/size(img,1) size(correlationRGB,2)/size(img,2)];
[centreCorr] = abs(floor(subpx2(correlationRGB)));
centreCorr = floor(abs(centreCorr - [Radius, Radius] + [Offset(1), Offset(2)]));
return
elseif strcmp(RGB,'B')
correlationRGB = normxcorr2(motif(:,:,3),img(:,:,3));
ratio = [size(correlationRGB,1)/size(img,1) size(correlationRGB,2)/size(img,2)];
[centreCorr] = abs(floor(subpx2(correlationRGB)));
centreCorr = floor(abs(centreCorr - [Radius, Radius] + [Offset(1), Offset(2)]));
return
end