Page 1 of 2

grayscale to color

Posted: 2015-11-18T01:52:02-07:00
by pog
I have old version of ImageMagick (5.4.1), unfortunately I can not upgrade to newer version because 5.4.1 is the latest version available for my platform (SGI IRIX 6.5).

I have grayscale image and i want for every pixel replace Green value to 255 without change Red and Blue channels.
For example RGB=(20,20,20) should be replaced by (20,255,20).

I can't found something useful in convert command parameters.

Any help will be appreciated.

Re: grayscale to color

Posted: 2015-11-18T10:35:39-07:00
by fmw42
That version is so ancient that I do not know what features were available. But you can try to replace the green channel with a constant white image. Here is one way with rudimentary commands that I hope you have on such an old system.

Code: Select all

convert image.suffix -separate image.suffix
convert image.suffix -fill white -colorize 100% white.suffix
convert image-0.suffix white.suffix image-2.suffix -combine newimage.suffix

Re: grayscale to color

Posted: 2015-11-18T11:35:35-07:00
by snibgo
In current IM, to set all green values to 100%:

Code: Select all

convert in.png -channel G -evaluate set 100% +channel out.png
But I don't know if that would work in your old version.

Re: grayscale to color

Posted: 2015-11-18T21:48:19-07:00
by pog
Thank you, fmw42 and snibgo. Unfortunately, both your solutions don't work for my (-separate, -evaluate options don't exist ...)

Re: grayscale to color

Posted: 2015-11-18T23:35:33-07:00
by snibgo
If you type just "convert" with nothing else, it may print a list of available commands. Paste that here, and perhaps we can suggest a method.

You might consider donating your version of IM, or the entire computer, to a museum.

Re: grayscale to color

