Added median filter with local memory