Change Palette entries in grayscale raster?

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
Zitterbacke
Posts: 2
Joined: 2015-08-24T04:30:22-07:00
Authentication code: 1151

Change Palette entries in grayscale raster?

Post by Zitterbacke »

Hello,
can I change the palette entries in a 4Bit raster (16 colors) with convert.exe from ImageMagick 6.9.1-10 for Windows.

Code: Select all

1 7734brtx_direkt_813dpi.tif
TIFFGetField

 TIFFTags :
o photometric:     1
o samplesperpixel: 1
o bitspersample:   1
o Image Width:     18004
o Image Length:    17004
o Planarconfig:    1
o Rows/Strip:      3
o Resolution:      813.00
o RUnit:           2
o ExtraSamples:    0  0
Here we have known a color index from 0 to 15.

For example I will change the
Color Index 1 from rgb(17,17,17) to rgb(0,0,0)
Color Index 2 from rgb(34,34,34) to rgb(0,0,0)
Color Index 3 from rgb(51,51,51) to rgb(0,0,0)
Color Index 4 from rgb(68,68,68) to rgb(0,0,0)

With IrfanView-GUI, it is possible.

Regards from Munich, Germany.
Zitterbacke
Posts: 2
Joined: 2015-08-24T04:30:22-07:00
Authentication code: 1151

Re: Change Palette entries in grayscale raster?

Post by Zitterbacke »

I fond it. It is -threshold value{%}
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Change Palette entries in grayscale raster?

Post by fmw42 »

Zitterbacke wrote:I fond it. It is -threshold value{%}
I do not think that will work. It will make all values below your value to black and the rest white.

I think what you want is

Unix syntax:

Code: Select all

convert image \
-fill black -opaque "rgb(17,17,17)"  \
-fill black -opaque "rgb(34,34,34)"  \
-fill black -opaque "rgb(51,51,51)"  \
-fill black -opaque "rgb(68,68,68)"  \
resultimage

Windows syntax:

Code: Select all

convert image ^
-fill black -opaque "rgb(17,17,17)"  ^
-fill black -opaque "rgb(34,34,34)"  ^
-fill black -opaque "rgb(51,51,51)"  ^
-fill black -opaque "rgb(68,68,68)"  ^
resultimage

see
http://www.imagemagick.org/Usage/color_basics/#replace
Post Reply