Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

Histogram slike...

[es] :: PHP :: Histogram slike...
(Zaključana tema (lock), by Nemanja Avramović)

[ Pregleda: 2515 | Odgovora: 3 ] > FB > Twit

Postavi temu

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

Tiha Baba
student

Član broj: 182274
Poruke: 74
*.dynamic.sbb.rs.



Profil

icon Histogram slike...30.05.2008. u 10:04 - pre 192 meseci
Da li neko mozda zna neku funkciju u php ( algoritam, ili kod) ili u flashu koji moze da procita vrednosti piksela neke slike? Zeleo bih da napravim histogram neke slike.
 
0

Nemanja Avramović
Engineering Manager
MENU Technologies
Beograd, Srbija

Moderator
Član broj: 32202
Poruke: 4391
77.46.172.*

Sajt: https://avramovic.info


+46 Profil

icon Re: Histogram slike...30.05.2008. u 11:08 - pre 192 meseci
Google: "php image histogram"
Laravel Srbija.

[NE PRUŽAM PODRŠKU ZA PHP PREKO PRIVATNIH PORUKA!]
 
0

emranonline
Emran Bajrami
Tu i tamo

Član broj: 105825
Poruke: 179
82.114.75.*



+1 Profil

icon Re: Histogram slike...30.05.2008. u 11:15 - pre 192 meseci
Code:
<?php
$source_file = "test_image.jpg";

// histogram options

$maxheight = 300;
$barwidth = 2;

$im = ImageCreateFromJpeg($source_file);

$imgw = imagesx($im);
$imgh = imagesy($im);

// n = total number or pixels

$n = $imgw*$imgh;

$histo = array();

for ($i=0; $i<$imgw; $i++)
{
        for ($j=0; $j<$imgh; $j++)
        {
       
                // get the rgb value for current pixel
               
                $rgb = ImageColorAt($im, $i, $j);
               
                // extract each value for r, g, b
               
                $r = ($rgb >> 16) & 0xFF;
                $g = ($rgb >> 8) & 0xFF;
                $b = $rgb & 0xFF;
               
                // get the Value from the RGB value
               
                $V = round(($r + $g + $b) / 3);
               
                // add the point to the histogram
               
                $histo[$V] += $V / $n;
       
        }
}

// find the maximum in the histogram in order to display a normated graph

$max = 0;
for ($i=0; $i<255; $i++)
{
        if ($histo[$i] > $max)
        {
                $max = $histo[$i];
        }
}

echo "<div style='width: ".(256*$barwidth)."px; border: 1px solid'>";
for ($i=0; $i<255; $i++)
{
        $val += $histo[$i];
       
        $h = ( $histo[$i]/$max )*$maxheight;

        echo "<img src=\"img.gif\" width=\"".$barwidth."\"
height=\"".$h."\" border=\"0\">";
}
echo "</div>";
?> 
 
0

Tiha Baba
student

Član broj: 182274
Poruke: 74
*.dynamic.sbb.rs.



Profil

icon Re: Histogram slike...30.05.2008. u 11:38 - pre 192 meseci
Hvala...
 
0

[es] :: PHP :: Histogram slike...
(Zaključana tema (lock), by Nemanja Avramović)

[ Pregleda: 2515 | Odgovora: 3 ] > FB > Twit

Postavi temu

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.