Have somebody working code for matchTemplate with mask?

asked 2017-09-14 08:41:57 -0600

baravunuw gravatar image

updated 2017-09-14 09:29:43 -0600

berak gravatar image

Here is a link: https://stackoverflow.com/questions/1... I have a problem with multiplating matrix. If element is 255 multiplated by 255 it will be still 255, becouse it is higher value of matrix element.

OpenCV have no template matching with mask, but it can be done follows steps: result = matchTemplate(I^2, W, method=2) - matchTemplate(I, 2*W*T, method=2) + as.scalar(sum(W*T^2))

Here I need to multiply matrix per-elements, but I can not do it with simple mul() becouse it cv::Mat can not store values more then maximal values (255 for example). When I multiply 255 by 255 it still stay 255. This is a problem.

edit retag flag offensive close merge delete

Comments

this link is worthy to try object-localization-using-color

sturkmen gravatar imagesturkmen ( 2017-09-14 09:00:43 -0600 )edit

"OpenCV have no template matching with mask,"

simply not true

berak gravatar imageberak ( 2017-09-14 09:31:29 -0600 )edit

Great. How does mask work? the black {0,0,0} is ignored and non - black is compared?

baravunuw gravatar imagebaravunuw ( 2017-09-14 09:45:31 -0600 )edit

exactly...

berak gravatar imageberak ( 2017-09-14 09:55:32 -0600 )edit

btw, the downvote is for: you asked on 2 different sites, and obviously NEVER cared to look at the docs.

berak gravatar imageberak ( 2017-09-14 13:18:20 -0600 )edit