Blur Faces in an Image
Automatically blur faces in an image.
how it works
Here’s an image with faces:
FindFaces returns a list of the bottom left and upper right corners of rectangles in the image that contain faces:
To blur the faces, create a mask image that corresponds to the faces by drawing disks inside each face rectangle:
The amount of blur necessary to obscure the details of a face depends on the size of the face rectangle. Calculate the number of pixels of blur in proportion to the largest dimension of a face rectangle:
This expression blurs the entire image, then picks out just the face regions using the mask computed above. The background is set to fully transparent and the face regions to fully opaque. The mask is blurred to give a gradual transition between the background and face regions.
Finally, overlaying the blurred face image on top of the original image with ImageCompose gives the face-blurred result.
Gathering up those steps and packaging them as a function yields BlurFaces:
Test BlurFaces on a larger face to check that the proportional blur is working correctly: