You might want to change the image from RGB to indexed, then you can use the normal histogram and detect photos (Matlab does this with rgb2ind (), as you probably already know), and then the problem will be reduced to your regular “finding peaks” in the array. "
Then n = hist (Y, nbins) links the elements in the vector Y to 10 equally spaced containers and returns the number of elements in each container as a row vector.
These values in n will give you the number of elements in each bin. Then it’s just a question with the number of boxes to make them wide enough, and with how many elements in each case will make you consider the mentioned bin the prevailing color, and then take the bins containing these many elements, calculating the index that matches their middle and again converts it to RGB.
Everything that you use for your processing probably has similar functions to those
source share