22 #include "Base/ImageUtils/Scanline.hh"
25 template <
class StorageType>
27 LineMatcherNCC(
const unsigned int p1[2],
const unsigned int start2[2],
28 const unsigned int end2[2],
29 const StorageType **ida1,
const StorageType **ida2,
30 const StorageType **grad1,
const StorageType **grad2,
31 const unsigned int halfwinsize,
32 const unsigned int epsilon,
33 const double gradientscale,
34 unsigned int result[2],
35 double& correlation)
const
38 Scanline scan(start2, end2, epsilon);
40 StorageType grad_threshold=
41 (StorageType)rint((
double)grad1[p1[1]][p1[0]]*gradientscale);
46 BIASDOUT(D_REGION_MATCHER_LINE,
"point ("<<next[0]<<
", "<<next[1]<<
")");
47 if (grad2[next[1]][next[0]]>=grad_threshold){
48 NCC(p1, next, ida1, ida2, halfwinsize, tmpcorr);
51 BIASDOUT(D_REGION_MATCHER_LINE,
"gradient is big enough "
52 <<(
int)(grad2[next[1]][next[0]])<<
" > "<<gradientscale<<
" * "
53 <<(
int)(grad1[p1[1]][p1[0]])<<
"\tcorrelation: "<<tmpcorr);
54 if (tmpcorr>correlation){
60 BIASDOUT(D_REGION_MATCHER_LINE,
"gradient too small "
61 <<(
int)(grad2[next[1]][next[0]])<<
" <= "<<gradientscale<<
"*"
62 <<(
int)(grad1[p1[1]][p1[0]])<<
" = "<<(
int)grad_threshold);
65 if (correlation<-1.0) res=-1;
71 template <
class StorageType>
int
73 LineMatcherSAD(
const unsigned int p1[2],
const unsigned int start2[2],
74 const unsigned int end2[2],
75 const StorageType **ida1,
const StorageType **ida2,
76 const StorageType **grad1,
const StorageType **grad2,
77 const unsigned int halfwinsize,
const unsigned int epsilon,
78 const double gradientscale,
unsigned int result[2],
82 Scanline scan(start2, end2, epsilon);
84 StorageType grad_threshold=
85 (StorageType)rint((
double)grad1[p1[1]][p1[0]]*gradientscale);
90 BIASDOUT(D_REGION_MATCHER_LINE,
"point ("<<next[0]<<
", "<<next[1]<<
")");
91 if (grad2[next[1]][next[0]]>=grad_threshold){
92 SAD(p1, next, ida1, ida2, halfwinsize, tmpcorr);
95 BIASDOUT(D_REGION_MATCHER_LINE,
"gradient is big enough "
96 <<(
int)(grad2[next[1]][next[0]])<<
" > "<<gradientscale<<
" * "
97 <<(
int)(grad1[p1[1]][p1[0]])<<
"\tsad: "<<tmpcorr);
104 BIASDOUT(D_REGION_MATCHER_LINE,
"gradient too small "
105 <<(
int)(grad2[next[1]][next[0]])<<
" <= "<<gradientscale<<
"*"
106 <<(
int)(grad1[p1[1]][p1[0]])<<
" = "<<(
int)grad_threshold);
109 if (sad==DBL_MAX) res=-1;
115 template <
class StorageType>
int
117 LineMatcherSSD(
const unsigned int p1[2],
const unsigned int start2[2],
118 const unsigned int end2[2],
119 const StorageType **ida1,
const StorageType **ida2,
120 const StorageType **grad1,
const StorageType **grad2,
121 const unsigned int halfwinsize,
const unsigned int epsilon,
122 const double gradientscale,
unsigned int result[2],
126 Scanline scan(start2, end2, epsilon);
127 unsigned int next[2];
128 StorageType grad_threshold=
129 (StorageType)rint((
double)grad1[p1[1]][p1[0]]*gradientscale);
134 BIASDOUT(D_REGION_MATCHER_LINE,
"point ("<<next[0]<<
", "<<next[1]<<
")");
135 if (grad2[next[1]][next[0]]>=grad_threshold){
136 SSD(p1, next, ida1, ida2, halfwinsize, tmpcorr);
139 BIASDOUT(D_REGION_MATCHER_LINE,
"gradient is big enough "
140 <<(
int)(grad2[next[1]][next[0]])<<
" > "<<gradientscale<<
" * "
141 <<(
int)(grad1[p1[1]][p1[0]])<<
"\tssd: "<<tmpcorr);
148 BIASDOUT(D_REGION_MATCHER_LINE,
"gradient too small "
149 <<(
int)(grad2[next[1]][next[0]])<<
" <= "<<gradientscale<<
"*"
150 <<(
int)(grad1[p1[1]][p1[0]])<<
" = "<<(
int)grad_threshold);
153 if (ssd==DBL_MAX) res=-1;
Class for scanning a region given by a line and a distance ca.
bool GetNext(int next[2])