# Check for metamers in an image (using C++)

How do I check how many metamers on my image using OpenCV & C++ ?
For example in this picture, what I'm trying to do is find out that box in no 1 & 5 are metamers, also box no. 3 & 6.
So total I have 2 metamers (blue & yellow), and later I need to swap the color.

What I've been doing so far is using inRange, and take an example of blue color range :
Blue no.1 (152,42,5) - BGR order
Blue no.6 (185,50,4) - BGR order

Mat mask;
cv::Scalar lowerb = cv::Scalar(150,20,0);
cv::Scalar upperb = cv::Scalar(200,50,5);



In this case I can define the target range, but later this colors will always programmatically change, so the target range will also change. And this also only for one color. How do I detect several colors that perceived the same when the target range isn't fixed ?

edit retag close merge delete

1

"How do I detect several colors that perceived the same when the target range isn't fixed ?" -- imho, you'll have to explain, what you're trying to achieve here

( 2018-02-16 07:53:57 -0500 )edit

I think it's pretty clear from the example above. So for example from the image, I want to detect if there are 2 colors that perceived the same --> blue & yellow. The thing is I cannot specify any specific range because the value will always change.

( 2018-02-16 08:01:15 -0500 )edit

but your images always have those "boxes" ? so, what you want is some "similarity test" , or "clustering" ?

what is the "use-case" for it ?

( 2018-02-16 08:07:32 -0500 )edit

The boxes isn't really necessary in the future, because in the future I'm going to work with natural mages. In this case it's just an example to make it easier. This is what I'm trying to ask. If my approach with inRange in this case was good or not. I've never been working with clustering or similarity test before. Do you think I need to start from that ?
i dont really get your references.

( 2018-02-16 08:35:01 -0500 )edit