Uncategorized

Python opencv (cv2) weird gray background


I have this example image that has a transparent background

enter image description here

When I check it directly from matplotlib in python with these snippets:

import cv2
from matplotlib import pyplot as plt
template = cv2.imread(template_paths[0], cv2.IMREAD_COLOR)
plt.imshow(cv2.cvtColor(template, cv2.COLOR_BGR2RGB))
plt.show()

I get the following results:

enter image description here

I want to use this image as my source for template matching for some images that contains this pattern, but I don’t know, if having this gray background means the template matching will also match it with this gray background? if thats the case, how do I get rid of it? there isn’t any alpha channels (4th dimension) in this example.



Source link

Leave a Reply

Your email address will not be published. Required fields are marked *