Stay updated
News & Insightsexampleexample bboxesexample bboxes2example chromatic aberrationexample d4example documentsexample domain adaptationexample gridshuffleexample hfhubexample kaggle saltexample keypointsexample mosaicexample multi targetexample OverlayElementsexample textimageexample ultralyticsexample weather transformsexample xymaskingface landmarks tutorialkeras cats dogs classificationkeras pretrained segmentationmigrating from torchvision to albumentationspytorch classificationpytorch semantic segmentationreplayserializationshowcase
Open in Google ColabRun this notebook interactively
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)
No code provided
No code provided
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"])
No code provided
No code provided
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"])
No code provided
No code provided