I want to implement a ring median filter - what it does is basically replace the center pixel by the median values of the pixels in a circular ring around it. I can make a circular mask of some radius like this
kernel = np.zeros((2*radius+1, 2*radius+1))
y,x = np.ogrid[-radius:radius+1, -radius:radius+1]
mask = x**2 + y**2 <= radius**2
kernel[mask] = 1
Then I can use scipy's generic filter to take median of the values
import scipy.ndimage.filters as scp_filt
circular_median = scp_filt.generic_filter(my_image, np.median, footprint=kernel)
The above mask is including pixels inside the circle. What pixels should lie on the circumference seems slightly ambiguous to me (think of circle inscribed in 3*3, 5*5, 7*7 kernels). Is there a "ring" function I can use OTS or something?
Why all this - trying to use a part of this paper http://pages.swcp.com/~spsvs/resume/PODS_DSS2009_2009-01-15.pdf Ring median filter, after subtraction from the original image leaves objects with a scale size of less than the radius.
Also, not sure if I should do this in RGB or not. I have only seen median filters on grayscale images