Page 1 of 1
Outputting Channel Images in RGB
Posted: 2014-03-08T00:32:19-07:00
by blue-j
I'd like to output separate channel images in RGB format, but can't seem to get what I need:
Code: Select all
convert input.ext -separate channel_%d.jpg
i've tried putting -colorspace RGB after -separate without luck. I understand the separate argument wisely outputs grayscale images; I want to make them RGB and maintain the source ICC profile (that happens by default it seems, which is good, except it embeds invalid RGB profiles inside grayscale images!) for rendering in a browser. i'm so sorry to ask this, i have tried to find the answer myself, and I know this should be easy for me! But alas, no fruit has dropped from the shaking of the tree.
Thanks in advance!
J
Re: Outputting Channel Images in RGB
Posted: 2014-03-08T07:09:03-07:00
by snibgo
Sorry, I don't understand what you want.
Do you want to create three files from one file? What do you want in those three files?
"-separate" puts the red channel in the first file, green in the second, and blue in the third. So each file contains one channel, which is greyscale.
If you want the three files to actually
look red, green and blue, then:
Code: Select all
convert channel_0.jpg -channel GB -evaluate set 0 channel_0.jpg
convert channel_1.jpg -channel RB -evaluate set 0 channel_1.jpg
convert channel_2.jpg -channel RG -evaluate set 0 channel_2.jpg
The three files are now colour images, not greyscale.
Re: Outputting Channel Images in RGB
Posted: 2014-03-09T17:50:01-07:00
by blue-j
hi there, thank you so much for your energy and for sharing your thoughts! i was looking for gray images, one per channel, technically in the RGB colorspace. but i will look at your suggestion and think about my direction further. thanks again!
- J
Re: Outputting Channel Images in RGB
Posted: 2014-03-09T18:24:00-07:00
by snibgo
You want the separated images to encode pixels as RGB (instead of sRGB) colorspace?
Code: Select all
convert in.png -separate -colorspace RGB out.png
PNG files have metadata that says whether the data is RGB or sRGB, and IM sets the metadata as appropriate. But some software ignores the metadata.
As far as I know, JPEG doesn't have that metadata. So programs that read the JPEG will probably think the values are encoded as sRGB.
EDIT: I see you said "i've tried putting -colorspace RGB after -separate without luck."
My example above works for IM v6.8.8-7 under Windows 7. If you are running an old version of IM, it may not work.
Re: Outputting Channel Images in RGB
Posted: 2014-03-09T18:35:57-07:00
by fmw42
for jpg, you could add a linear RGB profile to each gray jpg output
Re: Outputting Channel Images in RGB
Posted: 2014-03-09T19:38:04-07:00
by blue-j
i'm running the latest macport, which is 6.8.8-3_1.
to be more precise, my desire is to keep the source profile in the channel images, and retain the source colorspace (i.e., no color conversion, or at least one without visual effects). that way an ICC-savvy rendering of the channel images will be faithful to such a rendering of the composite.
nothing i do can change the output from being untagged grayscale at present. i'll keep working! thanks my friends!
J
Re: Outputting Channel Images in RGB
Posted: 2014-03-09T20:15:40-07:00
by blue-j
i found this post:
http://stackoverflow.com/questions/1144 ... ce-to-gray
and tried the truecolor argument, and it worked in at least gaining RGB output.
Code: Select all
convert input.ext -separate -type truecolor channel_%d.jpg
but my final goal eludes me for now. i may just go with sRGB GIFs and call it a day and live with the slight visual discrepancy in an ICC-savvy viewer.
- J
Re: Outputting Channel Images in RGB
Posted: 2014-03-09T20:55:11-07:00
by fmw42
blue-j wrote:i'm running the latest macport, which is 6.8.8-3_1.
to be more precise, my desire is to keep the source profile in the channel images, and retain the source colorspace (i.e., no color conversion, or at least one without visual effects). that way an ICC-savvy rendering of the channel images will be faithful to such a rendering of the composite.
nothing i do can change the output from being untagged grayscale at present. i'll keep working! thanks my friends!
J
You will have to read the verbose information for the image using IM to get the colorspace or profile. Then add the correct or desired profile to the output image if no profile was found in the input image. With IM you can either change profiles or add a profile if none exists.
See -profile
http://www.imagemagick.org/script/comma ... hp#profile
http://www.imagemagick.org/Usage/formats/#profiles
Re: Outputting Channel Images in RGB
Posted: 2014-03-11T13:10:36-07:00
by blue-j
thanks so much fred, i have already tried this without success, which i am measuring right now by visual reconciliation with Photoshop 14.2. i'll continue my work; perhaps Photoshop's rendering is suboptimal.
J
Re: Outputting Channel Images in RGB
Posted: 2014-03-11T13:28:25-07:00
by fmw42
blue-j wrote:thanks so much fred, i have already tried this without success, which i am measuring right now by visual reconciliation with Photoshop 14.2. i'll continue my work; perhaps Photoshop's rendering is suboptimal.
J
Photoshop has the habit of overwriting your profile or assigning one with theirs. Open the color control panel and set it to show when importing images so that you can tell it what profile to use, etc.
Post an example and tell us what you are trying to do. If you have an input image and your PS output and your IM output, post those. Then we can see what might be going on and what the correct IM commands or PS settings are needed.
Re: Outputting Channel Images in RGB
Posted: 2014-03-11T14:03:20-07:00
by snibgo
blue-j wrote:to be more precise, my desire is to keep the source profile in the channel images, and retain the source colorspace (i.e., no color conversion, or at least one without visual effects). that way an ICC-savvy rendering of the channel images will be faithful to such a rendering of the composite.
With these commands ...
Code: Select all
convert redBlue.png -separate rb.png
convert redBlue.png -separate rb.jpg
... the ICC profile from redBlue.png is copied to the output files. I can see that from "identify -verbose rb-0.png" etc. The resulting files (3 for each command) contain the pixels values from the red, green and blue channels.
But this is very dodgy practice because the embedded ICC profile no longer describes the meaning of the pixel values.
It may be better to extract the profile...
... then either strip the profile before separating, or convert the image to sRGB.