Convert greyscale image to alpha channel (opposite of Separate for channel=>Alpha)
Posted: 2017-09-09T01:50:29-07:00
I'm trying to extract an alpha channel as a greyscale image, manipulate it, and then either apply the greyscale image to the alpha channel on another image, or use the greyscale image as an alpha mask for a Composite operation.
I'm extracting the alpha channel as a greyscale image with something effectively like:
This works fine, but when I try to use my manipulated greyscale as an alpha mask, something effectively like:
The masking happens on a threshold basis, so I only get completely green or completely transparent pixels out - all my hard work on precise alpha levels is lost!
Is there any way I can make the masking happen the way I want, or I can do the opposite of the ->Separate in order to apply my greyscale image as an alpha channel?
Thanks all!
Jont.
I'm extracting the alpha channel as a greyscale image with something effectively like:
Code: Select all
my $alphagreyscale=$original->Clone();
$alphagreyscale->Separate(channel=>'Alpha');
Code: Select all
my $greenblock=Image::Magick->new();
$greenblock->ReadImage('xc:green[1000x1000!]');
my $target=Image::Magick->new();
$target->ReadImage('canvas:transparent[1000x1000!])';
$target->Composite(image=>$greenblock, mask=>$alphagreyscale);
Is there any way I can make the masking happen the way I want, or I can do the opposite of the ->Separate in order to apply my greyscale image as an alpha channel?
Thanks all!
Jont.