opencv-phaseCorrelate-response.patch

Robert Huitl, 2012-06-20 02:46 pm

Download (2.2 kB)

 
modules/imgproc/include/opencv2/imgproc/imgproc.hpp (Arbeitskopie)
600 600
//! computes PSNR image/video quality metric
601 601
CV_EXPORTS_W double PSNR(InputArray src1, InputArray src2);
602 602

  
603
CV_EXPORTS_W Point2d phaseCorrelate(InputArray src1, InputArray src2, InputArray window = noArray());
603
static double _no_double;
604
CV_EXPORTS_W Point2d phaseCorrelate(InputArray src1, InputArray src2, InputArray window = noArray(), double& response = _no_double);
604 605
CV_EXPORTS_W void createHanningWindow(OutputArray dst, Size winSize, int type);
605 606

  
606 607
//! type of the threshold operation
modules/imgproc/src/phasecorr.cpp (Arbeitskopie)
406 406
    merge(planes, out);
407 407
}
408 408

  
409
static Point2d weightedCentroid(InputArray _src, cv::Point peakLocation, cv::Size weightBoxSize)
409
static Point2d weightedCentroid(InputArray _src, cv::Point peakLocation, cv::Size weightBoxSize, double& response)
410 410
{
411 411
    Mat src = _src.getMat();
412 412

  
......
475 475
        }
476 476
    }
477 477

  
478
    response = sumIntensity;
479

  
478 480
    sumIntensity += DBL_EPSILON; // prevent div0 problems...
479 481

  
480 482
    centroid.x /= sumIntensity;
......
485 487

  
486 488
}
487 489

  
488
cv::Point2d cv::phaseCorrelate(InputArray _src1, InputArray _src2, InputArray _window)
490
cv::Point2d cv::phaseCorrelate(InputArray _src1, InputArray _src2, InputArray _window, double& response)
489 491
{
490 492
    Mat src1 = _src1.getMat();
491 493
    Mat src2 = _src2.getMat();
......
553 555

  
554 556
    // get the phase shift with sub-pixel accuracy, 5x5 window seems about right here...
555 557
    Point2d t;
556
    t = weightedCentroid(C, peakLoc, Size(5, 5));
558
    t = weightedCentroid(C, peakLoc, Size(5, 5), response);
557 559

  
560
    // max response is M*N (not exactly, might be slightly larger due to rounding errors (?))
561
    response /= M*N;
562

  
558 563
    // adjust shift relative to image center...
559 564
    Point2d center((double)padded1.cols / 2.0, (double)padded1.rows / 2.0);
560 565