Extracted Red channel is getting brighter.
Extracted Red channel is getting brighter.
I need to extract Red channel from a PNG file.
I use this command.
convert image.png -channel R channel.png
Unfortunately brightness is slightly increasing in pixels of the output image.
For example a pixel with red value of 100 becomes 132 in the output image.
Now I wonder if I'm using IM correctly?
I run ImageMagick 6.9.9-26 on Mac OS Sierra
Input
Output
Pavel
YoWindow Weather project
I use this command.
convert image.png -channel R channel.png
Unfortunately brightness is slightly increasing in pixels of the output image.
For example a pixel with red value of 100 becomes 132 in the output image.
Now I wonder if I'm using IM correctly?
I run ImageMagick 6.9.9-26 on Mac OS Sierra
Input
Output
Pavel
YoWindow Weather project
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Extracted Red channel is getting brighter.
Your input image is grayscale. What do you mean by "extract Red channel"? The red channel is no different to the green or blue channels, or the gray value.
Your command doesn't extract a channel, it merely sets what channels any following operations should operate on, but there aren't any operations. Your output is identical to your input.
Your command doesn't extract a channel, it merely sets what channels any following operations should operate on, but there aren't any operations. Your output is identical to your input.
snibgo's IM pages: im.snibgo.com
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Extracted Red channel is getting brighter.
ImageMagick compare function says the pixel data is identical. Both images are type=grayscale, but your input shows it as colorspace sRGB, while your output has colorspace Gray.
0 (0)
The difference is in the PNG meta data:
Input:
Output:
And intent is not specified.
Try the following:
That seems to match in meta data for me.
Unfortunately, I do not think you can set rendering intent to perceptual on a uniquely colorspace gray image. So you need to leave the image as colorspace sRGB and type=grayscale to keep the intent=perceptual.
I tried
But the verbose information says that rendering intent is undefined and no PNG intent is set.
Code: Select all
compare -metric rmse XAln75t.png L0Yiqwm.png null:
The difference is in the PNG meta data:
Input:
Code: Select all
png:IHDR.color_type: 2 (Truecolor)
png:sRGB: intent=0 (Perceptual Intent)
Code: Select all
png:IHDR.color-type-orig: 0
Try the following:
Code: Select all
convert input.png -define png:color-type=2 -intent perceptual output.png
Unfortunately, I do not think you can set rendering intent to perceptual on a uniquely colorspace gray image. So you need to leave the image as colorspace sRGB and type=grayscale to keep the intent=perceptual.
I tried
Code: Select all
convert input.png -colorspace gray -intent perceptual output.png
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Extracted Red channel is getting brighter.
Is intent relevant? There is no profile.
snibgo's IM pages: im.snibgo.com
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Extracted Red channel is getting brighter.
I do not know. I thought if it was colorspace sRGB vs grayscale, that intent would be relevant. It is listed in the input verbose information Rendering Intent and as PNG:sRGB intent=perceptual
Re: Extracted Red channel is getting brighter.
Guys, thank you for responding so quickly!
I have a PNG image in sRGB format.
All three RGB channels contain the same values.
I just need to extract one of them (Red, for example) to a file in grayscale format to save space and memory.
I've tried the spells proposed by Fred.
Unfortunately, they produce an RGB image that stores all three channels.
The last one produces a grayscale image, but the brightness is higher than in the original. Just like in my attempt.
What is the proper way to extract a channel with Image Magick?
I have a PNG image in sRGB format.
All three RGB channels contain the same values.
I just need to extract one of them (Red, for example) to a file in grayscale format to save space and memory.
I've tried the spells proposed by Fred.
Unfortunately, they produce an RGB image that stores all three channels.
The last one produces a grayscale image, but the brightness is higher than in the original. Just like in my attempt.
Code: Select all
convert input.png -colorspace gray -intent perceptual output.png
Thank you, snibgo.
What is the proper way to extract a channel with Image Magick?
Re: Extracted Red channel is getting brighter.
For the reference the input and output images side by side in Photoshop.
Notice that the building to the right is brighter.
Notice that the building to the right is brighter.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Extracted Red channel is getting brighter.
I do not think you can do that since I think you cannot specify perceptual intent for grayscale single channel images. If you change your input to have intent unspecified, then they would look the same. Perhaps using profiles and intent you can manage to get what you want. As I mentioned before the actual pixel data is identical. It seems that the perceptual intent on your input is what makes it look different.
How did you create your input? What tool?
Try this:
How did you create your input? What tool?
Try this:
Code: Select all
convert input.png -profile /Users/fred/images/profiles/GrayGamma22.icm output.png
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Extracted Red channel is getting brighter.
Here you go:wrote:I have a PNG image in sRGB format.
All three RGB channels contain the same values.
I just need to extract one of them (Red, for example) to a file in grayscale format to save space and memory.
Code: Select all
convert in.png out.png
I don't know why Photoshop displays them as different.
snibgo's IM pages: im.snibgo.com
-
- Posts: 5
- Joined: 2017-12-05T09:12:57-07:00
- Authentication code: 1152
Re: Extracted Red channel is getting brighter.
I believe the difference in the images you show are due to Color Profiles in Photoshop.
This has bitten me many, many times. (I don't seem to learn my lesson)
Below is a link to one of the best descriptions of Photoshop color profiles I have found: an introduction to what they do, and how to adjust color profiles.
In their example -- they want the browser image to look the same as the image in Photoshop:
https://www.howtogeek.com/70161/my-phot ... -fix-them/
This has bitten me many, many times. (I don't seem to learn my lesson)
Below is a link to one of the best descriptions of Photoshop color profiles I have found: an introduction to what they do, and how to adjust color profiles.
In their example -- they want the browser image to look the same as the image in Photoshop:
https://www.howtogeek.com/70161/my-phot ... -fix-them/