I am having trouble recovering color data from a set of RGB images, following some complex processing. It's experimental at this stage to compare the results of individual channel processing and processing without separating the RGB channels.
I have four RGB images (16 bit .tiff) - b d f and l.
Processing involves separating b d f and l into their separate R G B gray channels;
convert l.tiff -separate l_%d.tiff (same for other images)
Then operating on each channel as follows - use R channel as an example, where p = processed .tiff extension is retained throughout - implied here.
lpR = (lR - dR) / (fR - bR)
For each channel this produces lpR lpG and lpB, which are then recombined into image lpRGB.
convert lpR.tiff lpG.tiff lpB.tiff -combine lpRGB.tiff
I am expecting a color image but the result is gray.
It is easy enough to use the -separate and then -combine operators on these images without the intervening processing and keep the color information, however, I think the processing is where the color information is lost.
I have tried using the -channel and -set colorspace operators, reading that in later versions of IM the -separate operator implies -channel RGBA and Sync?
How do I ensure that color is retained through the processing steps or is my initial usage when separating channels at fault?
[SOLVED] Color retention in RGB separate channel processing
[SOLVED] Color retention in RGB separate channel processing
Last edited by geoland on 2016-05-30T05:45:57-07:00, edited 1 time in total.
Version: ImageMagick 7.0.7 (latest compiled from source) Q32 x86_64 (as of) 2018 - 04 - 31 xubuntu
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Color retention in RGB separate channel processing
What is your IM version and platform? Are you sure your tiff files are sRGB and not CMYK?
I think you should post an example set of commands for us to review to be sure you have your operations in the correct order.
Have you tried
What are the image channel statistics for lpR.tiff lpG.tiff lpB.tiff (using identify -verbose)
I think you should post an example set of commands for us to review to be sure you have your operations in the correct order.
Have you tried
Code: Select all
convert lpR.tiff lpG.tiff lpB.tiff -set colorspace sRGB -combine lpRGB.tiff
Re: Color retention in RGB separate channel processing
Thank you fwm42 - I have found the problem - wrong use of the 'Grey option with -separate - silly mistake.
can I improve on the following?
process all three channels as in previous post
then as suggested
produces a recombined sRGB image.
can I improve on the following?
Code: Select all
convert images -separate %d.tiff
then as suggested
Code: Select all
convert images -set colorspace sRGB -combine output_image.tiff
Version: ImageMagick 7.0.7 (latest compiled from source) Q32 x86_64 (as of) 2018 - 04 - 31 xubuntu
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: [SOLVED] Color retention in RGB separate channel processing
You can do it all in one command line, if you use -clone and parenthesis processing. See http://www.imagemagick.org/Usage/basics/#parenthesis and http://www.imagemagick.org/Usage/basics/#clone. But it would be quite complicated due to separating 4 images into their respective channels and then doing your processing and combining. You would need to keep good track of the 12 images in the image sequence that would be used and the respective clones for doing the subtraction and division and final combining.
Re: [SOLVED] Color retention in RGB separate channel processing
I have almost completed a bash script to automate the current process using arrays to sort images into temporary folders progressively processing and moving and deleting files.
I take it -clone parenthesis will eliminate a lot of processing which is quite intensive, given that eventually the script will process 99+ image channels in a single run.
I take it -clone parenthesis will eliminate a lot of processing which is quite intensive, given that eventually the script will process 99+ image channels in a single run.
Version: ImageMagick 7.0.7 (latest compiled from source) Q32 x86_64 (as of) 2018 - 04 - 31 xubuntu
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: [SOLVED] Color retention in RGB separate channel processing
-clone only saves you from reading input images multiple times and from writing temporary files. You can also use mpr: (in memory) format in place of clones. See http://www.imagemagick.org/Usage/files/#mpr. That allows you to name each channel of each image rather than going by clone numbers, which may be easier to code.
Re: [SOLVED] Color retention in RGB separate channel processing
I might need some help to get started and will start a new thread - thks
Version: ImageMagick 7.0.7 (latest compiled from source) Q32 x86_64 (as of) 2018 - 04 - 31 xubuntu