As part of my year-long StillStanding project, I post an average image of the spherical video recordings on Mastodon daily.
Average images
The average image is similar to an “open shutter” technique in photography; it overlays all the frames in a video. The result is an image that shows the most prominent parts of the video recording. This is ideal for my StillStanding recordings, because the technique effectively “removes” objects that appear in the recording for a short period of time. That means that people, cars, and animals do not appear. Since I stand still, the average image may look like a photography, but you can see that my face is blurred.
It is easy to make average images with the blend
function in the Musical Gestures Toolbox for Python. Since the GoPro Max splits up the recordings into multiple files, I first need to stich together a complete video file before running the process. You can check out one of my Jupyter Notebooks to see the details.
Adding transparency
My average images are made from fisheye-like videos with black “padding” outside the spherical images. These also appear in the average images. To make the images more flexible to use with various backgrounds, I looked for a solution to remove the black part and add transparency instead.
It is possible to manually remove the black parts in some image editing software (of which open-source GIMP is my current favorite). However, as I recently started exploring ChatGPT for research, I decided to ask for help. And it gave me a fully functional piece of code that I could copy into my Jupyter Notebook:
from PIL import Image, ImageDraw
# Open an image file
image = Image.open('filename.png').convert('RGBA')
# Create an alpha mask with the same size as the original image
alpha_mask = Image.new('L', image.size, 0)
draw = ImageDraw.Draw(alpha_mask)
# Draw shapes on the mask using draw.ellipse, draw.rectangle, etc.
draw.ellipse([2, 2, 700, 700], fill=255)
draw.ellipse([710, 2, 1400, 700], fill=255)
# Apply the alpha mask to the original image
image.putalpha(alpha_mask)
# Save the resulting image
image.save('output.png')
I only had to modify the filename and adjust the two circles to fit my image dimensions. The result is an average image with transparency around the two circles, which is precisely what I wanted.