imagegammacorrect 


gd apg

APPLIES gamma correction to the given gd image given an input and an output gamma.





GAMMA CORRECTION

is a nonlinear operation, applied to encode or decode LUMINANCE parameters or TRISTIMULUS values in images, to make their appearance close to that perceived by humans.

LUNINANCE

is the measure of the density of the intensity of a light reflected in a particular direction.

TRISTIMULUS

is a description of how the three primary colors are blended to obtain a particular secondary color.

Gamma is defined by Vout = Vingamma,

where:

Vout is the OUTPUT luminance value
and
Vin is the INPUT/actual luminance value.

This formula causes the graphic line to curve.

When gamma < 1, the line arches upward.

gamma_chart3c.png apr

When gamma > 1, the line arches down.

gamma_chart4d.png apr

* Images from CAMBRIDGE in COLOR



This function returns TRUE on success or FALSE on failure.



<?php

bool imagegammacorrect 
GdImage $image
                                                  
float $input_gamma
                                                  
float $output_gamma )


where,

$image The image identifier

$input_gamma 
The input gamma
              
$output_gamma 
The output gamma

?>
 

  $image   


The image identifier.



  $input_gamma   


The input gamma.



  $output_gamma   


The output gamma.



  1 EXERCISE   

<?php

echo 'PHP VERSION: ' PHP_VERSION '<br><br>';

$lang 'en';

$org_file "jpeg/JPEG 033 01.jpg";

$des_file "jpeg/JPEG 033 01 imagegammacorrect.jpg";

$gamma_in 2.0;

$gamma_out 0.9;

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

<?php
$id_HS01 
imagecreatefromjpeg$org_file);

$gamacorrectd 
imagegammacorrect($id_HS01$gamma_in$gamma_out);

if(
$gamacorrectd == true)
{
imagejpeg($id_HS01$des_file);

echo 
'<br><br>' basename($des_file); ?><br><br>
<img src="<?php echo $des_file?>"
alt="<?php echo $des_file?>
title="<?php echo $des_file?>">
<?php
imagedestroy
($id_HS01);
}
else
{
$en 'GAMMA was not corrected!';
echo 
'' . $$lang '';
}

?> 

 RESULT   

JPEG 033 01.jpg

JPEG 033 01.jpg apr


JPEG 033 01 imagegammacorrect.jpg

JPEG 033 01 imagegammacorrect.jpg apr