first version of dilate and erode