├── LICENSE ├── Movies ├── hero_barcode.png ├── hero_iris.png ├── matrix_barcode.png ├── matrix_iris.png ├── up_barcode.png └── up_iris.png ├── README.md ├── linear_to_circular.ipynb └── video_to_barcode.ipynb /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Lotan Weininger 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Movies/hero_barcode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LoSinCos/movie-iris/fa9914beb45f90b36134c9fa91c19ec203d4e37a/Movies/hero_barcode.png -------------------------------------------------------------------------------- /Movies/hero_iris.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LoSinCos/movie-iris/fa9914beb45f90b36134c9fa91c19ec203d4e37a/Movies/hero_iris.png -------------------------------------------------------------------------------- /Movies/matrix_barcode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LoSinCos/movie-iris/fa9914beb45f90b36134c9fa91c19ec203d4e37a/Movies/matrix_barcode.png -------------------------------------------------------------------------------- /Movies/matrix_iris.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LoSinCos/movie-iris/fa9914beb45f90b36134c9fa91c19ec203d4e37a/Movies/matrix_iris.png -------------------------------------------------------------------------------- /Movies/up_barcode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LoSinCos/movie-iris/fa9914beb45f90b36134c9fa91c19ec203d4e37a/Movies/up_barcode.png -------------------------------------------------------------------------------- /Movies/up_iris.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LoSinCos/movie-iris/fa9914beb45f90b36134c9fa91c19ec203d4e37a/Movies/up_iris.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Movie Iris 2 | 3 | ![Matrix barcode](https://github.com/LoSinCos/movie-iris/blob/master/Movies/matrix_barcode.png) 4 | ![Matrix iris](https://github.com/LoSinCos/movie-iris/blob/master/Movies/matrix_iris.png) 5 | 6 | 7 | `Matrix (1999)` 8 | 9 | 10 | ![Up Barcode](https://github.com/LoSinCos/movie-iris/blob/master/Movies/up_barcode.png) 11 | ![Up Iris](https://github.com/LoSinCos/movie-iris/blob/master/Movies/up_iris.png) 12 | 13 | 14 | `Movie: Up (2009)` 15 | 16 | 17 | ![Hero barcode](https://github.com/LoSinCos/movie-iris/blob/master/Movies/hero_barcode.png) 18 | ![Hero iris](https://github.com/LoSinCos/movie-iris/blob/master/Movies/hero_iris.png) 19 | 20 | 21 | `Movie: Hero (2002)` 22 | 23 | ## Introduction 24 | The `Movie Iris` project was something that I started working on during quarantine. I saw some cool visualizations on **Reddit's** `r/dataisbeautiful` and was inspired to start working on the project. Some other users had already done something like this - and I wanted to try my hand at is as well. This repo is my take on turning movies into still art. Effectively taking raw movie frames, compressing them to their core colors, and visualizing the color schemes of a movie. I wanted to see how movies evolve, as well as how directors intended for different colors to be prevalent across different scenes. I wanted to make something artistic and visual, and I figured this would be a great opportunity to learn how to do some image processing, while making something that I'll actually get to enjoy as well as share with friends and family! 25 | 26 | *P.S. Feel free to message me if you want me to do this to a video of yours!* 27 | 28 | ## Overview 29 | This repo takes in a video (can be `.mp4`, `.avi`, `.mkv`), and visualizes the color themes present in the video as a barcode and as a circle. There are 2 outputs to this script: `barcode.png` and `iris.png`. The outputs and all of the actual frames in this script are `.png` as it is as lossless format. Important to note - this is not `just for movies` - any video can be used (TV show episode, first bike ride, travel video, etc.) 30 | 31 | ## Dependencies 32 | This project was written in Python, and uses 2 main libraries: 33 | 1. `CV2` 34 | 2. `PIL` 35 | 36 | 37 | ## Process 38 | #### `video_to_barcode.ipynb` 39 | 40 | 1. This file takes 4 inputs: 41 | 42 | 1. Height of the final barcode 43 | 2. The name of the video 44 | 3. The vidcap (filepath of the video) 45 | 4. The frame count that we want to capture 46 | 47 | 48 | 2. The script creates a local folder to store all of the files that are going to be created 49 | 50 | 3. We divide the total amount of frames in the video by the desired frame_count, in order to figure out how many frames to skip for each frame we capture. We then capture the frames, skip by the correct amount, and capture again. We then save the newly created frames locally to the new folder we created. This interval allows us to capture the essence of the video. 51 | 52 | 4. We then increase the contrast slightly in each frame, in order to make more vibrant colors. 53 | 54 | 5. We take these new contrasted_frames and resize the images 3 times, finally reaching our desired size, which is `1 pixel wide` x `1000 pixels high` image. 55 | 56 | 6. We then take each frame, and effectively merge them together, creating a `6400 pixel wide` x `1000 pixel high` barcode, where each pixel is 1 distinct frame from the video. 57 | 58 | 7. We then run the `linear_to_circular.ipynb` file. 59 | 60 | #### `linear_to_circular.ipynb` 61 | 62 | 1. This file also takes 4 inputs: 63 | 64 | 1. The name of the video 65 | 2. Current working directory 66 | 3. The final images working directory 67 | 4. The name of the final barcode we created in the previous file. 68 | 69 | 70 | However, we don't need to pass these in, as they are imported from the previous file, and we can just continue with those variables. 71 | 72 | 2. The first thing we do is read in the barcode image that was made in `video_to_barcode.ipynb` 73 | 74 | 3. We then create a white stripe along the bottom of the image. This is so that when we transform the image to polar coordinates, the bottom of the image becomes the center, and we can get a nice white circle in the middle, to create that **iris** visualization. 75 | 76 | 4. The next thing we do is convert the barcode image to polar coordinates. There are multiple input arguments for the `warpPolar` function: 77 | 1. src 78 | 2. dsize 79 | 3. center 80 | 4. maxRadius 81 | 5. flags 82 | 83 | `src:` is effectively the source image we want to convert to polar coordinates - this should stay the same. 84 | `dsize:` is how large we want the output image to be -- these measurements we're a lot of trial and error on my part - you can tweak these as you see fit. 85 | `center:` is where we want the center of the image to be, relative to the dsize. This should not be changed, as it will dynamically update with the dsize_args parameter. 86 | `maxRadius:` is how large we want the circle to be -- this was also a lot of trial and error to get a good fit for the image - this can be tweaked as well. 87 | `flags:` is how the **warpPolar** function knows how to modify the src. This should not be touched. 88 | 89 | 5. Output the image. 90 | --------------------------------------------------------------------------------