Your ad could be here - Reach CV/ML engineers
Contact for advertisingContactInterested in advertising?
Contact usStay updated
News & Insightsexampleexample bboxesexample bboxes2example chromatic aberrationexample d4example documentsexample domain adaptationexample gridshuffleexample hfhubexample kaggle saltexample keypointsexample mosaicexample multi targetexample OverlayElementsexample textimageexample weather transformsexample xymaskingmigrating from torchvision to albumentationspytorch classificationpytorch semantic segmentationreplayserializationshowcase
Morphological Transform 🔗
import albumentations as A
import cv2
from matplotlib import pyplot as plt
def visualize(image):
plt.figure(figsize=(10, 5))
plt.axis("off")
plt.imshow(image)
Load the image from the disk
img_path = "../images/scan.jpeg"
img = cv2.imread(img_path, cv2.IMREAD_COLOR_RGB)
Visualize the original image 🔗
visualize(img)

Dilation 🔗
Dilation expands the white (foreground) regions in a binary or grayscale image.
transform = A.Compose([A.Morphological(p=1, scale=(2, 3), operation="dilation")], p=1, seed=137, strict=True)
transformed = transform(image=img)
visualize(transformed["image"])

Erosion 🔗
Erosion shrinks the white (foreground) regions in a binary or grayscale image.
transform = A.Compose([A.Morphological(p=1, scale=(2, 3), operation="erosion")], p=1, seed=137, strict=True)
transformed = transform(image=img)
visualize(transformed["image"])
