# Revision history [back]

### 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.