cost filtering+median filter