Ask Your Question

Eugene's profile - activity

2013-07-08 11:58:26 -0500 received badge  Famous Question (source)
2013-05-19 03:55:45 -0500 received badge  Notable Question (source)
2013-04-16 21:17:10 -0500 received badge  Popular Question (source)
2013-03-25 14:00:33 -0500 received badge  Scholar (source)
2013-03-25 14:00:31 -0500 received badge  Supporter (source)
2013-03-25 07:53:08 -0500 asked a question findTemplate: why conversion to grayscale is needed

As far as I can see from the code of Image.findTemplate() (ImageClass.py), both the image and the template image are converted to gray scale before matching:

cv.MatchTemplate( self._getGrayscaleBitmap(), template_image._getGrayscaleBitmap(), matches, method )

I wonder, why it is this way. If I understand the description of matchTemplate() in OpenCV docs correctly, matchTemplate() itself can operate on colour images.

If the conversion to grayscale is done on purpose, what is the recommended way to locate an image on a screenshot where several more images with similar shapes but different colours can be present?

By the way, if I disable the conversion, that is, change that line of code of findTemplate() to

cv.MatchTemplate( self.getBitmap(), template_image.getBitmap(), matches, method )

findTemplate() seems to work OK in my experiments although 'quality' value for the found matches is lower than if the conversion is enabled.