Basically, it gets an image as input, then outputs the same image with his pixels sorted by color. There are gonna be more informations about the algorithms used at the end of this page.
Original image:
Output with hue sorting:
Output with hsp:
Output with relative luminance:
Output with rgb sorting (red):
Output with HSL sorting:
I wanted to learn Python development and I just kinda leaned towards this little idea that I had in mind for a long time.
Assuming you don't have Python already installed (especially if you're on windows), go grab it at Python official site.
Note that this project requires Python 3.
Go ahead with the installation, then open a prompt window and type
$ pip install Pillow
This will install Pillow (Python Imaging Library), which is the library I'm currently using to work on images.
Looks like you're set!
Now go to the folder where you downloaded my software using your prompt window/terminal and type:
$ python pixelsorter.py
If you have Python 2 and Python 3 installed at the same time you should probably type:
$ python3 pixelsorter.py
Have fun!
Yes, I already know that. It's gonna be full of errors and poor-optimized code, but this is my first Python project, so take it easy.
Based on the HSV color representation where the color are expressed by cylindrical-coordinates. The three values of HSV are hue, saturation and value. This algorithm sorts the colors by ordering the pixels based on their hue values. Read the linked Wikipedia article to get to know more.
Based on the HSP color model, which is an alternative to HSV. The red, green and blue values from the RGB model are multiplied by three costants which represent the different degrees to which each of the primary (RGB) colors affects human perception of the overall brightness of a color. The linked article is a very interesting read on the subject.
The relative luminance is a value to get the luminance of a color. Again, we get the RGB values and multiply them by three costants. Note that the three constants are, like in the HSP model, based on the luminosity function: the green value is more important because contributes the most to how the intensity is perceived by the human eye (then red and blue).
This is a very simple algorithm (which is not really effective, but I originally wrote it for testing purposes then decided to leave it there as a simple demonstration) sorting the colors based on the first value of the RGB model (red intensity).
This algorithm is based on this Stack Overflow question. I hadn't tried an HSL algorithm before, so I figured I'd give it a shot. The pixels are sorted based on different weights assigned to the values of the HSL model.
Having zero experience in Python and color theory these are the resources I mainly used to gather informations, in addition to the sources I've already linked previously, if you're interested in knowing more.