My understanding of a RGB color vector is that it has 3 components like [100, 100, 100]. However, from the documentation, the argument sr – The color window radius
in the Python function cv2.pyrMeanShiftFiltering(src, sp, sr[, dst[, maxLevel[, termcrit]]])
accepts an int.
What exactly does color radius mean? I'd also like to understand the min and max values, and what the units are in.
Based on what I read in the description of the algorithm from the documentation,
sr
is a parameter for a part of the algorithm which needs neighbor identification.You might want to brush over your understanding of the mean shift algorithm, but at some point for a given pixel (X,Y), you need to find its neighbors. While often, we think as neighbors as spatial neighbors, i.e. pixels close spatially to the one we're considering ( ||(X,Y)-(x,y)||< some radius, with X,Y the considered pixel position and x,y the potential neighbor position), here the algorithm also considers the "color" closeness, as seen in the line :
This means to be considered a neighbor, a pixel needs to be spatially close and have also a close color to the considered pixel. You set this closeness condition with
sr
, just like you set required spatial closeness withsp
. Try some values out. It depends on what definition the algorithm uses for the || norm, probably something like ||(R,G,B)-(r,g,b)|| = sqrt((R-r)**2+(G-g)**2+(B-b)**2)