Are there any functions in openCV which perform the mean-shift algorithm in colour space only? It seems like the meanShift() function is aimed only at motion tracking. I want to ignore spatial information and simply find the dominant (modal) colour(s).
The context is that I'm trying to identify the background in images of pinned butterfly specimens. I don't want to use k-means clustering, as the other colours in the images can be very variable (see examples below). The backgrounds can vary in brightness across the image, but are of (approximately) uniform hue, or are sometimes speckled (which I get rid of by using cv2.bilateralFilter()). However, I can't use a single hue channel, because the background is often white, grey, or dark, and jpeg compression can lead to rather variable hue values even within a similar looking background. Instead, I'm thinking of looking for the dominant region in c1c2c3 colour space.
Once I have at least part of the background, The idea is to mask out the rest using GrabCut(), identify the contours in the mask, and perform logistic regression on the Hu moments to identify which masked area is most butterfly-like.
Thanks
Yan