Ask Your Question
0

How to make image of template matching result

asked 2016-08-09 09:39:03 -0600

M Fahad Minhas gravatar image

updated 2020-11-02 17:23:08 -0600

Hi,

I wanted to know that how can we extract the image out of the result we get by matchTemplate method of opencv.

I don't know how to use its location to make an image (colored), we can though put a rectangle on it if matched as shown in the following example, but how can we make a separate image of this rectangle?

TemplateMatchingExample

edit retag flag offensive close merge delete

Comments

hmm, the "result" image from template matching contains the probability density for the matching at each pixel. do you just need a better visualization for this ? it's a bit unclear, what you wanted.

berak gravatar imageberak ( 2016-08-09 10:10:07 -0600 )edit

We can put rectangle in the image where the template is detected, right? as shown in the link I gave.

I just want to crop that area and make another image of it, how can we do that using the "result" Matrix. We can draw rectangle on it, then surely we would be able to extract it as well, don't we?

M Fahad Minhas gravatar imageM Fahad Minhas ( 2016-08-09 10:24:34 -0600 )edit

sorry for being extra dumb, but i still don't get it.

in the result image, only a single point (the max or min) is relevant. drawing a rectangle there (or extracting the roi) has no significance.

did you mean: cropping the roi from the query image, where the template was found ?

berak gravatar imageberak ( 2016-08-09 10:57:49 -0600 )edit

You're berek from my previous question too right?

Significance for me in it is i would get colored part in the Main Image as i had shown previously.

I want to match and extract that colored part.

See here

I want to match and when detected, i want to extract that colored part from Main Image.

M Fahad Minhas gravatar imageM Fahad Minhas ( 2016-08-09 11:02:14 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2016-08-16 13:46:23 -0600

M Fahad Minhas gravatar image

We can crop and get the image of template matching result by using the function subMat(), and providing it the Rect, which is our ROI. We can get the cords. of Rect from the result Mat of template matching method.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2016-08-09 09:39:03 -0600

Seen: 1,012 times

Last updated: Aug 16 '16