Image Processing in Python
Rebeca Gonzalez
Data Engineer
from skimage import morphology
square = morphology.square(4)
[[1 1 1 1]
[1 1 1 1]
[1 1 1 1]
[1 1 1 1]]
rectangle = morphology.rectangle(4, 2)
[[1 1]
[1 1]
[1 1]
[1 1]]
from skimage import morphology
# Set structuring element to the rectangular-shaped selem = rectangle(12,6)
# Obtain the erosed image with binary erosion eroded_image = morphology.binary_erosion(image_horse, selem=selem)
# Show result
plot_comparison(image_horse, eroded_image, 'Erosion')
# Binary erosion with default selem
eroded_image = morphology.binary_erosion(image_horse)
from skimage import morphology # Obtain dilated image, using binary dilation dilated_image = morphology.binary_dilation(image_horse)
# See results plot_comparison(image_horse, dilated_image, 'Erosion')
Image Processing in Python