LoslegenKostenlos loslegen

RGB to grayscale

In this exercise you will load an image from scikit-image module data and make it grayscale, then compare both of them in the output.

We have preloaded a function show_image(image, title='Image') that displays the image using Matplotlib. You can check more about its parameters using ?show_image() or help(show_image) in the console.

Rocket

Diese Übung ist Teil des Kurses

Image Processing in Python

Kurs anzeigen

Anleitung zur Übung

  • Import the data and color modules from Scikit image. The first module provides example images, and the second, color transformation functions.
  • Load the rocket image.
  • Convert the RGB-3 rocket image to grayscale.

Interaktive Übung

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

# Import the modules from skimage
from skimage import ____, ____

# Load the rocket image
rocket = data.____()

# Convert the image to grayscale
gray_scaled_rocket = color.____(____)

# Show the original image
show_image(rocket, 'Original RGB image')

# Show the grayscale image
show_image(gray_scaled_rocket, 'Grayscale image')
Code bearbeiten und ausführen