Movie Barcode

How does it work?

The aim of this personal project encompassed three primary goals:

a) enabling the extraction of each frame from a movie, typically at one-second intervals;

b) Using k-means clustering to determine the most suitable number of clusters (k) for the k-clustering, which can be achieved through methods like the elbow method or the silhouette score, but preferably with the use of the gap statistic. This helps in identifying the most dominant color within each frame; and

c) merging these dominant colors sequentially onto a canvas.

To achieve a), the tool ffmpeg was employed, while b) and c) involved the creation of Python code using libraries like sklearn and PIL.

Code and resources

The code is currently in a private repository because I intend to make significant changes to it. In the future, I may consider creating a package for generating movie barcodes using k-means clustering and taking various other factors into account. The goal is to produce movie barcodes that closely mimic our perception of colors. Once this package reaches a certain level of quality, it may become worthy of publication or other forms of sharing. Other already existing project either lack some of these features or do only provide rudimental configuration options.

If you wan’t to learn more about k-means clustering and how it can be used to extract the dominant color of an image check out this blog post here.

Visualization of the process

A visualization of the steps, based on a fictional movie scene, can be seen here:

What are movie barcodes good for?

Movie barcodes are a versatile and visually engaging way to represent and interact with films. They can be used for a wide range of purposes, from film analysis and education to artistic expression. Fans of a movie can use movie barcodes to create fan art, analyze their favorite films, and engage in discussions about visual elements within a movie.

Samples from the Project

Harry Potter

Ah, the beloved Harry Potter series! I invite you to explore the movie barcodes created for the seven films in this project.