Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Trying to match color template with cv::ximgproc::colorMatchTemplate()

I'm trying to use colorMatchTemplate from L. Berger, in order to find a template that is a color stripe from a resistor (electronic component) inside a picture of the whole resistor.

When I tried the colorMatchTemplate method on a simple example (finding a red circle template inside a bigger image with dark background) it worked well (the max quarternion image displayed white pixel where the circle template has been located), but for some reason it does not work well with my resistor stripe template (no white pixel at the right location on the max quarternion image).

I have these results with the official example of colorMatchTemplate included in opencv 4.2.0

Also, the template should be found, because I extracted it from the original resistor image. So that's an exact match.

Any idea on how to make this algorithm work please ?

I read somewhere that I need to have pictures with even number of cols, so I did that, but the results are incorrect (template not located correctly).

Trying to match color template with cv::ximgproc::colorMatchTemplate()

I'm trying to use colorMatchTemplate from L. Berger, in order to find a template that is a color stripe from a resistor (electronic component) inside a picture of the whole resistor.

The resistor: image description

The template: image description

When I tried the colorMatchTemplate method on a simple example (finding a red circle template inside a bigger image with dark background) it worked well (the max quarternion image displayed white pixel where the circle template has been located), but for some reason it does not work well with my resistor stripe template (no white pixel at the right location on the max quarternion image).

I have these results with the official example of colorMatchTemplate included in opencv 4.2.0

Also, the template should be found, because I extracted it from the original resistor image. So that's an exact match.

Any idea on how to make this algorithm work please ?

I read somewhere that I need to have pictures with even number of cols, so I did that, but the results are incorrect (template not located correctly).