How to detect different random colors from the picture?
Hello,
I am doing phase detection program. I would like to know if there is any possibility to say that this picture frame has 3 various color or this picture frame has one color. colors should be changed picture by picture. So I am looking for some logic to say how many different color are there in the picture.
Please guide me. Thank you very much in advance.
Have you try histograms?
Maybe you could build a histogram and count number of non-zero elements (using cv::countNonZero(mat) )?
You can try color Image quantization in google or try this or this
have a look in this thread. However, have in mind that
partition()
is a bit slow in big images. In case that you need something faster I have a kind of optimization. However, I haven't implemented the lookup table for recognizing the color intensity, but getting the number of different colors in your image it works pretty well.Thank you very much for reply. I have different 4 colors to detect not more than that. and Image is also not so big. its like random color made draw in paint some time its two color some time 3 that is it. I have idea about histogram but I dont know how to implement it. I will also take a look in other suggestions. Thank you very much once again and it will be great help is someone can provide sample program.