Video Pixelator
I’ve been wanting to record a cover of the song “No Suprises” by Radiohead for a while but with some special twist on the video. One of the ideas is to have the video recorded as one shot with a heavily pixelated filter to make it look a bit eerie. Couldn’t quite find anything that did the filter in the needed way, so I coded something to have it done.
Development
The main idea behind the algorithm is to divide the image into blocks, calculate the mean color value within each block, and then apply that color to all the pixels in that region.
For this demo, we’ll use a clip from the movie “Coco”:
First, we split the video into PNG frames upon which we will run our algorithm:
Once the video is split, we start coding our python script. We start by loading our libraries:
Setup our I/O paths along with the grid-size (in pixels):
Then, we setup our iteration cycle, which loads all the PNG images in the desired folder and applies the filter to each one and exports the resulting image:
The main function in this script is the pixelateImage contained in the functions.py file. This function ‘blurs’ the blocks with the mean value of the region and overlays a grid on the resulting image:
Once we’ve applied the filter to the images, we re-assemble the frames into a video:
Documentation and Code
- Repository: Github repo
- Dependencies: ffmpeg, opencv-python