Gimp-Forum.net
consistent color palette from multiple images - Printable Version

+- Gimp-Forum.net (https://www.gimp-forum.net)
+-- Forum: GIMP (https://www.gimp-forum.net/Forum-GIMP)
+--- Forum: General questions (https://www.gimp-forum.net/Forum-General-questions)
+--- Thread: consistent color palette from multiple images (/Thread-consistent-color-palette-from-multiple-images)

Pages: 1 2


consistent color palette from multiple images - barrubba - 04-11-2021

I have 100 images with very similar palette (90%). Some images have some colore more, other less
I would like to index all images so that they share the same color palette.
The final palette will have 32 colors. I have tested it on a group of images and it seems to respect the color variations. 
Any advice?


RE: consistent color palette from multiple images - rich2005 - 04-11-2021

Are these indexed images ? and what image format ?


RE: consistent color palette from multiple images - barrubba - 04-11-2021

the input images are jpg's and are not indexed. They are illustrations with sharp colors and all the images as mentioned have generally the same colors except for a few. For example some do not have the red that is present in others or similar cases.
I need to index them all so I can unify the palette and then do color by number.


RE: consistent color palette from multiple images - rich2005 - 04-11-2021

Quote:the input images are jpg's and are not indexed. They are illustrations with sharp colors and all the images as mentioned have generally the same colors except for a few. For example some do not have the red that is present in others or similar cases.

As jpegs they are liable to have lots of colours, might look sharp but what does Colors -> Info -> Color Cube Analysis report.

Quote:I would like to index all images so that they share the same color palette. The final palette will have 32 colors

It is the indexed image colormap that you will be editing.
Gimp is not too good with indexed colormaps. To get a common colormap, open a base image in Indexed mode, with the desired colormap. Then open the jpegs as layers. That will (1) force the (jpeg) layers to indexed mode (2) apply the common colormap.

It is getting them out of that stack of images that is a problem. The scripts I have, give indexed images with individual (different) colourmaps, which is normal Gimp behaviour. I have to do one-layer at a time.

Ofnuts has a plug-in ofn-replace-colormap.py from http://sourceforge.net/projects/gimp-tools/files/scripts/ Which as the name implies replaces the colormap in an indexed image.
I can not get this to work for me. Do not know why, gives a "palette has different number of entries error", but worth a try.

I am sure you will get better advice than mine. Keep visiting.


RE: consistent color palette from multiple images - barrubba - 04-11-2021

(04-11-2021, 10:56 AM)rich2005 Wrote:
Quote:the input images are jpg's and are not indexed. They are illustrations with sharp colors and all the images as mentioned have generally the same colors except for a few. For example some do not have the red that is present in others or similar cases.

As jpegs they are liable to have lots of colours, might look sharp but what does  Colors -> Info -> Color Cube Analysis report.

Quote:I would like to index all images so that they share the same color palette.  The final palette will have 32 colors

It is the indexed image colormap that you will be editing.
Gimp is not too good with indexed colormaps. To get a common colormap, open a base image in Indexed mode, with the desired colormap. Then open the jpegs as layers. That will (1) force the (jpeg)  layers to indexed mode (2) apply the common colormap.

It is getting them out of that stack of images that is a problem. The scripts I have, give indexed images with individual (different) colourmaps, which is normal Gimp behaviour. I have to do one-layer at a time.

Ofnuts has a plug-in ofn-replace-colormap.py from http://sourceforge.net/projects/gimp-tools/files/scripts/ Which as the name implies replaces the colormap in an indexed image.
I can not get this to work for me. Do not know why, gives a "palette has different number of entries error", but worth a try.

I am sure you will get better advice than mine. Keep visiting.

- Color Cube attached
- forcing index palette applpying on layers, i see, it's ok, obviously it force some images with "new" colora to apply a similar one. It's just this to solve.
- Can be a solution opening all imagesall images side by side in mosaic to index all togethers?
- Why "getting them out of that stack" it's a problem? ofn-export-layers export each level to a separate file.


 


RE: consistent color palette from multiple images - rich2005 - 04-11-2021

Quote:Why "getting them out of that stack" it's a problem? ofn-export-layers export each level to a separate file.

From a stack of indexed with a common colormap

Separate images but each indexed has each has its own colormap, not the common one.

Up to now, the only way I can find, is drag a layer into the tool box to create a image, then export that (as a gif)

OK, that is only true of gif images. Stick with exporting png's and as far as I can tell they have a common colormap.

The sequence might be
Open an indexed base file with the required colormap.
Add the jpegs as layers Image -> Open as Layers
Use Ofnuts ofn-export-layers to separate png files. They keep the indexed mode.
Check: Open the exported files with the colormap dock open. The displayed colormap should be constant

I have only tried with a small number of files, not 100, seems to work ok.


RE: consistent color palette from multiple images - barrubba - 04-11-2021

Great! thank you
now just the last thing.
At the top of layer image list, i have a separate layer with a logo that must be exported with EACH levels..
How to do that?


RE: consistent color palette from multiple images - Ofnuts - 04-12-2021

A different solution:

1) For each image:
  • Convert to color-index if not done (no need to save at that point)
  • Copy the color map as a palette (in the Palettes list, the color map of the current image is the first one, so you just duplicate and rename it).
2) Gather the palettes (if necessary, the palettes list right-click menu has a "Show in file manager" entry)

3) Create a composite palette: add all color lines from all palettes and remove the duplicates (a good text editor must have something to sort lines, so locating duplicates shouldn't be hard).

4) Save that palette to the Gimp palette directory

