I have two greyscale images, G1.jpg and G2.jpg. I would like to treat G1.jpg as the red channel, and G2.jpg as the green channel to produce an output image of combinations of red and green. Is this possible?
Thanks,
Dave
Combine greyscale images as the color channels of an RGB ima
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Combine greyscale images as the color channels of an RGB ima
Yes, but you also need to define a blue image, but it can be totally black. Use -combine. see
http://www.imagemagick.org/Usage/channels/#combine
http://www.imagemagick.org/Usage/channels/#combine
Re: Combine greyscale images as the color channels of an RGB ima
Great - here was my entire script:
ImageMagick does it again!
Code: Select all
convert -size 250x250 xc:black black.jpg
convert r.jpg g.jpg black.jpg -combine combined.jpg
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Combine greyscale images as the color channels of an RGB ima
you can make it simpler:
convert r.jpg g.jpg \( -size 250x250 xc:black \) -combine combined.jpg
see http://www.imagemagick.org/Usage/basics/#image_seq
convert r.jpg g.jpg \( -size 250x250 xc:black \) -combine combined.jpg
see http://www.imagemagick.org/Usage/basics/#image_seq
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Combine greyscale images as the color channels of an RGB ima
Just set background and only combine two channels, undefined channels are set to the background setting (for that channel).
WARNING: the order of the channels is not exchangeable, it must be red then green.
Code: Select all
convert r.jpg g.jpg -background black -channel RG -combine combined.jpg
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: Combine greyscale images as the color channels of an RGB ima
So since they have to be ordered, if you wanted to combine just G and B, you'd have to use the first method of making a black red channel? Same for R and B? The only one can you can take advantage of the background is R only, or R and G?
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Combine greyscale images as the color channels of an RGB ima
No, the order is just that the order. the -channel defines which of the channel images are actually being provided.daviddoria wrote:So since they have to be ordered, if you wanted to combine just G and B, you'd have to use the first method of making a black red channel? Same for R and B? The only one can you can take advantage of the background is R only, or R and G?
So for BG with a R set to zero you would use
Code: Select all
convert g.jpg b.jpg -background black -channel GB -combine combined.jpg
The channel setting just 'flags' what channel images are being used, it does not specify order. That was what I was getting at.
This is covered in IM Examples, channel, masks, and transparency, combining channel images.
http://www.imagemagick.org/Usage/channels/#combine
Hmmm... Actually it should cover it, looks like an example is needed!
It also goes on to how you would combine non-RGB channel images
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: Combine greyscale images as the color channels of an RGB ima
ah, sorry, I totally missed the -channel in your last post, that makes much more sense!