fix dilation and erosion