TIFF file color reducing RGB to 256 colors: PB with white

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
lraynal

TIFF file color reducing RGB to 256 colors: PB with white

Post by lraynal »

hello,

i have a geotiff file in RGB (chich correspond to a scanned map) and i want to reduce the number of color to 256

in the current case, my geotiff file has only about 35 different colors, so the colormap is not full

i use the last image magick ImageMagick-6.3.7-9-Q8-windows-static.exe on windows Server 2003.
and when i use the command line :

convert usrp_update.tif +dither -colors 256 usrp_update_256.tif

the white color that is largely used in the image is transformed in grey value (147, 147, 147), color index 30 (last color index)
could you explain me why ?

have i forgotten a parameter in the line command ?

thanks for your help.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: TIFF file color reducing RGB to 256 colors: PB with white

Post by anthony »

Quantize does not like to use 'pure' colors as such color tend not to best match a given set of colors. A slightly greyer color matches more colors.

For more specific information see...
Quantization does NOT Preserve Colors
http://imagemagick.org/Usage/quantize/# ... _not_exact

One solution is to to a trial run, and then extract the colors the quantization routine found! You can then adjust those colors and use -map to apply them to the original image.
I am looking for a good (small) example of this problem and solution.

Another solution is to append a large patch of the color wanted. This will cause the quantization routine to include that specific color as being a good color to add to the final map. the appended 'patch' can then be removed.

Again I am needing a good example to demonstrate this in IM examples.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
lraynal

Re: TIFF file color reducing RGB to 256 colors: PB with white

Post by lraynal »

i have read your proposal.

considering that there is a problem with white color (especially for my kind of image : scanned maps)
considering that white pixels stay white pixel (they represent nothing), i would propose this way :

- create a mask of the image with all the white pixels

- reducing the color of the image (as before)

- apply the white mask in the final image

what is your opinion of such a procedure ?

however, i am not sure with the command line to create and apply mask : could you help me ?

regards,
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: TIFF file color reducing RGB to 256 colors: PB with white

Post by anthony »

That will work too. but in that cause you probably want to 'normalize' the image so as to stretch the colors out rather than just mask white to white.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
lraynal

Re: TIFF file color reducing RGB to 256 colors: PB with white

Post by lraynal »

ok we can close this discussion

but the white areas have a signification in geo-data: that means nothing is there, at that place on the earth (regarding the theme that is mapped)
so even if you change the color, there are still nothing there

therefore, that's why 'white mask' have a sense in my context.

thanks for your help
Post Reply