overlay of non-standard color channels

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
langstrump

overlay of non-standard color channels

Post by langstrump »

I have three gray scale images resembling different colors that I want to overlay to a composite color image.

convert test-Ch1.png test-Ch2.png test-Ch3.png -background black -combine test.png

gives me an overlay, but interpretes the images as the channels red, green, blue. This cannot be changed by the "-channel"-option.
However, I would like to have the second gray scale image yellow and not green.

How can this be done?

Thanks for your help

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

Re: overlay of non-standard color channels

Post by fmw42 »

You can only combine channels corresponding to standard colorspaces, such as RGB, CMYK, CMY, HSL, etc.

You cannot have RGB and Y (unless you somehow merge two colors and use that for one of the standard channels of some given colorspace)
nor RYB. For the latter, you would have to somehow decompose the Y into R and G (combine the R from Y and the orginal R) and use those along with B as RGB. But I have no idea how you would do any of this.

Can you not just create grayscale images for C,M,Y (and K)?

see

http://www.imagemagick.org/Usage/channe ... bine_other

Perhaps you can explain further about where your grayscale images come from and what your real goal for the result is?
langstrump

Re: overlay of non-standard color channels

Post by langstrump »

The grey scale images are generated by a microscope acquiring fluorescence intensities at different wavelengths. So actually, I want to create an overlay in pseudo-color. One of the channels is usually illustrated in yellow.

I though, mixing red and green should give yellow. So, to add the "yellow" image in both the red and the green channel I first combined the red and the "yellow" to a new greyscale image that I then used in the red channel

# combining red and yellow channel to new greyscale image
convert test_Y.png test_R.png -background black -combine test_YR.png
convert test_YR.png -colorspace Gray test_YR.png

# combing everything
convert test_YR.png test_Y.png test_B.png -background black -channel RGB -combine test.png

However, the result is not satisfying. There is absolutely no difference to just doing:
convert test_R.png test_Y.png test_B.png -background black -channel RGB -combine test.png
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: overlay of non-standard color channels

Post by fmw42 »

You could try coding a grayscale gradient with your pseudocolors and then applying using -clut. see http://www.imagemagick.org/Usage/color/#color_lut
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: overlay of non-standard color channels

Post by anthony »

fmw42 wrote:You could try coding a grayscale gradient with your pseudo-colors and then applying using -clut. see http://www.imagemagick.org/Usage/color/#color_lut
For generating psuedo-color LUTs the best technique is usually a "Resize Gradient".
That is create a small image of specific color order wanted, then enlarge (or use as-is directly,
using the IM interpolation methods.) Other gradient methods can also be used.

See IM examples Resize Gradients
http://www.imagemagick.org/Usage/canvas ... ent_resize

I do have a LUT coloring example (an array of 2-dimentional maps) which psuedo-color maps specific values to specific color changes, But I have not turned it into a example in IM examples as yet.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
langstrump

Re: overlay of non-standard color channels

Post by langstrump »

I found a quite simple solution to my problem.
I first generate a overlay of the grey scales using the RGB channels. As yellow is generated by mixing red and green I add the green channel to the red channel using -recolor:

convert test_R.png test_Y.png test_B.png -background black -combine test_pre.png
convert test_pre.png -recolor '1 1 0 0 1 0 0 0 1' test.png

Thanks for all the hints and discussion!
Post Reply