LoslegenKostenlos loslegen

Removing logos

As we saw in the video, another use of image restoration is removing objects from an scene. In this exercise, we'll remove the Datacamp logo from an image.

Landscape with small datacamp logo
Image loaded as image_with_logo.

You will create and set the mask to be able to erase the logo by inpainting this area.

Remember that when you want to remove an object from an image you can either manually delineate that object or run some image analysis algorithm to find it.

Diese Übung ist Teil des Kurses

Image Processing in Python

Kurs anzeigen

Anleitung zur Übung

  • Initialize a mask with the same shape as the image, using np.zeros().
  • In the mask, set the region that will be inpainted to 1 .
  • Apply inpainting to image_with_logo using the mask.

Interaktive Übung

Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.

# Initialize the mask
mask = ____(____[:-1])

# Set the pixels where the logo is to 1
mask[210:290, 360:425] = ____

# Apply inpainting to remove the logo
image_logo_removed = inpaint.____(____,
                                  ____,
                                  multichannel=True)

# Show the original and logo removed images
show_image(image_with_logo, 'Image with logo')
show_image(image_logo_removed, 'Image with logo removed')
Code bearbeiten und ausführen