Imagick::thresholdImage


wizard apg

CHANGES the value of individual pixels based on a threshold.



<?php

bool 
public Imagick::thresholdImage(
                              
float $threshold, 
                                
int $channel = Imagick::CHANNEL_DEFAULT);
                                            
?>

$threshold


The threshold.



$channel


One of Imagick::CHANNEL_*.





This function returns true on success.



AVAILABLE "imagick" CHANNEL
STUDIED IN THIS TUTORIAL

1810 - ImageMagick 7.1.2-34
CHANNEL
CONSTANTVALUEABOUT
imagick::CHANNEL_UNDEFINED0 
imagick::CHANNEL_RED1 
imagick::CHANNEL_GRAY1 
imagick::CHANNEL_CYAN1 
imagick::CHANNEL_GREEN2 
imagick::CHANNEL_MAGENTA2 
imagick::CHANNEL_BLUE4 
imagick::CHANNEL_YELLOW4 
imagick::CHANNEL_ALPHA16 
imagick::CHANNEL_OPACITY16 
imagick::CHANNEL_MATTE  
imagick::CHANNEL_BLACK8 
imagick::CHANNEL_INDEX32 
imagick::CHANNEL_ALL134217727 
imagick::CHANNEL_DEFAULT134217727 
ed48


RANDOMIZED COLOR

Each new run, a new color is shown.

rgb code hexadecimal colorTHRESHOLD
118, 24, 21#761815Threshold = 0.66
Quantum = 65535
Channel = 134217727
ed48

  1 EXERCISE   

<?php

// Run several times

$file1 = PATH2IMGW . '/gif/E 01 01.gif';

$str1img = 'img/results/E 01 01th661.gif';

$image1 = new Imagick($file1);

$threshold = mt_rand(0, 100) / 100;

$quantum = $image1->getQuantum();

$channel = imagick::CHANNEL_DEFAULT;

$image1->thresholdImage($threshold * $quantum, $channel);

$image1 = $image1->getImageBlob();

$img = imagecreatefromstring($image1);

imagegif($img, $str1img);

echo 
basename($str1img); ?>
<br><br>
<img src="<?php echo $str1img; ?>"
 alt="<?php echo $str1img; ?>" 
 title="<?php echo $str1img; ?>">

 RESULT   


thresholdImage(0.4*65535,imagick::CHANNEL_RED);

E 01 01th661.gif


img/results/E 01 01th661.gif apr

Auschwitz-Birkenau (POL) - 2018.