Clean imgproc code; added erosion and thresholds