Page 1 of 1

[SOLVED] Color retention in RGB separate channel processing

Posted: 2016-05-29T15:37:52-07:00
by geoland
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?

Re: Color retention in RGB separate channel processing

Posted: 2016-05-29T15:41:00-07:00
by fmw42
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

Code: Select all

convert lpR.tiff lpG.tiff lpB.tiff -set colorspace sRGB -combine lpRGB.tiff
What are the image channel statistics for lpR.tiff lpG.tiff lpB.tiff (using identify -verbose)

Re: Color retention in RGB separate channel processing

Posted: 2016-05-30T05:43:22-07:00
by geoland
Thank you fwm42 - I have found the problem - wrong use of the 'Grey option with -separate - silly mistake.

can I improve on the following?

Code: Select all

convert images -separate %d.tiff
process all three channels as in previous post

then as suggested

Code: Select all

convert images -set colorspace sRGB -combine output_image.tiff
produces a recombined sRGB image.

Re: [SOLVED] Color retention in RGB separate channel processing

Posted: 2016-05-30T10:59:23-07:00
by fmw42
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

Posted: 2016-05-30T17:35:24-07:00
by geoland
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.

Re: [SOLVED] Color retention in RGB separate channel processing

Posted: 2016-05-30T19:03:21-07:00
by fmw42
-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

Posted: 2016-05-30T21:19:44-07:00
by geoland
I might need some help to get started and will start a new thread - thks