Page 1 of 1

Mapping indexed colors in indexed color file (pseudo colors)

Posted: 2016-07-06T05:26:41-07:00
by happymapper
I have an raster file in indexed color mode (256 colors). The indexed colors are spread from black to white between the 256 colors. I need to reduce the colors exactly to the maximum of 100 colors in smoothly steps (index 100 should be black and 0 white). The indexed colors 101-255 can be deleted after this. Should work just like the mapcolor skript by Fred but using index numers instead of color values.
How and where could this be done in IM with or without an lookup table / mapping table? After this, can i save the table as an human readable ascii file?

example table: old index value = new index value

0=1; 1=1; 2=1; 3=2; 4=2; 5=3; 6=3; 7=4; 8=4; 9=4; 10=5 ....

Does IM offers a function to work this? Thx Oliver

Re: Mapping indexed colors in indexed color file (pseudo colors)

Posted: 2016-07-06T09:32:02-07:00
by fmw42
What do you mean by index numbers in stead of color values? Each value in a color table is a color value. You can use my script to write gray(0) ... gray(100), but I do not know how you would get just 0 to 100 without the gray(...) part. Palettes are not indices, but colors, so I do not understand what you want. Please clarify and also always provide your IM version and platform.

Imagemagick has no way to manipulate the color table directly. All you can do is use -remap with a desired colortable image to map each of the colors in your image to the "closest" color specified in the colortable image. That will result in your output image having only the number of colors specified in the colortable image. But you cannot force the arrangement of the colors in the color table.

I do not understand the use of indices rather than colors and do not believe that colortables work that way. However, I am not an expert on colortable manipulation.