Page 1 of 1

GetPixel failing

Posted: 2012-04-30T03:09:10-07:00
by magiotrope
I'm really puzzled

the "identify" command returns " JPEG 205x154 205x154+0+0 8-bit DirectClass 48KiB 0.000u 0:00.000" on the image, and it is a color photo I can see with lots of multicolored flowers.

when I read it into PerlMagick and iterate over every pixel, like this...

Code: Select all

for(my $i=1; $i<=$width; $i++) {
    for(my $j=1; $j<=$height; $j++) {
        my @rgb=$image->GetPixel($i,$j);
        $colors{join(',', @rgb)}++;
    }
}

print "\n unique colors : \n";

foreach $k (keys %colors) {
    print "\n $k : ", $colors{$k};
}
I get:
unique colors :
0.141176470588235,0.152941176470588,0.211764705882353 : 31570

for a black & white tiff I get only "1,1,1" (white)

What am I doing wrong?
thanks

Re: GetPixel failing

Posted: 2012-05-10T23:59:37-07:00
by anthony
The color values are normalized. That is they are floating point numbers in a 0 to 1 range. That is all.