Erode and dilate operations on label images