> 16) & 0xFF; $g = ($rgb >> 8) & 0xFF; $b = $rgb & 0xFF; $luminance_running_sum = (0.30 * $r) + (0.59 * $g) + (0.11 * $b); return $luminance_running_sum; } function histogramme($file){ $key = 0; $tab = array(); $x_dimension = 0; $y_dimension = 0; $image = 0; $x = 0; $y = 0; //initialise le tableau (au cas ou il est des trous pour certaines valeurs) $tab=array_fill(0, 255, '0'); $image = imagecreatefromjpeg($file); $x_dimension = imagesx($image); $y_dimension = imagesy($image); for ($x = 0; $x < $x_dimension; $x++) { for ($y = 0; $y < $y_dimension; $y++) { $key = pix_luminence($x,$y,$image); $tab[$key]++; } } // trie le tableau par ordre croissant des valeurs cles (Pas forcément nécessaire) ksort($tab); return $tab; } $tab = histogramme("panneau.jpg"); echo"
";
echo"
";
echo "