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

1690 - ImageMagick 6.9.10-6
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_ALPHA8 
imagick::CHANNEL_OPACITY8 
imagick::CHANNEL_MATTE 8  
imagick::CHANNEL_BLACK32 
imagick::CHANNEL_INDEX32 
imagick::CHANNEL_ALL134217727 
imagick::CHANNEL_DEFAULT134217719 
ed48


RANDOMIZED COLOR

Each new run, a new color is shown.

rgb code hexadecimal colorTHRESHOLD
71, 53, 10#47350aThreshold = 0.24
Quantum = 65535
Channel = 134217719
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(0100) / 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.37*65535,imagick::CHANNEL_INDEX);

E 01 01th661.gif


img/results/E 01 01th661.gif apr

Auschwitz-Birkenau (POL) - 2018.