Skip to content

Is masked matchTemplate implementation correct? #6919

@snosov1

Description

@snosov1
System information (version)
  • OpenCV => 3.1
  • Operating System / Platform / Compiler => any
Detailed description

#6773 has brought a couple of question about masked matchTemplate implementation.

  1. The CV_8U and CV_32F masks seem to be treated differently. CV_8U mask is treated as binary, but in case of a CV_32F mask, the template pixels will be multiplied by the mask values (presumably, in [0..1] range). Is that intended? See https://github.com/opencv/opencv/blob/master/modules/imgproc/src/templmatch.cpp#L860
  2. I'm in doubt regarding the implementation correctness:
    1. For CV_TM_CCORR_NORMED metric, I would expect that the implementation will simply multiply the template by mask. But it does something more involved.
    2. For CV_TM_SQDIFF metric, I would expect it to multiply the squared bracket by mask. It looks like the implementation tries to replace the square of sum into separate units and multiply them by mask individually. But to me, the evaluation doesn't look correct.

@vpisarev, are you familiar with the implementation? Can you comment on this? Also, it looks like @wangyan42164 is the author of the implementation. Is that so? If yes, can you, please, comment as well?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions