Color Palettes from images 
Autor: Americo Gobbo | Publicado: 2014-05-02T17:59:00-03:00



Image made on Alchemy to my palette tests.

Personally I am a fan of the work based on color palettes ... this comes from traditional painting, where is useful to have a limited range of colors and the combinations are made on the palette.

One reason to like palette of colors in the digital world is that this is a way to ensure consistency during the process of one or more jobs for the same client ... and why not the one to build a own particular style where the color also it is important element.

In another article I will try to take a trip into some painting masters through a few centuries ... an epoch where the range was very limited and these days it is vast.

In the digital world there are several software that enables you to extract the palette from an image, whatever they may be. The Gimp and Photoshop have the resources to do this easily ... then I'll talk about some methods for GIMP ... but that can be adapted to any type of editing software and imaging.



Building color palettes from RGB images on Gimp [1]

In Gimp and Photoshop is very easy to do palettes from image... perhaps on Gimp a bit more easy because the feature very specialized to make it. The feature is available directly on the Palette menu, making 'Import Palette'.


Import Palette of an image in Gimp.


In this example I have an indexed image with only 16 colors ... in this case the interval has no reason so it is disabled. This method of indexing the images can be quite interesting to have fixed and wearable palettes in Colormap Gimp. To create indexed palettes we have to use Image &gt; Mode &gt; Indexed. This argument deserves absolutely different and I will address it below.


Importing a Palette from a 16 colors indexed image.

The interval parameter that adjusts the groups of similar colors thus reducing the range of the palette. There is not a priori a fixed rule, but the best way to reduce the color range 'to the bone' would first restrict the number of colors.

The second step is to choose the columns, but this does not influence in the selection but in the appearance of the palette ... if you are thinking a palette with only 4 colors ... then use 4 columns is the most appropriate number ... this number works well for palletes with multiple of 4 (8, 12, 16, 32, ...).

Now the decision interval will be interactive ... as we increase the interval are created groups of more specialized colors at maximum saturation. The screenshot below exemplifies this case where the value of the 'interval' was restored and placed at most 4 and representative colors of the image.


Adjusting the range of a palette from a 8 bit RGB image.



Building indexed palettes [2]

As you can see the palette obtained by adjusting the range of colors in the image above is representative of the colors. But the best method, in my opinion, is indexing the image and after to extract the color palette.

The method uses as a step to further filter Colors &gt; Posterize where is possible determine the ideal amount of posterization, which largely coincides with the number of colors that I have in indexed image ... from there I import my palette with feature available in the Palette Menu &gt; Import Palette.


Original image without posterization yet.



Posterized image with 8 colors.

To build the best palette I realized that is recommend to posterize the image with the number of colors that best summarizes the main and most important colors in the image ... without thereby changing it radically. The following converts the posterized RGB image in the indexed image with 8 colors (below).


8 color indexed image from the image posterized to 8 colors.

As you can see the image is almost identical and we can now import the palette. The figure below shows the import of an indexed palette 8 colors and previously posterized image with the same number of colors. We note that all the major colors were imported correctly.


Import palette from an indexed 8-color previously posterized
with the same amount of colors colors.

Both methods are valid, but surely work with indexed images is the best solution, but since it is submitted before the "posterization" and creating a summary of what we consider the acceptable colors to represent the image.

Indexing the RGB directly, we have several surprises, as I had the opportunity to see ... for example the orange did not appear and was replaced by a very clear tone of this color. The conversion algorithm can depend on 'n' things... so to make two passes (Posterize and after Import Palette) is better ... since the Posterize is somehow in this process is already a good preview.

The method of posterization, without transforming the image into indexed, can be particularly useful to extract colors with the import function of the Palette extending or restricting the range of colors as I detailed in the first part of the method ... i.e. knowing and controlling this process as well we can build representative palletes fairly easy and practical way.


Sorting the colors in a Gimp palette according to different ways.

