phaseCorrelation: return magnitude of the peak (Patch #2071)


Added by Robert Huitl over 12 years ago. Updated over 12 years ago.


Status:Done Start date:2012-06-20
Priority:Normal Due date:
Assignee:Vadim Pisarevsky % Done:

80%

Category:imgproc, video
Target version:2.4.3
Affected version: Operating System:
Difficulty: HW Platform:
Pull request:

Description

Hi, just a simple patch I made to return the magnitude of the response.

If phase correlation cannot determine the translation reliably, there will be multiple peaks in the spatial domain, or no peaks at all (basically just noise). Nevertheless, phaseCorrelation() returns the translation vector for the largest peak, however it does not return any information about how large this peak is compared to other peaks.

This patch returns the sum of the responses in the 5x5 window in the output parameter "response". If there's only a single peak, response will be fairly large (~0.3 - 1), allowing the caller to assess the quality of the translation vector.

- cv::Point2d cv::phaseCorrelate(InputArray _src1, InputArray _src2, InputArray _window)
+ cv::Point2d cv::phaseCorrelate(InputArray _src1, InputArray _src2, InputArray _window, double& response)

Cheers,
Robert


opencv-phaseCorrelate-response.patch (2.2 kB) Robert Huitl, 2012-06-20 02:46 pm

opencv-phaseCorrelate-response.patch (4.5 kB) Robert Huitl, 2012-06-21 04:59 pm

opencv-phaseCorrelate-response.patch (3.7 kB) Robert Huitl, 2012-06-21 11:02 pm


Associated revisions

Revision 0c65ea97
Added by Vadim Pisarevsky over 12 years ago

added the optional output maxima value to phaseCorrelate (patch #2071 by Robert Huitl)

Revision 8539d424
Added by Vadim Pisarevsky over 10 years ago

Merge pull request #2071 from pemmanuelviel:LshOrthogonalSubvectors

History

Updated by Vadim Pisarevsky over 12 years ago

hello! the patch breaks compatibility with previous versions even at the source code level, so it can not be accepted.

cv::Point2d cv::phaseCorrelate(InputArray _src1, InputArray _src2, InputArray _window, CV_OUT double* response=0)
may work though.

Also, the documentation should be updated along to reflect this API change.

Updated by Robert Huitl over 12 years ago

Hi Vadim, I'm not sure why this breaks at the source code level. The new signature is

static double _no_double;
CV_EXPORTS_W Point2d phaseCorrelate(InputArray src1, InputArray src2, InputArray window = noArray(), double& response = _no_double);

so old source code should still compile against the new version. I didn't use a pointer because I saw the "reference hard-wired to a dummy variable" trick somewhere else in OpenCV and thought that's the preferred C++-ish way to go.

I'll update the documentation and send an updated patch.

Updated by Vadim Pisarevsky over 12 years ago

it's not good style and not quite portable to have non-constant references with default parameters.
In particular, static double no_double; will definitely not work, since it will create as many _different instances of no_double as the number of source files that include the header.

Updated by Robert Huitl over 12 years ago

Thanks for the explanation. I changed the patch to use a pointer defaulting to 0 and updated the documentation. Also fixed the rendering of the other formulas in the phaseCorrelate() documentation, they weren't picked up as math markup.

  • File opencv-phaseCorrelate-response.patch added

Updated by Robert Huitl over 12 years ago

Ah great, I removed the doc changes from the patch.

  • File opencv-phaseCorrelate-response.patch added

Updated by Vadim Pisarevsky over 12 years ago

thanks! your patch was applied in r8724

Updated by Vadim Pisarevsky over 12 years ago

  • Status changed from Open to Done
  • Target version set to 3.0

Updated by Andrey Kamaev over 12 years ago

  • Target version changed from 3.0 to 2.4.3

Also available in: Atom PDF