Add mask to match template demo#6773
Conversation
|
I can rebase if you prefer, but i think it makes sense to have two commits |
| template image (patch). | ||
|
|
||
| While the patch must be a rectangle it may be that not all of the | ||
| rectangle is relevent. In such a case, a mask can be used to isolate the portion of the patch |
There was a problem hiding this comment.
ugh. installing spell checker. thanks.
|
@apavlenko thanks for the feedback. I think i've covered all your issues in b53b8d9 |
1. Explain grayscale input still read as three channel 2. Fix typo 3. Add more details to image match explanation to include the use of masks
b53b8d9 to
0ed250c
Compare
|
Although, it's not necessarily the issue of this PR, but a wording in the documentation made me wonder about the implementation. The statement that took my attention was:
So, @acinader are you familiar with the implementation and can you confirm whether it works correctly? Also, it looks like @wangyan42164 is the author of the implementation. Is that so? If yes, can you, please, comment as well? |
|
@snosov1 I am not familiar with the implementation. I am coming at it as a user and trying to figure out how templates and masks work by trial and error (which is why I am adding the mask to the sample so I can play and see the results.) FWIW, it would be helpful to have some docs and unit tests with some sample images that could be a guide for how to prepare a template and mask. Unfortunately, I don't have enough understanding of what is going on to drive that process, but I'd be glad to help. |
|
Ok, then. I think we can merge this particular PR after a couple of small changes in wording. However, we'll probably need to submit a separate ticket about the issues I highlighted (different behavior for So, I suggest that you replace the following paragraph with the proposed text, and if you agree with it - please, update the PR and we'll merge it.
The mask should have a |
|
@snosov1 updated to reflect your suggestion. FYI, your explanation is very helpful to me, so a good change! thanks. |
|
@apavlenko, I'm ok with this PR. I'll create a separate issue with my concerns about the implementation. |
|
👍 |
|
@acinader could you send me the images you used for the mask part? |
|
Thanks! @sturkmen72 |
|
@Cartucho Did you get this to work? When I run these images through the matchTemplate function I get incorrect results (see red dot in image where the result deemed match): My test code: OpenCV => 3.3 @apavlenko And by the way, remove the mask from the function call and the results do not change at all. As I mentioned in #6919, I don't think this code is implemented correctly. |
|
Thanks for referring to that document. However, this does not change my opinion that the implementation in OpenCV for match templates with a mask is incorrect. (I'm not asking a question about my implementation in my comment; that was there for completeness) |
|
@Cartucho |
|
@ai-snow Shouldn't you use |



Accept and use optional mask argument for MatchTemplate_Demo.
Useful for visualizing effect of a mask on template matching.
this replaces #6758 which was giving me some problems with github.... you can close this if you want to re-open #6758 instead?