added a function for 3d median filter