Ask Your Question

color percentage in image

asked 2018-10-27 12:01:53 -0500

makot gravatar image

updated 2018-10-27 12:06:50 -0500

berak gravatar image

I am beginner in OpenCv and I need your help how I can find a percentage of brown and yellow color in the picture when I ignore the white background

edit retag flag offensive close merge delete


read this tutorials

LBerger gravatar imageLBerger ( 2018-10-27 12:05:10 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2018-10-29 19:44:33 -0500

nrsyed gravatar image

Consider using k-means clustering to split the pixels of the image into distinct clusters based on color. In this case, you'd probably want to use k=3, i.e., 3 clusters (one for the white background, one for the brown, and one for the yellow). Then it would simply be a matter of counting the number of pixels belonging to each cluster label.

OpenCV seems to have a k-means method, though I'm not familiar with it. You may want to check out the scikit-learn k-means method instead.

edit flag offensive delete link more

Question Tools



Asked: 2018-10-27 12:01:53 -0500

Seen: 345 times

Last updated: Oct 27 '18