5) For each image:
  • Convert to full RGB
  • Convert to color-indexed, providing the palette created previously
  • Save/Export



RE: consistent color palette from multiple images - rich2005 - 04-12-2021

Quote:At the top of layer image list, i have a separate layer with a logo that must be exported with EACH levels..
How to do that?

You need to add your logo to the images in RGB mode, before you Index them. Use this script http://chiselapp.com/user/saulgoode/repository/script-fu/wiki?name=sg-combine-bg  it does not require all layers the same size.

Remember, that logo adds to each image colours, better if you can keep to a single color, even better if black or white. 
However, back to the original specification, consistent colormap with 32 colours. Might go like this:

Open the images as layers including the logo.
Add the logo to all layers using sg-combine-bg.scm
Export all layers as RGB jpeg, now with the logo.
Use one of those and put in Indexed Mode creating a 32 colour colormap
Add the jpgs (with logo) as layers, to that indexed image.
Export the layers to individual indexed png images.

All that in this 5 minute video. https://youtu.be/VpUK5AmkZvM





A bit at the end about editing those indexed png's preserving  the 32 color colormap.


RE: consistent color palette from multiple images - barrubba - 04-17-2021

(04-12-2021, 08:35 AM)Ofnuts Wrote: A different solution:

1) For each image:
  • Convert to color-index if not done (no need to save at that point)
  • Copy the color map as a palette (in the Palettes list, the color map of the current image is the first one, so you just duplicate and rename it).
2) Gather the palettes (if necessary, the palettes list right-click menu has a "Show in file manager" entry)

3) Create a composite palette: add all color lines from all palettes and remove the duplicates (a good text editor must have something to sort lines, so locating duplicates shouldn't be hard).

4) Save that palette to the Gimp palette directory

5) For each image:
  • Convert to full RGB
  • Convert to color-indexed, providing the palette created previously
  • Save/Export
Thank you ! very well explained

(04-12-2021, 10:13 AM)rich2005 Wrote:
Quote:At the top of layer image list, i have a separate layer with a logo that must be exported with EACH levels..
How to do that?

You need to add your logo to the images in RGB mode, before you Index them. Use this script http://chiselapp.com/user/saulgoode/repository/script-fu/wiki?name=sg-combine-bg  it does not require all layers the same size.

Remember, that logo adds to each image colours, better if you can keep to a single color, even better if black or white. 
However, back to the original specification, consistent colormap with 32 colours. Might go like this:

Open the images as layers including the logo.
Add the logo to all layers using sg-combine-bg.scm
Export all layers as RGB jpeg, now with the logo.
Use one of those and put in Indexed Mode creating a 32 colour colormap
Add the jpgs (with logo) as layers, to that indexed image.
Export the layers to individual indexed png images.

All that in this 5 minute video. https://youtu.be/VpUK5AmkZvM





A bit at the end about editing those indexed png's preserving  the 32 color colormap.

Thank you too, for your very explanatory video...i''ve solved all my issues