Page 1 of 1

(done) How to combine image from R+G+B channels in Perl?

Posted: 2009-08-27T02:48:14-07:00
by vassapup
Hello!
I wander how to combine 3 grey channels into RGB composite by a Perl script.

I tried
$image->Read('red.tif', 'green.tif', 'blue.tif');
$image->Composite(image=>$image, compose=>'rgb');
$image->Write('composite.tif');
but it just returns grey composite.

Is there any solution to do such a composite? (not using command line)
Thanks.

Re: How to combine image from R+G+B channels in Perl?

Posted: 2009-08-27T08:11:36-07:00
by fmw42
try posting to the PerlMagick forum viewforum.php?f=7

Re: How to combine image from R+G+B channels in Perl?

Posted: 2009-08-27T09:00:01-07:00
by el_supremo
On the command line you would use the -combine operator and with MagickWand it would be MagickCombineImages but I can't find an equivalent operation in the docs for PerlMagick.

Pete

Re: How to combine image from R+G+B channels in Perl?

Posted: 2009-08-27T13:12:47-07:00
by vassapup
Thanks!
I posted this question in perl-forum topic
If there won't be any perl-solution, I'll just call Imagemagick in commandline from Perl. :)

Re: How to combine image from R+G+B channels in Perl?

Posted: 2009-08-27T21:14:51-07:00
by anthony
If you can't find a Combine method in perl, put a notice on the bugs forum and Cristy may add one.

In the mean time their is a composite solution. You take a red channel image
and use the CopyGreen and CopyBlue compose operators to copy those channels from the respective channel images.

A Command line equivalent is shown on
http://www.imagemagick.org/Usage/channels/#combine
But for non-RGB images. RGB images are easier, with one channle (typicaly red) regarded as already in place.

Re: How to combine image from R+G+B channels in Perl?

Posted: 2009-08-28T02:48:39-07:00
by vassapup
anthony wrote:You take a red channel image
and use the CopyGreen and CopyBlue compose operators to copy those channels from the respective channel images.
Yes! This perl-equivalent works:
$red->Composite(image=>$green, compose=>'CopyGreen');
$red->Composite(image=>$blue, compose=>'CopyBlue');
(having $red $green $blue as grayscale images, we'll obtain in $red RGB composite)