// returns a masked version of given image where every pixel // above / below a given value ( in quantum range ) gets transparent Magick::Image masked( bool below, double value, Magick::Image img ) { Magick::Image mask = img; mask.type( Magick::GrayscaleMatteType ); mask.normalize(); double v = below ? value : 1-value; mask.threshold( v*MaxRGB ); if( below ) mask.negate(); mask.type( Magick::TrueColorMatteType ); mask.transparent( "black" ); Magick::Image masked = img; masked.composite( mask, Magick::CenterGravity, Magick::CopyOpacityCompositeOp ); return masked; }
void Magick::negateImage::operator()( Magick::Image &image_ ) const { image_.negate( _grayscale ); }