Fixed median filter so that it works in the y direction as well