I tried finding the OpenCV method for mean shift, but nothing came up. I am looking for a way to find clusters in an image and replace them by their mean value using python OpenCV. Any leads would be appreciated.
For example:
Input:
Output:
I tried finding the OpenCV method for mean shift, but nothing came up. I am looking for a way to find clusters in an image and replace them by their mean value using python OpenCV. Any leads would be appreciated.
For example:
Input:
Output:
hiankun
On
For people who think it's straightforward to find mean shift in cv2, I have some information to share with you.
The meanShift() function given by @fmw42 is not what you want. I believe that many people (included me) have been googled and found it. The meanShift() function of OpenCV is used for object tracking.
What we want might be another function named pyrMeanShiftFiltering().
I haven't try it. Just FYI.
Copyright © 2021 Jogjafile Inc.


Here is a result from sklearn:
Notice that the image is smoothed first to reduce noise. Also, this is not quite the algorithm from image segmentation paper, because the image and the kernels are flattened.
Here is the code: