Template Matching using Color

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

Barry gravatar image

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


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.

Barry gravatar imageBarry ( 2015-04-03 19:35:13 -0500 )edit