adding median filter and beginning detect plate