How to capture multiple rectangles and get their color?

Hello, I’m new to OpenMV.
What I want to do is get all rectangles in a color chart and then get their color.
Next is to compare my PH test paper to the chart. Find the most likely PH value.

I tried to find edges or template of the rectangles but it only work in GRAYSCALE.
But I cannot get the color.
So I want to ask how to convert RGB image to Gray or how to do match template for a RGB image.
Thanks a lot.

Hi, use find_blobs searching for the color white with invert on. This will find the location of all colors not white. Use the threshold color editor to help you do this. You can call find_blobs on an RGB image.

After you have the rects you can use all the stats functions to determine the color mean/median/mode/etc.

It works!
Thank you very much. :smiley:
BTW, I’m now using l_mean, a_mean, b_mean to determine the color distance between test paper and color chart.
It seems PH 5 and 6 have ambiguous color.
Which color distance is better for this situation RGB ,LAB or HSV?
I mean, is there any good method to improve its accuracy?

Hi, use the median which is not affected by outliers (white paper) from the edges of the color. The mean will be influenced by how much white paper is seen in a bounding box.

As for trying to detect between two similar colors… you’re kind SOL there. You need another method. Is there anything else to detect a color difference? Or, can you make the color spectrum continuous?

It’s not really a path you want to go down trying to detect between orange and a different shade of orange.