added else logic to inner loop that will assign pixel value to be the average of median values +-avg_nmbrs distance away from the median.