How does the grayscale image change color?

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
maple
Posts: 4
Joined: 2019-01-29T20:13:22-07:00
Authentication code: 1152

How does the grayscale image change color?

Post by maple »

I convert an image to a grayscale image

Code: Select all

convert 001.jpg -colorspace gray out.jpg
The next,I need to convert it to a single channel color image, what should I do?

please help me
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How does the grayscale image change color?

Post by fmw42 »

Imagemagick 6 internally treats grayscale images as 3 equal RGB channels. To outside programs it is actually only one channel. For example:

convert logo: -colorspace gray x.jpg

exiftool -s -ee -g1 -u -n -D x.jpg
---- ExifTool ----
- ExifToolVersion : 10.51
---- System ----
- FileName : x.jpg
- Directory : .
- FileSize : 34253
- FileModifyDate : 2019:01:29 20:51:46-08:00
- FileAccessDate : 2019:01:29 20:51:46-08:00
- FileInodeChangeDate : 2019:01:29 20:51:46-08:00
- FilePermissions : 644
---- File ----
- FileType : JPEG
- FileTypeExtension : JPG
- MIMEType : image/jpeg
- ImageWidth : 640
- ImageHeight : 480
- EncodingProcess : 0
- BitsPerSample : 8
- ColorComponents : 1
---- JFIF ----
0 JFIFVersion : 1 1
2 ResolutionUnit : 0
3 XResolution : 1
5 YResolution : 1
---- Composite ----
- ImageSize : 640x480
- Megapixels : 0.3072


Imagemagick 7, internally treats grayscale images as one single channel.
maple
Posts: 4
Joined: 2019-01-29T20:13:22-07:00
Authentication code: 1152

Re: How does the grayscale image change color?

Post by maple »

fmw42 wrote: 2019-01-29T21:53:36-07:00 Imagemagick 6 internally treats grayscale images as 3 equal RGB channels. To outside programs it is actually only one channel. For example:

convert logo: -colorspace gray x.jpg

exiftool -s -ee -g1 -u -n -D x.jpg
---- ExifTool ----
- ExifToolVersion : 10.51
---- System ----
- FileName : x.jpg
- Directory : .
- FileSize : 34253
- FileModifyDate : 2019:01:29 20:51:46-08:00
- FileAccessDate : 2019:01:29 20:51:46-08:00
- FileInodeChangeDate : 2019:01:29 20:51:46-08:00
- FilePermissions : 644
---- File ----
- FileType : JPEG
- FileTypeExtension : JPG
- MIMEType : image/jpeg
- ImageWidth : 640
- ImageHeight : 480
- EncodingProcess : 0
- BitsPerSample : 8
- ColorComponents : 1
---- JFIF ----
0 JFIFVersion : 1 1
2 ResolutionUnit : 0
3 XResolution : 1
5 YResolution : 1
---- Composite ----
- ImageSize : 640x480
- Megapixels : 0.3072


Imagemagick 7, internally treats grayscale images as one single channel.
sorry,I don't understand,I am usingImagemagick 7,How to use commands to change the color of grayscale images
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How does the grayscale image change color?

Post by fmw42 »

What do you mean by change the color of grayscale images? Do you want to colorize them? Or do you want to make the grayscale image become 3 channels RGB format?

Your question was:
The next,I need to convert it to a single channel color image, what should I do?
In Imagmagick 7, doing your command should make a single channel grayscale image.


______________________

Please, always provide your IM version and platform when asking questions, since syntax may differ.

Also provide your exact command line and your images, if possible.

See the top-most post in this forum "IMPORTANT: Please Read This FIRST Before Posting" at viewtopic.php?f=1&t=9620

If using Imagemagick 7, then see http://imagemagick.org/script/porting.php#cli


For novices, see

viewtopic.php?f=1&t=9620
http://www.imagemagick.org/script/comma ... essing.php
http://www.imagemagick.org/Usage/reference.html
http://www.imagemagick.org/Usage/
https://github.com/ImageMagick/usage-markdown
https://imagemagick.org/script/porting.php#cli
maple
Posts: 4
Joined: 2019-01-29T20:13:22-07:00
Authentication code: 1152

Re: How does the grayscale image change color?

Post by maple »

fmw42 wrote: 2019-01-30T00:24:12-07:00 What do you mean by change the color of grayscale images? Do you want to colorize them? Or do you want to make the grayscale image become 3 channels RGB format?

Your question was:
The next,I need to convert it to a single channel color image, what should I do?
In Imagmagick 7, doing your command should make a single channel grayscale image.


______________________

Please, always provide your IM version and platform when asking questions, since syntax may differ.

Also provide your exact command line and your images, if possible.

See the top-most post in this forum "IMPORTANT: Please Read This FIRST Before Posting" at viewtopic.php?f=1&t=9620

If using Imagemagick 7, then see http://imagemagick.org/script/porting.php#cli


For novices, see

viewtopic.php?f=1&t=9620
http://www.imagemagick.org/script/comma ... essing.php
http://www.imagemagick.org/Usage/reference.html
http://www.imagemagick.org/Usage/
https://github.com/ImageMagick/usage-markdown
https://imagemagick.org/script/porting.php#cli


sorry,I did not express clearly,I want to give color to the grayscale image...
Imagemagick 7
win7
I need the command to use directly because the English documentation is a bit complicated..

I want to achieve the following effect:
Image
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How does the grayscale image change color?

Post by fmw42 »

try this

Code: Select all

magick grayscale.png +level-colors "red,white" colored.png
see https://imagemagick.org/Usage/color_mods/#level-colors
maple
Posts: 4
Joined: 2019-01-29T20:13:22-07:00
Authentication code: 1152

Re: How does the grayscale image change color?

Post by maple »

fmw42 wrote: 2019-01-30T10:43:30-07:00 try this

Code: Select all

magick grayscale.png +level-colors "red,white" colored.png
see https://imagemagick.org/Usage/color_mods/#level-colors

That's what I want..Thanks♪(・ω・)ノ
Post Reply