<?php
## 이미지 밝기 측정(스펙트럼분석)
$fname = $_SERVER['argv'][1];
if(file_exists($fname)) exit(1);
$im = imagecreatefromjpeg($fname);
$maxx = imagesx($im);
$maxy = imagesy($im);
$t = array();
for($y=0; $y<$maxy; $y++)
{
for($x=0; $x<$maxx; $x++)
{
$index = imagecolorat($im,$x,$y);
list($r,$g,$b,$alpha) = array_values(imagecolorsforindex($im,$index));
$br = sprintf('%.4f',($r+$g+$b)/3);
//echo "$x,$y = $br\n";
$t[$x] += $br;
}
}
foreach($t AS $x=>$v)
{
printf("%d\t%.4f\n",$x,$v/$maxy);
}
exit(0);
?>
|