gasilhat.blogg.se

Get color palette from image python
Get color palette from image python




get color palette from image python

get color palette from image python

#DESCRIPTION: This is just an experiment to try to create a color palette from an image. #GenerateColorPaletteFromImage #AUTHOR: Juan Francisco Cevallos C. The first one is an awesome illustration by Wei Wang, the second one is a concept art by Juan Diego Leon, and the last image is from Edvige Faini. The images used to illustrate how the tool is working were taken from Google. It is not a perfect approach as pixelation (Blocky) blends the colors, however I’m happy with the results as it can be a fast approach to get a color palette.

#Get color palette from image python code#

There’s a variable called blockySize in the code that controls the number of colors (it’s not the number of colors, but the size of the blocky, a smaller size will create more colors and a larger number will create less colors), now is set to the 15% of the image width, you can change this value to have more or less colors but WARNING, it can be heavy to process. The GitHub code is here as I couldn’t embed it anymore in Squarespace XD. The result was interesting, I didn’t group the operations so the whole process is visible, however it is not updated automatically as the python code stores the colors when run. The Blocky node creates a pixelated effect, I store those pixel values in an array and then create a new image (ramp) with the colors sorted by luminance (I used this equation to calculate the luminance: lumaValue = redSample*0.2126 + greenSample*0.7152 + blueSample*0.0722). I used two Blocky Nodes combined to mix base and complementary/saturated color. This was an experiment trying to create a color palette from an image, it was made just for fun and as an exercise trying to solve that problem using Python. This is an old version for a python learning experiment.






Get color palette from image python