A simple implementation of median filter in Python3.
Median filter is usually used to reduce noise in an image. We will be dealing with salt and pepper noise in example below. Median_Filter method takes 2 arguments, Image array and filter size. Lets say you have your Image array in the variable called img_arr, and you want to remove the noise from this image using 3x3 median filter. Thats how you do it.
removed_noise = median_filter(arr, 3)
For 5x5 median filter, you just need to change the second argument to 5, and so on.
#Example