updated  dilation and erosion