Ask Your Question
1

Template Matching using Color

asked 2015-04-02 14:46:42 -0600

Barry gravatar image

updated 2020-11-02 17:39:59 -0600

Hello, My application is to find and count boxes on a shelf. As a test I'm using Apple and Fruit Punch Minute Maid juice boxes. The boxes look almost identical except for the color – Apple is green and Fruit Punch is red. When converted to grayscale, the intensities of the red and green are almost the same. Understandably the template matching gets confused, although otherwise I am absolutely amazed by its performance.

I have tried template matching using color images (the docs for 2.4.11 say all three color channels are used) and grayscale images. The performance for color is a little better, but still confuses one for the other.

Is there a standard way to introduce the actual color value into the template matching algorithm? I'm thinking of something like matching the color at half a dozen locations in the template versus the same location in identified match and somehow computing if they are close.

Can anyone offer suggestions?

Thanks, Barry.

edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted
0

answered 2015-04-03 19:35:13 -0600

Barry gravatar image

I think I found a good way to do it. Use three bands (upper, middle, bottom) within the template and test image matched area, compute the histograms for each band, and compare between the template and test images. There is even a really nice tutorial, "Histogram Comparison", http://docs.opencv.org/doc/tutorials/... which gets me 80% there.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2015-04-02 14:46:42 -0600

Seen: 2,932 times

Last updated: Apr 02 '15