21 #include <Base/Common/W32Compat.hh>
24 #include "RegionMatcher.hh"
29 #include "LineMatcher.cpp"
30 #include "SimilarityMeasure.cpp"
31 #include <Base/Image/Image.hh>
49 template<
class StorageType>
51 const double &x,
const double &y,
const unsigned hws,
106 template<
class StorageType>
108 const double &x,
const double &y,
const unsigned hws,
114 const int size = 2 * hws + 1;
116 const int y_floor_start = (int) floor(y) - hws;
117 const int y_floor_end = y_floor_start + size;
118 const int x_floor_start = ((int) floor(x) - hws) * 3;
119 const int x_floor_end = x_floor_start + 3 * size;
120 if (x_floor_start < 0 || y_floor_start < 0 || x_floor_end + 3 > 3 * w
123 register const double dy = y - (double) floor(y);
124 register const double dx = x - (double) floor(x);
125 register const double dxy = dx * dy;
126 register int col_floor, col_ceil, row_floor, row_ceil, dst_row, dst_col;
127 register double ul, ur, ll, lr;
128 for (row_floor = y_floor_start; row_floor < y_floor_end; row_floor++) {
129 row_ceil = row_floor + 1;
130 dst_row = row_floor - y_floor_start;
131 for (col_floor = x_floor_start; col_floor < x_floor_end; col_floor++) {
132 dst_col = col_floor - x_floor_start;
133 col_ceil = col_floor + 3;
134 ul = (double) (ida[row_floor][col_floor]);
135 ur = (double) (ida[row_floor][col_ceil]);
136 ll = (double) (ida[row_ceil][col_floor]);
137 lr = (double) (ida[row_ceil][col_ceil]);
138 res[dst_row][dst_col] = ul + dy * (ll - ul) + dx * (ur - ul) + dxy
139 * (ul + lr - ll - ur);
145 template<
class StorageType>
147 const double &x,
const double &y,
const unsigned hws,
152 const unsigned size = 2 * hws + 1;
154 unsigned x_floor = (unsigned) floor(x);
155 unsigned y_floor = (unsigned) floor(y);
156 unsigned x_floor_end = x_floor + hws + 1;
157 unsigned y_floor_end = y_floor + hws + 1;
158 if (x_floor < hws || y_floor < hws || x_floor_end >= w || y_floor_end >= h)
160 unsigned rf, rc, cf, cc, r, c;
161 double ul, ur, ll, lr;
162 register double dy = y - (double) y_floor;
163 register double dx = x - (double) x_floor;
164 register double dxy = dx * dy;
165 for (rf = y_floor - hws, rc = rf + 1, r = 0; rf < y_floor_end; rf++, rc++, r++) {
166 for (cf = x_floor - hws, cc = cf + 1, c = 0; cf < x_floor_end; cf++, cc++, c++) {
167 ul = (double) (ida[rf][cf]);
168 ur = (double) (ida[rf][cc]);
169 ll = (double) (ida[rc][cf]);
170 lr = (double) (ida[rc][cc]);
171 res[r][c] = ul + dy * (ll - ul) + dx * (ur - ul) + dxy * (ul + lr
178 template<
class StorageType>
180 const double &x,
const unsigned &y,
const unsigned hws,
184 const unsigned size = 2 * hws + 1;
186 unsigned x_floor = (unsigned) floor(x);
187 unsigned x_floor_end = x_floor + hws + 1;
188 const unsigned maxy = y + hws;
189 if (x_floor < hws || y < hws || x_floor_end >= w || maxy >= h)
236 template<
class StorageType>
238 const unsigned int p2[2],
const StorageType **ida1,
239 const StorageType **ida2,
const unsigned int halfnccwinsize,
240 const unsigned int halfsearchwinsize,
unsigned int resultpoint[2],
241 const double mincorrelation,
double& result)
const {
243 unsigned int p3[2], p4[2];
244 double tmpresult, maxresult;
246 BIASDOUT(D_REGION_MATCHER_SEARCH_ODD,
"\np1: "<<p1[0]<<
" "<<p1[1]
247 <<
"\tp2: "<<p2[0]<<
" "<<p2[1]<<
"\tida1: "<<&ida1[0]
248 <<
" ida2: "<<&ida2[0]<<
" halfnccwinsize: "<<halfnccwinsize);
250 resultpoint[0] = p2[0];
251 resultpoint[1] = p2[1];
252 NCC(p1, p2, ida1, ida2, halfnccwinsize, maxresult);
253 BIASDOUT(D_REGION_MATCHER_SEARCH_ODD,
"("<<p2[0]<<
", "<<p2[1]<<
") : "
255 if (maxresult > mincorrelation) {
257 BIASDOUT(D_REGION_MATCHER_SEARCHNCC,
"first correlation succeeded "
260 BIASDOUT(D_REGION_MATCHER_SEARCHNCC,
"first correlation "<<maxresult);
261 for (
register unsigned int sr = 1; sr <= halfsearchwinsize; sr++) {
262 BIASDOUT(D_REGION_MATCHER_SEARCHNCC,
"search radius " << sr);
265 for (p3[0] = p2[0] - sr, p4[0] = p2[0] - sr; p3[0] <= p2[0] + sr; p3[0]++, p4[0]++) {
266 NCC(p1, p3, ida1, ida2, halfnccwinsize, tmpresult);
267 BIASDOUT(D_REGION_MATCHER_SEARCH_ODD,
"("<<p3[0]<<
", "<<p3[1]<<
") : "
269 if (tmpresult > maxresult) {
270 maxresult = tmpresult;
271 resultpoint[0] = p3[0];
272 resultpoint[1] = p3[1];
274 if (maxresult > mincorrelation)
277 NCC(p1, p4, ida1, ida2, halfnccwinsize, tmpresult);
278 BIASDOUT(D_REGION_MATCHER_SEARCH_ODD,
"("<<p4[0]<<
", "<<p4[1]<<
") : "
280 if (tmpresult > maxresult) {
281 maxresult = tmpresult;
282 resultpoint[0] = p4[0];
283 resultpoint[1] = p4[1];
285 if (maxresult > mincorrelation)
288 if (maxresult < result) {
291 for (p3[1] = p2[1] - sr - 1, p4[1] = p2[1] - sr - 1; p3[1]
292 <= p2[1] + sr - 1; p3[1]++, p4[1]++) {
293 NCC(p1, p3, ida1, ida2, halfnccwinsize, tmpresult);
294 BIASDOUT(D_REGION_MATCHER_SEARCH_ODD,
"("<<p3[0]<<
", "<<p3[1]<<
") : "
296 if (tmpresult > maxresult) {
297 maxresult = tmpresult;
298 resultpoint[0] = p3[0];
299 resultpoint[1] = p3[1];
301 if (maxresult > mincorrelation)
304 NCC(p1, p4, ida1, ida2, halfnccwinsize, tmpresult);
305 BIASDOUT(D_REGION_MATCHER_SEARCH_ODD,
"("<<p4[0]<<
", "<<p4[1]<<
") : "
307 if (tmpresult > maxresult) {
308 maxresult = tmpresult;
309 resultpoint[0] = p4[0];
310 resultpoint[1] = p4[1];
312 if (maxresult > mincorrelation)
316 if (maxresult > mincorrelation) {
318 BIASDOUT(D_REGION_MATCHER_SEARCHNCC,
"succeeded at searchradius "<<sr
319 <<
" with "<<result<<
" correlation point: "<<resultpoint);
324 if (mincorrelation < 1.0 && result < mincorrelation) {
325 BIASDOUT(D_REGION_MATCHER_SEARCHNCC,
"no success within "<<p2[0] <<
" "
327 <<
" +/- "<<halfsearchwinsize<<
" max correlation "<<result
328 <<
" at "<<resultpoint<<
" still lower than "<<mincorrelation);
330 }
else if (mincorrelation >= 1.0) {
331 BIASDOUT(D_REGION_MATCHER_SEARCHNCC,
"searched within "<<p2[0]<<
" "
333 <<
" +/- "<<halfsearchwinsize<<
" found max correlation "<<result
334 <<
" at "<<resultpoint[0]<<
", "<<resultpoint[1]);
341 template<
class StorageType>
343 const unsigned int p2[2],
const StorageType **ida1,
344 const StorageType **ida2,
const unsigned int halfnccwinsize,
345 const unsigned int halfsearchwinsize,
unsigned int resultpoint[2],
346 const double mincorrelation,
double& result)
const {
348 unsigned int p3[2], p4[2];
349 double tmpresult, maxresult = -1.0;
366 BIASDOUT(D_REGION_MATCHER_SEARCHNCC,
"\np1: "<<p1[0]<<
" "<<p1[1]
367 <<
"\tp2: "<<p2[0]<<
" "<<p2[1]<<
"\tida1: "<<&ida1[0]
368 <<
" ida2: "<<&ida2[0]<<
" halfnccwinsize: "<<halfnccwinsize);
369 for (
register unsigned int sr = 1; sr <= halfsearchwinsize; sr++) {
370 BIASDOUT(D_REGION_MATCHER_SEARCHNCC,
"search radius " << sr);
372 p3[1] = p2[1] - sr + 1;
374 for (p3[0] = p2[0] - sr + 1, p4[0] = p2[0] - sr + 1; p3[0] <= p2[0]
375 + sr; p3[0]++, p4[0]++) {
376 NCC(p1, p3, ida1, ida2, halfnccwinsize, tmpresult);
377 BIASDOUT(D_REGION_MATCHER_SEARCH_EVEN,
"("<<p3[0]<<
", "<<p3[1]<<
") : "
379 if (tmpresult > maxresult) {
380 maxresult = tmpresult;
381 resultpoint[0] = p3[0];
382 resultpoint[1] = p3[1];
384 if (maxresult > mincorrelation)
387 NCC(p1, p4, ida1, ida2, halfnccwinsize, tmpresult);
388 BIASDOUT(D_REGION_MATCHER_SEARCH_EVEN,
"("<<p4[0]<<
", "<<p4[1]<<
") : "
390 if (tmpresult > maxresult) {
391 maxresult = tmpresult;
392 resultpoint[0] = p4[0];
393 resultpoint[1] = p4[1];
395 if (maxresult > mincorrelation)
398 if (maxresult < mincorrelation) {
399 p3[0] = p2[0] - sr + 1;
401 for (p3[1] = p2[1] - sr + 2, p4[1] = p2[1] - sr + 2; p3[1] <= p2[1]
402 + sr - 1; p3[1]++, p4[1]++) {
403 NCC(p1, p3, ida1, ida2, halfnccwinsize, tmpresult);
404 BIASDOUT(D_REGION_MATCHER_SEARCH_EVEN,
"("<<p3[0]<<
", "<<p3[1]<<
") : "
406 if (tmpresult > maxresult) {
407 maxresult = tmpresult;
408 resultpoint[0] = p3[0];
409 resultpoint[1] = p3[1];
411 if (maxresult > mincorrelation)
414 NCC(p1, p4, ida1, ida2, halfnccwinsize, tmpresult);
415 BIASDOUT(D_REGION_MATCHER_SEARCH_EVEN,
"("<<p4[0]<<
", "<<p4[1]<<
") : "
417 if (tmpresult > maxresult) {
418 maxresult = tmpresult;
419 resultpoint[0] = p4[0];
420 resultpoint[1] = p4[1];
422 if (maxresult > mincorrelation)
426 if (maxresult > mincorrelation) {
428 BIASDOUT(D_REGION_MATCHER_SEARCHNCC,
"succeeded at searchradius "<<sr
429 <<
" with "<<result<<
" correlation point: "<<resultpoint);
434 if (mincorrelation < 1.0 && result < mincorrelation) {
435 BIASDOUT(D_REGION_MATCHER_SEARCHNCC,
"no success within "<<p2[0]<<
" "
437 <<
" +/- "<<halfsearchwinsize<<
" max correlation "<<result
438 <<
" at "<<resultpoint<<
" still lower than "<<mincorrelation);
440 }
else if (mincorrelation >= 1.0) {
441 BIASDOUT(D_REGION_MATCHER_SEARCHNCC,
"searched within "<<p2[0]<<
" "<<p2[1]
442 <<
" +/- "<<halfsearchwinsize<<
" found max correlation "<<result
443 <<
" at "<<resultpoint[0]<<
", "<<resultpoint[1]);
450 template<
class StorageType>
452 const KLT_TYPE y)
const {
453 unsigned int x_floor = (
unsigned int) floor(x);
454 unsigned int y_floor = (
unsigned int) floor(y);
455 unsigned int x_ceil = (
unsigned int) ceil(x);
456 unsigned int y_ceil = (
unsigned int) ceil(y);
457 StorageType ul = ida[y_floor][x_floor];
458 StorageType ur = ida[y_floor][x_ceil];
459 StorageType ll = ida[y_ceil][x_floor];
460 StorageType lr = ida[y_ceil][x_ceil];
461 KLT_TYPE dy = y - y_floor;
462 KLT_TYPE dx = x - x_floor;
464 return ul + dy * (ll - ul) + dx * (ur - ul) + dy * dx * (ul + lr - ll - ur);
468 const KLT_TYPE y)
const {
481 register unsigned int x_floor = (
unsigned int) floor(x);
482 register unsigned int y_floor = (
unsigned int) floor(y);
483 register unsigned int x_ceil = x_floor + 1;
484 register unsigned int y_ceil = y_floor + 1;
485 register unsigned int ul = (
unsigned int) ida[y_floor][x_floor];
486 register unsigned int ur = (
unsigned int) ida[y_floor][x_ceil];
487 register unsigned int ll = (
unsigned int) ida[y_ceil][x_floor];
488 register unsigned int lr = (
unsigned int) ida[y_ceil][x_ceil];
489 register unsigned int dy = (
unsigned int) rint((y - y_floor) * 256);
490 register unsigned int dx = (
unsigned int) rint((x - x_floor) * 256);
492 return (
unsigned char) (((ul << 16) + (dy << 8) * (ll - ul) + (dx << 8)
493 * (ur - ul) + dy * dx * (ul - ll - ur + lr)) >> 16);
496 template<
class StorageType>
499 unsigned x_floor = (
unsigned int) floor(x);
500 unsigned y_floor = (
unsigned int) floor(y);
501 unsigned x_floor_end = x_floor + hws + 1;
502 unsigned y_floor_end = y_floor + hws + 1;
503 unsigned rf, rc, cf, cc, r, c;
504 StorageType ul, ur, ll, lr;
505 register KLT_TYPE dy = (KLT_TYPE) (y - y_floor);
506 register KLT_TYPE dx = (KLT_TYPE) (x - x_floor);
507 register KLT_TYPE dxy = dx * dy;
508 for (rf = y_floor - hws, rc = rf + 1, r = 0; rf < y_floor_end; rf++, rc++, r++) {
509 for (cf = x_floor - hws, cc = cf + 1, c = 0; cf < x_floor_end; cf++, cc++, c++) {
514 res[r][c] = (KLT_TYPE) (ul + dy * (ll - ul) + dx * (ur - ul) + dxy
515 * (ul + lr - ll - ur));
521 const KLT_TYPE x,
const KLT_TYPE y,
const unsigned hws,
523 unsigned int x_floor = (
unsigned int) floor(x);
524 unsigned int y_floor = (
unsigned int) floor(y);
525 unsigned int x_floor_end = x_floor + hws + 1;
526 unsigned int y_floor_end = y_floor + hws + 1;
527 unsigned rf, rc, cf, cc, r, c;
528 unsigned ul, ur, ll, lr;
529 register unsigned int dy = (
unsigned int) rint((y - y_floor) * 256);
530 register unsigned int dx = (
unsigned int) rint((x - x_floor) * 256);
531 register unsigned int dxy = dx * dy;
532 for (rf = y_floor - hws, rc = rf + 1, r = 0; rf < y_floor_end; rf++, rc++, r++) {
533 for (cf = x_floor - hws, cc = cf + 1, c = 0; cf < x_floor_end; cf++, cc++, c++) {
534 ul = (unsigned) ida[rf][cf];
535 ur = (unsigned) ida[rf][cc];
536 ll = (unsigned) ida[rc][cf];
537 lr = (unsigned) ida[rc][cc];
538 res[r][c] = (
unsigned char) (((ul << 16) + (dy << 8) * (ll - ul)
539 + (dx << 8) * (ur - ul) + dxy * (ul - ll - ur + lr)) >> 16);
609 template<
class StorageType>
611 const unsigned int p2[2],
const StorageType **ida1,
612 const StorageType **ida2,
const unsigned int halfwinsize,
613 KLT_TYPE result[2])
const {
616 double x1, x2, x3, y1, y2, y3;
617 unsigned int p2tmp[2];
618 BIASDOUT(D_REGION_MATCHER_PARABOLA,
"p1 ("<<p1[0]<<
", "<<p1[1]<<
")\tp2 ("
619 <<p2[0]<<
", "<<p2[1]<<
")\tida1: "<<&ida1[0]<<
" ida2: "<<&ida2[0]
620 <<
" halfwinsize: "<<halfwinsize);
621 NCC(p1, p2, ida1, ida2, halfwinsize, x2);
625 p2tmp[1] = p2[1] - 1;
626 NCC(p1, p2tmp, ida1, ida2, halfwinsize, y1);
627 p2tmp[1] = p2[1] + 1;
628 NCC(p1, p2tmp, ida1, ida2, halfwinsize, y3);
629 p2tmp[0] = p2[0] - 1;
631 NCC(p1, p2tmp, ida1, ida2, halfwinsize, x1);
632 p2tmp[0] = p2[0] + 1;
633 NCC(p1, p2tmp, ida1, ida2, halfwinsize, x3);
635 if (x3 >= x2 || x1 >= x2) {
636 BIASERR(
"invalid correlation data "<<x1<<
" "<<x2
637 <<
" "<<x3<<
"\n\tcorrelation between ("
638 <<p1[0]<<
", "<<p1[1]<<
") and ("<<p2[0]
639 <<
", "<<p2[1]<<
") is not a local maximum");
642 if (y3 >= y2 || y1 >= y2) {
643 BIASERR(
"invalid correlation data "<<y1<<
" "<<y2
644 <<
" "<<y3<<
"\n\tcorrelation between ("
645 <<p1[0]<<
", "<<p1[1]<<
") and ("<<p2[0]
646 <<
", "<<p2[1]<<
") is not a local maximum");
652 BIASDOUT(D_REGION_MATCHER_PARABOLA,
"\n(x1 x2 x3) : res\t("<<x1<<
" "<<x2<<
" "
653 <<x3<<
") : "<<result[0]-p2[0]<<
"\n(y1 y2 y3) : res\t("
654 <<y1<<
" "<<y2<<
" "<<y3<<
") : "<<result[1]-p2[1]);
658 template<
class StorageType>
660 const unsigned int p2[2],
const StorageType **ida1,
661 const StorageType **ida2,
const unsigned int halfwinsize,
662 KLT_TYPE result[2])
const {
665 double x1, x2, x3, x4, x5, y1, y2, y3, y4, y5;
666 unsigned int p2tmp[2];
667 BIASDOUT(D_REGION_MATCHER_PARABOLA,
"p1 ("<<p1[0]<<
", "<<p1[1]<<
")\tp2 ("
668 <<p2[0]<<
", "<<p2[1]<<
")\tida1: "<<&ida1[0]<<
" ida2: "<<&ida2[0]
669 <<
" halfwinsize: "<<halfwinsize);
670 NCC(p1, p2, ida1, ida2, halfwinsize, x3);
674 p2tmp[1] = p2[1] - 1;
675 NCC(p1, p2tmp, ida1, ida2, halfwinsize, y2);
676 p2tmp[1] = p2[1] - 2;
677 NCC(p1, p2tmp, ida1, ida2, halfwinsize, y1);
678 p2tmp[1] = p2[1] + 1;
679 NCC(p1, p2tmp, ida1, ida2, halfwinsize, y4);
680 p2tmp[1] = p2[1] + 2;
681 NCC(p1, p2tmp, ida1, ida2, halfwinsize, y5);
682 p2tmp[0] = p2[0] - 1;
684 NCC(p1, p2tmp, ida1, ida2, halfwinsize, x2);
685 p2tmp[0] = p2[0] - 2;
686 NCC(p1, p2tmp, ida1, ida2, halfwinsize, x1);
687 p2tmp[0] = p2[0] + 1;
688 NCC(p1, p2tmp, ida1, ida2, halfwinsize, x4);
689 p2tmp[0] = p2[0] + 2;
690 NCC(p1, p2tmp, ida1, ida2, halfwinsize, x5);
692 if (x1 >= x3 || x2 >= x3 || x4 >= x3 || x5 >= x3) {
693 BIASERR(
"invalid correlation data "<<x1<<
" "<<x2
694 <<
" "<<x3<<
" "<<x4<<
" "<<x5<<
"\n\tcorrelation between ("
695 <<p1[0]<<
", "<<p1[1]<<
") and ("<<p2[0]
696 <<
", "<<p2[1]<<
") is not a local maximum");
699 if (y1 >= y3 || y2 >= y3 || y4 >= y3 || y5 >= y3) {
700 BIASERR(
"invalid correlation data "<<y1<<
" "<<y2
701 <<
" "<<y3<<
" "<<y4<<
" "<<y5<<
"\n\tcorrelation between ("
702 <<p1[0]<<
", "<<p1[1]<<
") and ("<<p2[0]
703 <<
", "<<p2[1]<<
") is not a local maximum");
709 BIASDOUT(D_REGION_MATCHER_PARABOLA,
710 "\n(x1 x2 x3 x4 x5) : res\t("<<x1<<
" "<<x2<<
" "<<x3<<
" "<<x4
711 <<
" "<<x5<<
") : "<<result[0]-p2[0]<<
"\n(y1 y2 y3 y4 y5) : res\t("
712 <<y1<<
" "<<y2<<
" "<<y3<<
" "<<y4<<
" "<<y5<<
") : "<<result[1]-p2[1]);
716 template<
class StorageType>
718 StorageType>& img1,
const unsigned int x2,
const unsigned int y2,
722 for (
unsigned int ch = 0; ch < img1.GetChannelCount(); ch++) {
723 res += fabs((
float) img1.PixelValue(x1, y1,
724 static_cast<unsigned short int> (ch))
726 static_cast<unsigned short int> (ch)));
737 #define INSTUC(uctype)\
738 template BIASMatcher2D_EXPORT void RegionMatcher::NCC<uctype>(const double p1[2],\
739 const double p2[2], const uctype **ida1, const uctype **ida2, const unsigned halfwinsize,\
741 template BIASMatcher2D_EXPORT void RegionMatcher::NCC<uctype>(\
742 const unsigned int p1[2], const unsigned int p2[2], const uctype **ida1, const uctype **roi1,\
743 const uctype **ida2, const uctype **roi2, const unsigned hww, const unsigned hwh, double& result)const ;\
744 template BIASMatcher2D_EXPORT int RegionMatcher::NCCSearchOdd<uctype>(\
745 const unsigned int p1[2], const unsigned int p2[2], const uctype **ida1, const uctype **ida2,\
746 const unsigned int halfnccwinsize, const unsigned int halfsearchwinsize,\
747 unsigned int resultpoint[2], const double mincorrelation, double& result)const ;\
748 template BIASMatcher2D_EXPORT int RegionMatcher::NCCSearchEven<uctype>(\
749 const unsigned int p1[2], const unsigned int p2[2],const uctype **ida1, const uctype **ida2,\
750 const unsigned int halfnccwinsize, const unsigned int halfsearchwinsize,\
751 unsigned int resultpoint[2], const double mincorrelation, double& result)const ;\
752 template BIASMatcher2D_EXPORT int RegionMatcher::LineMatcherNCC<uctype>(\
753 const unsigned int p1[2], const unsigned int start2[2], const unsigned int end2[2],\
754 const uctype **ida1, const uctype **ida2, const uctype **grad1, const uctype **grad2,\
755 const unsigned int halfwinsize, const unsigned int epsilon, const double gradientscale,\
756 unsigned int result[2], double& correlation)const ;\
757 template BIASMatcher2D_EXPORT int RegionMatcher::LineMatcherSAD<uctype>(\
758 const unsigned int p1[2], const unsigned int start2[2], const unsigned int end2[2],\
759 const uctype **ida1, const uctype **ida2, const uctype **grad1, const uctype **grad2,\
760 const unsigned int halfwinsize, const unsigned int epsilon, const double gradientscale,\
761 unsigned int result[2], double& sad)const ;\
762 template BIASMatcher2D_EXPORT int RegionMatcher::LineMatcherSSD<uctype>(\
763 const unsigned int p1[2], const unsigned int start2[2], const unsigned int end2[2],\
764 const uctype **ida1, const uctype **ida2, const uctype **grad1, const uctype **grad2,\
765 const unsigned int halfwinsize, const unsigned int epsilon, const double gradientscale,\
766 unsigned int result[2], double& ssd)const ;\
767 template BIASMatcher2D_EXPORT int RegionMatcher::ParabolaNCC(\
768 const unsigned int p1[2], const unsigned int p2[2], const uctype **ida1, const uctype **ida2,\
769 const unsigned int halfwinsize, KLT_TYPE result[2])const ;\
770 template BIASMatcher2D_EXPORT int RegionMatcher::ParabolaNCC5(\
771 const unsigned int p1[2], const unsigned int p2[2], const uctype **ida1, const uctype **ida2,\
772 const unsigned int halfwinsize, KLT_TYPE result[2])const ;\
773 template BIASMatcher2D_EXPORT void RegionMatcher::ColorNCC<uctype>(\
774 const unsigned int p1[2], const unsigned int p2[2], const uctype **ida1, const uctype **ida2,\
775 const unsigned int halfwinsize, double& result)const ;\
776 template BIASMatcher2D_EXPORT void RegionMatcher::CNCC<uctype>(\
777 const unsigned int p1[2], const unsigned int p2[2], const uctype **ida1, const uctype **ida2,\
778 const unsigned int halfwinsize, double& result) const;
785 template BIASMatcher2D_EXPORT void RegionMatcher::SSD<itype>(const unsigned int p1[2]\
786 , const unsigned int p2[2], const itype **ida1, const itype **ida2, const unsigned int halfwinsize,\
787 double& result) const;\
788 template BIASMatcher2D_EXPORT void RegionMatcher::NCC<itype>(const unsigned int p1[2]\
789 , const unsigned int p2[2], const itype **ida1, const itype **ida2, const unsigned int halfwinsize,\
790 double& result) const;\
791 template BIASMatcher2D_EXPORT void RegionMatcher::SAD<itype>(const unsigned int p1[2]\
792 , const unsigned int p2[2], const itype **ida1, const itype **ida2, const unsigned int halfwinsize,\
793 double& result) const;\
794 template BIASMatcher2D_EXPORT void RegionMatcher::SAD<itype>(const unsigned int p1[2]\
795 , const unsigned int p2[2], const itype **ida1, const itype **ida2, const unsigned int halfwinsize, const unsigned channel_count, double& result) const; \
796 template BIASMatcher2D_EXPORT void RegionMatcher::SADN<itype>(\
797 const unsigned int p1[2], const unsigned int p2[2], const itype **ida1, const itype **ida2,\
798 const unsigned int halfwinsize, double& result) const;
800 #define INST_IM(itype)\
801 template BIASMatcher2D_EXPORT bool RegionMatcher::BilinearRegion<itype>(\
802 const Image<itype>& im, const double &x, const double &y, \
803 const unsigned hws, Matrix<double>& res); \
804 template BIASMatcher2D_EXPORT bool RegionMatcher::BilinearRegionColor<itype>(\
805 const Image<itype>& im, const double &x, const double &y, \
806 const unsigned hws, Matrix<double>& res); \
807 template BIASMatcher2D_EXPORT bool RegionMatcher::BilinearRegionColor3<itype>(\
808 const Image<itype>& im, const double &x, const double &y, \
809 const unsigned hws, Matrix<double>& res); \
810 template BIASMatcher2D_EXPORT bool RegionMatcher::LinearRegionX<itype>(\
811 const Image<itype>& im, const double &x, const unsigned &y, \
812 const unsigned hws, Matrix<double>& res);\
813 template BIASMatcher2D_EXPORT float RegionMatcher::AD<itype>(const unsigned int x1, const unsigned int y1,\
814 Image<itype>& img1, const unsigned int x2, const unsigned int y2, Image<itype>& img2);
819 INSTUC(
unsigned char)
824 INSTUC(
unsigned short)
835 INST_IM(
unsigned char)
838 #ifdef BUILD_IMAGE_INT
841 #ifdef BUILD_IMAGE_CHAR
844 #ifdef BUILD_IMAGE_SHORT
847 #ifdef BUILD_IMAGE_USHORT
848 INST_IM(
unsigned short)
850 #ifdef BUILD_IMAGE_UINT
851 INST_IM(
unsigned int)
853 #ifdef BUILD_IMAGE_DOUBLE
Matrix< KLT_TYPE > _gx1_5
static bool BilinearRegionColor3(const Image< StorageType > &im, const double &x, const double &y, const unsigned hws, Matrix< double > &res)
Fast bilinear interpolation of a region in interleaved color image.
bool IsInterleaved() const
Matrix< KLT_TYPE > _gx2_5
Matrix< T > & newsize(Subscript M, Subscript N)
static bool LinearRegionX(const Image< StorageType > &im, const double &x, const unsigned &y, const unsigned hws, Matrix< double > &res)
Fast linear interpolation of a region in the image, untested.
Matrix< KLT_TYPE > _bl1_5
Matrix< KLT_TYPE > _gsy_5
unsigned int GetWidth() const
StorageType PixelValue(const unsigned int x, const unsigned int y, const unsigned short int channel=0) const
Returns value of pixel at specific position, using specific channel as offset.
int NCCSearchEven(const unsigned int p1[2], const unsigned int p2[2], const StorageType **ida1, const StorageType **ida2, const unsigned int halfnccwinsize, const unsigned int halfsearchwinsize, unsigned int resultpoint[2], const double mincorrelation, double &result) const
As above but middle point of searchwindow is p1[0]+0.5, p1[1]+0.5 Searchwindow is always even-sized f...
static float AD(const unsigned int x1, const unsigned int y1, BIAS::Image< StorageType > &img1, const unsigned int x2, const unsigned int y2, BIAS::Image< StorageType > &img2)
calculates absolute difference between pixel (x1,y1) in image img1 and (x2,y2) in img2 ...
int ParabolaNCC(const unsigned int p1[2], const unsigned int p2[2], const StorageType **ida1, const StorageType **ida2, const unsigned int halfwinsize, KLT_TYPE result[2]) const
function to achieve sub-pixel accuracy if p1 and p2 are corresponding image points from ida1 resp ida...
int NCCSearchOdd(const unsigned int p1[2], const unsigned int p2[2], const StorageType **ida1, const StorageType **ida2, const unsigned int halfnccwinsize, const unsigned int halfsearchwinsize, unsigned int resultpoint[2], const double mincorrelation, double &result) const
Searches in a window around p2 [p2[i]+-halfsearchwinsize] for a point with correlation > mincorrelati...
Matrix< KLT_TYPE > _bl2_5
unsigned int GetChannelCount() const
returns the number of Color channels, e.g.
Matrix< KLT_TYPE > _gy2_5
unsigned int GetHeight() const
Matrix< KLT_TYPE > _gy1_5
static bool BilinearRegion(const Image< StorageType > &im, const double &x, const double &y, const unsigned hws, Matrix< double > &res)
Fast bilinear interpolation of a region in grey image.
The image template class for specific storage types.
Matrix< KLT_TYPE > _gsx_5
KLT_TYPE _ParabolaApprox(const KLT_TYPE x1, const KLT_TYPE x2, const KLT_TYPE x3) const
bilinear interpolation, also moved gradient image data from [0:255] to [-127, 128] before interpolati...
int ParabolaNCC5(const unsigned int p1[2], const unsigned int p2[2], const StorageType **ida1, const StorageType **ida2, const unsigned int halfwinsize, KLT_TYPE result[2]) const
function to achieve sub-pixel accuracy if p1 and p2 are corresponding image points from ida1 resp ida...
void NCC(const unsigned int p1[2], const unsigned int p2[2], const StorageType **ida1, const StorageType **ida2, const unsigned int halfwinsize, double &result) const
fast ncc between p1 and p2 without boundary checking Faster specialisation for unsigned char exists b...
void _BilinearRegion(const StorageType **ida, const KLT_TYPE x, const KLT_TYPE y, const unsigned hws, Matrix< KLT_TYPE > &res) const
bilinear interpolation, also moved gradient image data from [0:255] to [-127, 128] before interpolati...
KLT_TYPE _Bilinear(const StorageType **ida, const KLT_TYPE x, const KLT_TYPE y) const
static bool BilinearRegionColor(const Image< StorageType > &im, const double &x, const double &y, const unsigned hws, Matrix< double > &res)
Fast bilinear interpolation of a region in interleaved color image.
const StorageType ** GetImageDataArray() const
overloaded GetImageDataArray() from ImageBase