368 Unsupervised Classification
Show that the mean shift is always in the direction of the gradient. (This
demonstrates that the mean shift algorithm will find the modes of the
distribution without actually estimating its density, and can be shown
to be a general result (Comaniciu and Meer, 2002).)
(c) The OpenCV Python package exports the function PyrMeanShiftFilter-
ing(), which performs mean shift filtering (but not segmentation) of
RGB c olor images. In the code snippe t:
1 impo rt cv2 . cv as cv
2 src = cv . fromar ray ( src )
3 dst = cv . Create Mat ( rows , cols , cv . CV_ 8UC3 )
4 cv . PyrMeanShiftF ilte ring ( src , dst , sp , sr )
the variables are:
src: the source 8-bit, 3- channel image in a numpy array
dst: the destination image, same format