median filter added
median filter optimized