medianfilter slow as fuck