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

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
vassapup

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

Post 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.
Last edited by vassapup on 2009-08-28T02:49:16-07:00, edited 1 time in total.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

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

Post by fmw42 »

try posting to the PerlMagick forum viewforum.php?f=7
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

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

Post 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
Sorry, my ISP shutdown all personal webspace so my MagickWand Examples in C is offline.
See my message in this topic for a link to a zip of all the files.
vassapup

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

Post 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. :)
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

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

Post 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.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
vassapup

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

Post 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)
Post Reply