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

asked 2018-02-16 07:26:08 -0600

raisa_ gravatar image

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.

image description

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); 

cv::inRange(frame, lowerb, upperb, mask);

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 flag offensive close merge delete

Comments

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

berak gravatar imageberak ( 2018-02-16 07:53:57 -0600 )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.

raisa_ gravatar imageraisa_ ( 2018-02-16 08:01:15 -0600 )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 ?

https://en.wikipedia.org/wiki/Metamer...https://en.wikipedia.org/wiki/Color_d...

berak gravatar imageberak ( 2018-02-16 08:07:32 -0600 )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.

raisa_ gravatar imageraisa_ ( 2018-02-16 08:35:01 -0600 )edit