Posted: 2015-11-18T23:39:17-07:00
by pog
Version: @(#)ImageMagick 5.4.1 12/01/01 Q:16 http://www.imagemagick.org
Copyright: Copyright (C) 2001 ImageMagick Studio

Usage: convert [options ...] file [ files... ] output_file

Where options include:
-adjoin join images into a single multi-image file
-affine matrix drawing transform matrix
-antialias remove pixel-aliasing
-append append an image sequence
-average average an image sequence
-background color background color
-blur geometry blur the image
-border geometry surround image with a border of color
-bordercolor color border color
-box color color for annotation bounding box
-cache threshold megabytes of memory available to the pixel cache
-channel type extract a particular color channel from image
-charcoal radius simulate a charcoal drawing
-coalesce merge a sequence of images
-colorize value colorize the image with the fill color
-colors value preferred number of colors in the image
-colorspace type alternate image colorspace
-comment string annotate image with comment
-compress type type of image compression
-contrast enhance or reduce the image contrast
-crop geometry preferred size and location of the cropped image
-cycle amount cycle the image colormap
-delay value display the next image after pausing
-deconstruct break down an image sequence into constituent parts
-density geometry vertical and horizontal density of the image
-depth value depth of the image
-despeckle reduce the speckles within an image
-display server obtain image or font from this X server
-dispose method GIF disposal method
-dither apply Floyd/Steinberg error diffusion to image
-draw string annotate the image with a graphic primitive
-edge radius apply a filter to detect edges in the image
-emboss radius emboss an image
-enhance apply a digital filter to enhance a noisy image
-equalize perform histogram equalization to an image
-fill color color to use when filling a graphic primitive
-filter type use this filter when resizing an image
-flatten flatten a sequence of images
-flip flip image in the vertical direction
-flop flop image in the horizontal direction
-font name font for rendering text
-frame geometry surround image with an ornamental border
-fuzz distance colors within this distance are considered equal
-gamma value level of gamma correction
-geometry geometry perferred size or location of the image
-gaussian geometry gaussian blur an image
-gravity type vertical and horizontal text placement
-implode amount implode image pixels about the center
-intent type Absolute, Perceptual, Relative, or Saturation
-interlace type None, Line, Plane, or Partition
-label name assign a label to an image
-level value adjust the level of image contrast
-list type Color, Delegate, Format, Magic, Module, or Type
-loop iterations add Netscape loop extension to your GIF animation
-map filename transform image colors to match this set of colors
-matte store matte channel if the image has one
-median radius apply a median filter to the image
-modulate value vary the brightness, saturation, and hue
-monochrome transform image to black and white
-morph value morph an image sequence
-mosaic create an mosaic from an image sequence
-negate replace every pixel with its complementary color
-noise radius add or reduce noise in an image
-normalize transform image to span the full range of colors
-opaque color change this color to the fill color
-page geometry size and location of an image canvas
-paint radius simulate an oil painting
-ping efficiently determine image attributes
-pointsize value pointsize of Postscript font
-preview type image preview type
-profile filename add ICM or IPTC information profile to image
-quality value JPEG/MIFF/PNG compression level
-raise value lighten/darken image edges to create a 3-D effect
-region geometry apply options to a portion of the image
-roll geometry roll an image vertically or horizontally
-rotate degrees apply Paeth rotation to the image
-sample geometry scale image with pixel sampling
-scale geometry resize image
-scene value image scene number
-segment values segment an image
-seed value pseudo-random number generator seed value
-shade degrees shade the image using a distant light source
-sharpen geometry sharpen the image
-shave geometry shave pixels from the image edges
-shear geometry slide one edge of the image along the X or Y axis
-size geometry width and height of image
-solarize threshold negate all pixels above the threshold level
-spread amount displace image pixels by a random amount
-stroke color color to use when stoking a graphic primitive
-strokewidth value width of stroke
-swirl degrees swirl image pixels about the center
-texture filename name of texture to tile onto the image background
-threshold value threshold the image
-tile filename tile image when filling a graphic primitive
-transparent color make this color transparent within the image
-treedepth value depth of the color tree
-type type image type
-units type PixelsPerInch, PixelsPerCentimeter, or Undefined
-unsharp geometry sharpen the image
-verbose print detailed information about the image
-view FlashPix viewing transforms
-wave geometry alter an image along a sine wave

Re: grayscale to color

Posted: 2015-11-19T00:44:16-07:00
by fmw42
Does this work

Code: Select all

convert in.png -channel G -fill white -colorize +channel out.png
Are you sure there is no -combine?

Re: grayscale to color

Posted: 2015-11-19T00:51:40-07:00
by pog
fmw47: I receive "convert: Missing value (-colorize)" message

Re: grayscale to color

Posted: 2015-11-19T00:56:35-07:00
by fmw42
Odd your list above says:

"-colorize value colorize the image with the fill color"

Re: grayscale to color

Posted: 2015-11-19T00:57:33-07:00
by fmw42
What messages did you get from my earlier commands?

Code: Select all

convert image.suffix -separate image.suffix
convert image.suffix -fill white -colorize 100% white.suffix
convert image-0.suffix white.suffix image-2.suffix -combine newimage.suffix

Re: grayscale to color

Posted: 2015-11-19T01:04:40-07:00
by pog
1. As I understand, -colorize option needs some parameter

2. Unrecognized option (-separate)

Re: grayscale to color

Posted: 2015-11-19T01:06:30-07:00
by fmw42
Sorry, it is getting late for me. I did miss the argument. So try

Code: Select all

convert in.png -channel G -fill white -colorize 100% +channel out.png

Re: grayscale to color

Posted: 2015-11-19T01:09:09-07:00
by fmw42
fmw42 wrote:Sorry, it is getting late for me. I did miss the argument. So try

Code: Select all

convert in.png -channel G -fill white -colorize 100% +channel out.png

For such an old IM version, you may need to put the argument before the input image

Code: Select all

convert -channel G -fill white -colorize 100% +channel in.png out.png

Re: grayscale to color

Posted: 2015-11-19T01:13:17-07:00
by fmw42
try also

Code: Select all

convert -channel G -threshold -1 +channel in.png out.png

Re: grayscale to color

Posted: 2015-11-19T01:17:55-07:00
by pog
After command:
convert -channel Green -fill white -colorize 100% +channel in.png out.png
all grayscale pixels are white (255,255,255)

After command:
convert -channel Green -threshold -1 +channel in.png out.png
all image is white