Aan de slagGa gratis aan de slag

Privacy protection

Let's look at a real-world application of what you have learned in the course.

In this exercise, you will detect human faces in the image and for the sake of privacy, you will anonymize data by blurring people's faces in the image automatically.

Group band walking
Image preloaded as group_image.

You can use the gaussian filter for the blurriness.

The face detector is ready to use as detector and all packages needed have been imported.

Deze oefening maakt deel uit van de cursus

Image Processing in Python

Cursus bekijken

Oefeninstructies

  • Detect the faces in the image using the detector, set the minimum size of the searching window to 10 by 10 pixels.
  • Go through each detected face with a for loop.
  • Apply a gaussian filter to detect and blur faces, using a sigma of 8.

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# Detect the faces
detected = ____.____(img=____, 
                                       scale_factor=1.2, step_ratio=1, 
                                       min_size=____, max_size=(100, 100))
# For each detected face
for d in ____:  
    # Obtain the face rectangle from detected coordinates
    face = getFaceRectangle(d)
    
    # Apply gaussian filter to extracted face
    blurred_face = ____(face, multichannel=____, sigma = ____)
    
    # Merge this blurry face to our final image and show it
    resulting_image = mergeBlurryFace(group_image, blurred_face) 
show_image(resulting_image, "Blurred faces")
Code bewerken en uitvoeren