If a color palette is definitely saved in the list ... this can be edited and can even arrange the colors according to different schemes.

Palettes from pixelated images - Goya Case [3]



Lucientes Goya and a tentative to simplified palette.

In some cases the method of simplification by the "posterization" and successive image indexing ... may not work properly in these cases I advise you to build a palette based on greater palette, as one web based ... is a solution for those cases where certain colors insist not appear.


Lady in red who could not extract with the basic method.

As I tried to transcribe a palette from a painting of Goya (Lucientes) and color the lady in red was not included in the indexed image with the same depth that it had posterized image.


Palette extracted with the web based palette ... and red is recovered.

Surely the palette is much larger than the 12 colors which originally wanted to work.&nbsp;
We can also apply an unsharp mask that helps to saturate the image in a balanced way, but in this case not helped resolve because the red of the lady continued not appearing.

A more interesting method for these cases is to apply a "pixelate" via GEGL and then import the palette using a suitable quantity and range ... in this case I used a range of 24 colors and 62 on interval, this interval is the limit when the palette start to get the full white swatch...


Technique using the GEGL pixelate and then importing the restricted
palette of colors and proper range.


Each case is unique — summarizing methods
Is important to do a previous analysis of the image and to choose the more ideal method ... but we can imagine rapid methods for the most part well-saturated and represented in terms of color ... images that would be the first two methods presented here [1] and [2] for images with ... a narrow range of colors such as this painting of Goya Case [3] ... we can build a palette of web based on top or else produce pixelate and thereafter recover a color palette ... It seems that the method of Pixelate is very good and representative for this type of problem.


Gradients and color palettes



Sample the gradient of palette rescued 4 colors
inspired by the image of this article.

In some works we can use methods of painting where we have to use instruments to which it is useful to support a gradient. In Gimp currently have 3 tools that allow painting painting with gradient: Gradient, Pencil and Paintbrush.

A palette created from the same image we are working or on top of a palette of colors that we are using to paint the work may be transformed on the fly into a gradient ... and this is particularly useful if we use dynamic in which the Color parameter is used. In this case the purpose of "impasto" would be much more significant than using a strange palette to work.

Colormap — Palettes de imagens indexadas

A colormap is just a color map and it works if I open an indexed image ... the tab Colormap has some interesting features ... one of them is to rearrange the index of colors.

Another significant advantage to have indexed images to build pallets is that they themselves are already a palette of colors and can be adequately treated and edited in Gimp.
If for example we're working with Pixel Art or related or even design your own simple icons ... the work is already palette.
This type of palette can also be saved to the traditional standard of the Gimp with the .gpl extension.



Making Palettes on Photoshop and in the Web


Photoshop seems pretty interesting this howto vimeo Harry Harmenik. 


Saving and putting the color palette in Illustrator.

There are several very interesting applications in web ... I will only deal with those that extract colors from images ... because there are great apps that build custom pallets ... but without the ability to extract them from the pictures.


Schema using Degraeve Colr.org.

Following this idea my favorite are the Color Palette Generator and that of the Degraeve Colr.org. 
What seems to be the most complete Colr.org ... where you can customize the palette in many ways. You can export it as .aco ... that are native Photoshop palettes and common to all the other packages from Adobe. In some cases these applications are very interesting and quick to summarize the range of colors in a few steps.

To export .aco to free formats like .gpl used in Gimp, MyPaint and Inkscape on Linux usually uses Gimp.

"ACO (Adobe Color Palette) is the native Format of Photoshop using a specific 16bit code for the colors. This encoding makes it possible to use different color spaces in one palette like CYMK or RGB. Actually Gimp is able to read .aco palettes, but it cannot deal all color models that are encoded in the aco files. The adobe swatch exchange format (.ase) is no alternative for Gimp Users as it could not be loaded in Gimp, but you can convert .ase files with Gpick!" [Excerpt from Vasco Basque: http://vascobasque.wordpress.com/2013/09/20/handling-colors-part-i-palettes/]