Ask Your Question

Determine a piece of image is in large image, if there - how much Percentage

asked 2016-03-06 01:13:24 -0500

Shahrukh Q gravatar image

I am trying to find a piece of image in large image. I used template matching it always give coordinate if image is there or not there. I want to find the percentage occurrence of piece of image in large image. In fast way.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2016-03-06 01:37:30 -0500

Tetragramm gravatar image

Template Matching may always give a coordinate, but that coordinate will tell you whether it was a good match or not. In the output map, check the max value against a threshold. If it's too low, it's a bad match and you can say that it wasn't there.

edit flag offensive delete link more


Thanks for your replay @Tetragramm. Can you please give me an example.

Shahrukh Q gravatar imageShahrukh Q ( 2016-03-06 04:03:16 -0500 )edit

Well, when you do the minMaxLoc to find the coordinate, also get the maxVal. That is a double value containing the "strength" of the match. What constitutes a good match depends on your use and how much noise and so forth there is between your template and the image.

It also depends on which template matching method you use. Some are bound between 0 and 1, others aren't. Some have 0 as a perfect match, others have 1. You'll have to check for the method you are using and see.

Tetragramm gravatar imageTetragramm ( 2016-03-06 10:03:14 -0500 )edit
Shahrukh Q gravatar imageShahrukh Q ( 2016-03-09 02:49:21 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2016-03-06 01:13:24 -0500

Seen: 107 times

Last updated: Mar 06 '16