Get Started

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.

This is a part of the course

“Image Processing in Python”

View Course

Exercise instructions

  • 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.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# 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')
Edit and Run Code