/usr/include/vigra/affine_registration_fft.hxx is in libvigraimpex-dev 1.10.0+git20160211.167be93+dfsg-5ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 | /************************************************************************/
/* */
/* Copyright 2007-2014 by Benjamin Seppke */
/* */
/* This file is part of the VIGRA computer vision library. */
/* The VIGRA Website is */
/* http://hci.iwr.uni-heidelberg.de/vigra/ */
/* Please direct questions, bug reports, and contributions to */
/* ullrich.koethe@iwr.uni-heidelberg.de or */
/* vigra@informatik.uni-hamburg.de */
/* */
/* Permission is hereby granted, free of charge, to any person */
/* obtaining a copy of this software and associated documentation */
/* files (the "Software"), to deal in the Software without */
/* restriction, including without limitation the rights to use, */
/* copy, modify, merge, publish, distribute, sublicense, and/or */
/* sell copies of the Software, and to permit persons to whom the */
/* Software is furnished to do so, subject to the following */
/* conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the */
/* Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES */
/* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND */
/* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT */
/* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, */
/* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING */
/* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR */
/* OTHER DEALINGS IN THE SOFTWARE. */
/* */
/************************************************************************/
#ifndef VIGRA_AFFINE_REGISTRATION_FFT_HXX
#define VIGRA_AFFINE_REGISTRATION_FFT_HXX
#include "mathutil.hxx"
#include "matrix.hxx"
#include "linear_solve.hxx"
#include "tinyvector.hxx"
#include "splineimageview.hxx"
#include "imagecontainer.hxx"
#include "multi_shape.hxx"
#include "affinegeometry.hxx"
#include "correlation.hxx"
#include <cmath>
namespace vigra {
/** \addtogroup Registration Image Registration
*/
//@{
/********************************************************/
/* */
/* transformToPolarCoordinates */
/* */
/********************************************************/
/** \brief Transforms a given image to its (image-centered) polar coordinates representation.
This algorithm transforms a given image (by means of an spline image view) to its
image-centered polar coordinates reprensentation. The sampling of the polar coordinate system
is determined by the shape of the dest. image.
<b> Declarations:</b>
<b>\#include</b> \<vigra/affine_registration_fft.hxx\><br>
Namespace: vigra
pass 2D array views:
\code
namespace vigra {
template <class SplineImage,
class T1, class S1>
void
transformToPolarCoordinates(SplineImage const & src,
MultiArrayView<2, T1, S1> dest);
}
\endcode
\deprecatedAPI{estimateTranslation}
pass \ref ImageIterators and \ref DataAccessors :
\code
namespace vigra {
template <class SplineImage,
class DestIterator, class DestAccessor>
void
transformToPolarCoordinates(SplineImage const & src,
DestIterator dul, DestIterator dlr, DestAccessor dest)
}
\endcode
use argument objects in conjunction with \ref ArgumentObjectFactories :
\code
namespace vigra {
template <class SplineImage,
class DestIterator, class DestAccessor>
void
transformToPolarCoordinates(SplineImage const & src,
triple<DestIterator, DestIterator, DestAccessor> dest)
}
\endcode
\deprecatedEnd
*/
template <class SplineImage,
class DestIterator, class DestAccessor>
void
transformToPolarCoordinates(SplineImage const & src,
DestIterator d_ul, DestIterator d_lr, DestAccessor d_acc)
{
typename DestIterator::difference_type d_shape = (d_lr - d_ul);
int s_w = src.width(),
s_h = src.height();
int s_size = min(s_w, s_h);
int d_w = d_shape.x,
d_h = d_shape.y;
double r_max = s_size / 2.0;
DestIterator yd = d_ul;
DestIterator xd = yd;
for (int t_step = 0; t_step < d_h; t_step++, yd.y++)
{
xd = yd;
for (int r_step = 0; r_step < d_w; r_step++, xd.x++)
{
double theta = 2.0 * M_PI * double(t_step) / double(d_h);
double r = r_max * double(r_step) / double(d_w);
double u = r * cos(theta) + r_max;
double v = r * -sin(theta) + r_max;
if ( u >= 0 && u < s_size
&& v >= 0 && v < s_size)
{
d_acc.set(src(u, v), xd);
}
}
}
}
template <class SplineImage,
class DestIterator, class DestAccessor>
inline void
transformToPolarCoordinates(SplineImage const & src,
vigra::triple<DestIterator, DestIterator, DestAccessor> dest)
{
transformToPolarCoordinates(src, dest.first, dest.second, dest.third);
}
template <class SplineImage,
class T1, class S1>
void
transformToPolarCoordinates(SplineImage const & src,
MultiArrayView<2, T1, S1> dest)
{
transformToPolarCoordinates(src, srcImageRange(dest));
}
namespace detail
{
template <class SrcIterator, class SrcAccessor,
class DestIterator, class DestAccessor>
void
maximumFastNCC(SrcIterator s_ul, SrcIterator s_lr, SrcAccessor s_acc,
DestIterator d_ul, DestIterator d_lr, DestAccessor d_acc,
TinyVector<int,2> & position,
double & correlation_coefficent)
{
typename DestIterator::difference_type s_shape = s_lr - s_ul;
typename DestIterator::difference_type d_shape = d_lr - d_ul;
MultiArray<2, float> src(s_shape.x, s_shape.y), dest(d_shape.x, d_shape.y), ncc(d_shape.x, d_shape.y);
BasicImageView<float> src_view = makeBasicImageView(src);
BasicImageView<float> dest_view = makeBasicImageView(dest);
copyImage(srcIterRange(s_ul, s_lr, s_acc), destImage(src_view));
copyImage(srcIterRange(d_ul, d_lr, d_acc), destImage(dest_view));
fastNormalizedCrossCorrelation(dest, src, ncc);
int max_x = 0;
int max_y = 0;
float val = 0.0;
float max_val = -1.0;
for (int y = 0; y < ncc.height()-s_shape.y; y++)
{
for (int x = 0; x < ncc.width()-s_shape.x; x++)
{
val = ncc(x+s_shape.x/2, y+s_shape.y/2);
if (val > max_val)
{
max_x = x;
max_y = y;
max_val = val;
}
}
}
position[0] = max_x;
position[1] = max_y;
correlation_coefficent = max_val;
}
template <class SrcIterator, class SrcAccessor,
class DestIterator, class DestAccessor>
inline void
maximumFastNCC(triple<SrcIterator, SrcIterator, SrcAccessor> src,
triple<DestIterator, DestIterator, DestAccessor> dest,
TinyVector<int,2> & position,
double & correlation_coefficent)
{
maximumFastNCC(src.first, src.second, src.third,
dest.first, dest.second, dest.third,
position,
correlation_coefficent);
}
template <class SrcIterator, class SrcAccessor,
class DestIterator, class DestAccessor>
void fourierLogAbsSpectrumInPolarCoordinates(SrcIterator s_ul, SrcIterator s_lr, SrcAccessor s_acc,
DestIterator d_ul, DestIterator d_lr, DestAccessor d_acc)
{
using namespace vigra;
typename SrcIterator::difference_type shape = s_lr - s_ul;
FFTWComplexImage fourier(shape);
FImage fft_mag(shape);
fourierTransform(srcIterRange(s_ul, s_lr, s_acc), destImage(fourier));
moveDCToCenter(srcImageRange(fourier, FFTWMagnitudeAccessor<>()), destImage(fft_mag));
vigra::SplineImageView<2, double> spl(srcImageRange(fft_mag));
transformToPolarCoordinates(spl,
destIterRange(d_ul, d_lr, d_acc));
transformImage(srcIterRange(d_ul,d_lr,d_acc), destIter(d_ul,d_acc), log(abs(functor::Arg1())));
}
template <class SrcIterator, class SrcAccessor,
class DestIterator, class DestAccessor>
void fourierLogAbsSpectrumInPolarCoordinates(triple<SrcIterator, SrcIterator, SrcAccessor> src,
triple<DestIterator, DestIterator, DestAccessor> dest)
{
fourierLogAbsSpectrumInPolarCoordinates(src.first, src.second, src.third, dest.first, dest.second, dest.third);
}
} //namespace detail
/********************************************************/
/* */
/* estimateGlobalRotation */
/* */
/********************************************************/
/** \brief Estimate the rotation between two images by means of a normalized cross correlation matching of the FFT spectra.
This algorithm uses the fast normalized cross correlation to determine a global rotation
between two images (from image2 to image1). To derive the rotation, the algorithm performs the following steps:
<ol>
<li>Transforming both images to the frequency domain using FFTW</li>
<li>Create LogAbs PolarCoordinate representations for each spectrum.</li>
<li>Determining the final Rotation by performing a fast normalized cross correlation
based on the polar representations.</li>
</ol>
The images are cropped to the corresponding images center-squared before the estimation
takes place.
<b> Declarations:</b>
<b>\#include</b> \<vigra/affine_registration_fft.hxx\><br>
Namespace: vigra
pass 2D array views:
\code
namespace vigra {
template <class T1, class S1,
class T2, class S2>
void
estimateGlobalRotation(MultiArrayView<2, T1, S1> const & src,
MultiArrayView<2, T2, S2> dest,
Matrix<double> & affineMatrix,
double & correlation_coefficent);
}
\endcode
\deprecatedAPI{estimateGlobalRotation}
pass \ref ImageIterators and \ref DataAccessors :
\code
namespace vigra {
template <class SrcIterator, class SrcAccessor,
class DestIterator, class DestAccessor>
void
estimateGlobalRotation(SrcIterator sul, SrcIterator slr, SrcAccessor src,
DestIterator dul, DestIterator dlr, DestAccessor dest,
Matrix<double> & affineMatrix,
double & correlation_coefficent)
}
\endcode
use argument objects in conjunction with \ref ArgumentObjectFactories :
\code
namespace vigra {
template <class SrcIterator, class SrcAccessor,
class DestIterator, class DestAccessor>
void
estimateGlobalRotation(triple<SrcIterator, SrcIterator, SrcAccessor> src,
triple<DestIterator, DestIterator, DestAccessor> dest,
Matrix<double> & affineMatrix,
double & correlation_coefficent)
}
\endcode
\deprecatedEnd
*/
doxygen_overloaded_function(template <...> void estimateGlobalRotation)
template <class SrcIterator, class SrcAccessor,
class DestIterator, class DestAccessor>
void
estimateGlobalRotation(SrcIterator s_ul, SrcIterator s_lr, SrcAccessor s_acc,
DestIterator d_ul, DestIterator d_lr, DestAccessor d_acc,
Matrix<double> & affineMatrix,
double & correlation_coefficient)
{
//determine squared centers of both images without consuming any additional memory!
typename SrcIterator::difference_type s_shape = s_lr - s_ul;
Diff2D s2_shape(min(s_shape.x, s_shape.y),min(s_shape.x, s_shape.y));
Diff2D s2_offset = (s_shape-s2_shape)/2;
typename DestIterator::difference_type d_shape = d_lr - d_ul;
Diff2D d2_shape(min(d_shape.x, d_shape.y),min(d_shape.x, d_shape.y));
Diff2D d2_offset = (d_shape-d2_shape)/2;
//Determine Shape for united polar coordinate representation
Diff2D mean_shape = (s_shape + d_shape)/2;
int size = min(mean_shape.x, mean_shape.y);
if(size %2 == 0)
size++;
const int pc_w = size,
pc_h = size*6+1;
DImage s_polCoords(pc_w, pc_h/2),
d_polCoords(pc_w, pc_h),
ncc(pc_w, pc_h);
detail::fourierLogAbsSpectrumInPolarCoordinates(srcIterRange(s_ul+s2_offset, s_ul+s2_offset+s2_shape, s_acc),
destImageRange(d_polCoords));
copyImage(srcIterRange(d_polCoords.upperLeft(), d_polCoords.upperLeft() + vigra::Diff2D(pc_w, pc_h/2), d_polCoords.accessor()),
destImage(s_polCoords));
detail::fourierLogAbsSpectrumInPolarCoordinates(srcIterRange(d_ul+d2_offset, d_ul+d2_offset+d2_shape, d_acc),
destImageRange(d_polCoords));
//Basic Cross correlation is assumed to be faster here, as there are only pc_h comparisons possible...
normalizedCrossCorrelation(srcImageRange(d_polCoords), srcImageRange(s_polCoords), destImage(ncc));
int max_idx = 0;
double max_val = -1;
const int x=pc_w/2;
double val;
//Only look at a stripe for the maximum angle of rotation
//at the image center, at find the best fitting angle...
for (int y=0; y<pc_h/2; y++)
{
val = ncc(x,y+pc_h/4);
if (val > max_val)
{
max_idx = y;
max_val = val;
}
}
double theta = double(max_idx) / pc_h * 360.0;
affineMatrix = rotationMatrix2DDegrees(theta, vigra::TinyVector<double,2>(s_shape.x/2.0, s_shape.y/2.0));
correlation_coefficient = max_val;
}
template <class SrcIterator, class SrcAccessor,
class DestIterator, class DestAccessor>
inline void
estimateGlobalRotation(triple<SrcIterator, SrcIterator, SrcAccessor> src,
triple<DestIterator, DestIterator, DestAccessor> dest,
Matrix<double> & affineMatrix,
double & correlation_coefficient)
{
estimateGlobalRotation(src.first, src.second, src.third,
dest.first, dest.second, dest.third,
affineMatrix,
correlation_coefficient);
}
template <class T1, class S1,
class T2, class S2>
inline void
estimateGlobalRotation(MultiArrayView<2, T1, S1> const & src,
MultiArrayView<2, T2, S2> dest,
Matrix<double> & affineMatrix,
double & correlation_coefficent)
{
estimateGlobalRotation(srcImageRange(src),
destImageRange(dest),
affineMatrix,
correlation_coefficent);
}
/********************************************************/
/* */
/* estimateGlobalTranslation */
/* */
/********************************************************/
/** \brief Estimate the translation between two images by means of a normalized cross correlation matching.
This algorithm uses the fast normalized cross correlation to determine a global translation
between two images (from image2 to image1). To derive the translation, the algorithm consists of differents steps:
<ol>
<li>Separation of the second image<br/>
The second image (the one, for which the translation shall be determined) is cut into five
subregions: UpperLeft, UpperRight, Center, LowerLeft and LowerRight, each of 1/4 the size of
the original image. Using a border > 0 results in (all) overlapping regions.</li>
<li>Cross-Correlation of the subimages to the first image<br/>
The subimages are normalized cross-correlated to the (complete) first image.
The resulting maximum-likelihood translations and the correlation coefficients are stored for the next step.</li>
<li>Determining the final Translation by voting<br/>
Each correlation vector gets one vote at the beginning. For each equality of derived motion vectors,
the voting to these vectors is incremented. If the maximum number of votes is larger than 1, the vector with the
most votes is chosen. If the maximum number of votes is 1, the vector with the maximum likelihood is choosen.</li>
</ol>
<b> Declarations:</b>
<b>\#include</b> \<vigra/affine_registration_fft.hxx\><br>
Namespace: vigra
pass 2D array views:
\code
namespace vigra {
template <class T1, class S1,
class T2, class S2>
void
estimateGlobalTranslation(MultiArrayView<2, T1, S1> const & src,
MultiArrayView<2, T2, S2> dest,
Matrix<double> & affineMatrix,
double & correlation_coefficent,
Diff2D border = Diff2D(0,0));
}
\endcode
\deprecatedAPI{estimateGlobalTranslation}
pass \ref ImageIterators and \ref DataAccessors :
\code
namespace vigra {
template <class SrcIterator, class SrcAccessor,
class DestIterator, class DestAccessor>
void
estimateGlobalTranslation(SrcIterator sul, SrcIterator slr, SrcAccessor src,
DestIterator dul, DestIterator dlr, DestAccessor dest,
Matrix<double> & affineMatrix,
double & correlation_coefficent,
Diff2D border = Diff2D(0,0))
}
\endcode
use argument objects in conjunction with \ref ArgumentObjectFactories :
\code
namespace vigra {
template <class SrcIterator, class SrcAccessor,
class DestIterator, class DestAccessor>
void
estimateGlobalTranslation(triple<SrcIterator, SrcIterator, SrcAccessor> src,
triple<DestIterator, DestIterator, DestAccessor> dest,
Matrix<double> & affineMatrix,
double & correlation_coefficent,
Diff2D border = Diff2D(0,0))
}
\endcode
\deprecatedEnd
*/
doxygen_overloaded_function(template <...> void estimateGlobalTranslation)
template <class SrcIterator, class SrcAccessor,
class DestIterator, class DestAccessor>
void estimateGlobalTranslation(SrcIterator s_ul, SrcIterator s_lr, SrcAccessor s_acc,
DestIterator d_ul, DestIterator d_lr, DestAccessor d_acc,
Matrix<double> & affine_matrix,
double & correlation_coefficent,
Diff2D border = Diff2D(0,0))
{
typename SrcIterator::difference_type s_shape = s_lr - s_ul;
//determine matrix by using 5 quater-matches and a maximum likelihood decision:
Diff2D q_shape = (s_shape - border - border)/2;
if (q_shape.x % 2 == 0) q_shape.x--;
if (q_shape.y % 2 == 0) q_shape.y--;
Diff2D q_offsets[5];
q_offsets[0] = border;
q_offsets[1] = Diff2D(s_shape.x, 0)/2 + border;
q_offsets[2] = s_shape/4;
q_offsets[3] = Diff2D(0, s_shape.y)/2 + border;
q_offsets[4] = s_shape/2 + border;
TinyVector<int,2> translation_vectors[5];
double translation_correlations[5] = {0.0,0.0,0.0,0.0,0.0};
int translation_votes[5] = {1,1,1,1,1};
int max_corr_idx=0;
for (int q=0; q!=5; q++)
{
Diff2D offset = q_offsets[q];
//we are searching a transformation from img2 -> transformed image1, thus we switch dest and tmp
detail::maximumFastNCC(srcIterRange(d_ul+offset, d_ul+offset+q_shape, d_acc),
srcIterRange(s_ul, s_lr, s_acc),
translation_vectors[q],
translation_correlations[q]);
translation_vectors[q] = translation_vectors[q] - TinyVector<int,2>(offset);
if(translation_correlations[q] > translation_correlations[max_corr_idx])
{
max_corr_idx=q;
}
for (int q_old=0; q_old!=q; q_old++)
{
if (translation_vectors[q] == translation_vectors[q_old])
{
translation_votes[q_old]++;
}
}
}
int max_votes_idx=0;
for (int q=0; q!=5; q++)
{
if(translation_votes[q] > translation_votes[max_votes_idx])
{
max_votes_idx=q;
}
}
int best_idx=0;
if(translation_votes[max_votes_idx] > 1)
{
best_idx = max_votes_idx;
}
else
{
best_idx = max_corr_idx;
}
affine_matrix = translationMatrix2D(translation_vectors[best_idx]);
correlation_coefficent = translation_correlations[best_idx];
}
template <class SrcIterator, class SrcAccessor,
class DestIterator, class DestAccessor>
inline void
estimateGlobalTranslation(triple<SrcIterator, SrcIterator, SrcAccessor> src,
triple<DestIterator, DestIterator, DestAccessor> dest,
Matrix<double> & affineMatrix,
double & correlation_coefficent,
Diff2D border = Diff2D(0,0))
{
estimateGlobalTranslation(src.first, src.second, src.third,
dest.first, dest.second, dest.third,
affineMatrix,
correlation_coefficent,
border);
}
template <class T1, class S1,
class T2, class S2>
inline void
estimateGlobalTranslation(MultiArrayView<2, T1, S1> const & src,
MultiArrayView<2, T2, S2> dest,
Matrix<double> & affineMatrix,
double & correlation_coefficent,
Diff2D border = Diff2D(0,0))
{
estimateGlobalTranslation(srcImageRange(src),
destImageRange(dest),
affineMatrix,
correlation_coefficent,
border);
}
/********************************************************/
/* */
/* estimateGlobalRotationTranslation */
/* */
/********************************************************/
/** \brief Estimate the (global) rotation and translation between two images by means a normalized cross correlation matching.
This algorithm use the functions \ref estimateGlobalRotation() and
\ref estimateGlobalTranslation() to estimate a matrix which describes
the global rotation and translation from the second to the first image.
<b> Declarations:</b>
<b>\#include</b> \<vigra/affine_registration_fft.hxx\><br>
Namespace: vigra
pass 2D array views:
\code
namespace vigra {
template <class T1, class S1,
class T2, class S2>
void
estimateGlobalRotationTranslation(MultiArrayView<2, T1, S1> const & src,
MultiArrayView<2, T2, S2> dest,
Matrix<double> & affineMatrix,
double & rotation_correlation,
double & translation_correlation,
Diff2D border = Diff2D(0,0));
}
\endcode
\deprecatedAPI{estimateGlobalRotationTranslation}
pass \ref ImageIterators and \ref DataAccessors :
\code
namespace vigra {
template <class SrcIterator, class SrcAccessor,
class DestIterator, class DestAccessor>
void
estimateGlobalRotationTranslation(SrcIterator sul, SrcIterator slr, SrcAccessor src,
DestIterator dul, DestIterator dlr, DestAccessor dest,
Matrix<double> & affineMatrix,
double & rotation_correlation,
double & translation_correlation,
Diff2D border = Diff2D(0,0))
}
\endcode
use argument objects in conjunction with \ref ArgumentObjectFactories :
\code
namespace vigra {
template <class SrcIterator, class SrcAccessor,
class DestIterator, class DestAccessor>
void
estimateGlobalRotationTranslation(triple<SrcIterator, SrcIterator, SrcAccessor> src,
triple<DestIterator, DestIterator, DestAccessor> dest,
Matrix<double> & affineMatrix,
double & rotation_correlation,
double & translation_correlation,
Diff2D border = Diff2D(0,0))
}
\endcode
\deprecatedEnd
*/
doxygen_overloaded_function(template <...> void estimateGlobalRotationTranslation)
template <class SrcIterator, class SrcAccessor,
class DestIterator, class DestAccessor>
void
estimateGlobalRotationTranslation(SrcIterator s_ul, SrcIterator s_lr, SrcAccessor s_acc,
DestIterator d_ul, DestIterator d_lr, DestAccessor d_acc,
Matrix<double> & affineMatrix,
double & rotation_correlation,
double & translation_correlation,
Diff2D border = Diff2D(0,0))
{
typename DestIterator::difference_type d_shape = d_lr - d_ul;
//First step: Estimate rotation from img2 -> img1.
Matrix<double> rotation_matrix;
estimateGlobalRotation(srcIterRange(s_ul+border, s_lr-border, s_acc),
srcIterRange(d_ul+border, d_lr-border, d_acc),
rotation_matrix,
rotation_correlation);
//Second step: correct image according to the estimated rotation:
FImage tmp(d_shape);
SplineImageView<3, double> spl(srcIterRange(s_ul, s_lr, s_acc));
affineWarpImage(spl, destImageRange(tmp), rotation_matrix);
//Third step: find rotation between temp image (of step 2) and dest:
Matrix<double> translation_matrix;
estimateGlobalTranslation(srcImageRange(tmp),
srcIterRange(d_ul, d_lr, d_acc),
translation_matrix,
translation_correlation,
border);
affineMatrix = rotation_matrix * translation_matrix;
}
template <class SrcIterator, class SrcAccessor,
class DestIterator, class DestAccessor>
inline void
estimateGlobalRotationTranslation(triple<SrcIterator, SrcIterator, SrcAccessor> src,
triple<DestIterator, DestIterator, DestAccessor> dest,
Matrix<double> & affineMatrix,
double & rotation_correlation,
double & translation_correlation,
Diff2D border = Diff2D(0,0))
{
estimateGlobalRotationTranslation(src.first, src.second, src.third,
dest.first, dest.second, dest.third,
affineMatrix,
rotation_correlation,
translation_correlation,
border);
}
template <class T1, class S1,
class T2, class S2>
inline void
estimateGlobalRotationTranslation(MultiArrayView<2, T1, S1> const & src,
MultiArrayView<2, T2, S2> dest,
Matrix<double> & affineMatrix,
double & rotation_correlation,
double & translation_correlation,
Diff2D border = Diff2D(0,0))
{
estimateGlobalRotationTranslation(srcImageRange(src),
destImageRange(dest),
affineMatrix,
rotation_correlation,
translation_correlation,
border);
}
//@}
} // namespace vigra
#endif /* VIGRA_AFFINE_REGISTRATION_FFT_HXX */
|