I'm not sure exactly what you mean by "pen"? But assuming you mean palette index, then this will get you started.
It takes an image name as it's command line argument and outputs a table showing the palette indexes, the rgb values at those indexes and the count of pixels using that index. It will be easy to modify to just display the index/rgb of a particular pixel:
#! perl -slw
use strict;
use GD;
my $img = GD::Image->new( $ARGV[0] ) or die $!;
my %palette;
my( $x, $y ) = $img->getBounds;
for my $yi ( 0 .. $y ) {
++$palette{ $img->getPixel( $_, $yi ) } for 0 .. $x;
}
for my $i ( sort{ $a <=> $b } keys %palette ) {
printf "index:%3d (%02x:%02x:%02x) n:%d\n",
$i, $img->rgb( $i ), $palette{ $i };
}
__END__
C:\test>imgInspect.pl v3d_usb_perf.gif
index: 0 (ff:ff:ff) n:274410
index: 1 (00:00:7f) n:4909
index: 2 (7f:7f:7f) n:80
index: 3 (00:00:ff) n:14025
index: 5 (3f:3f:3f) n:2390
index: 6 (00:ff:00) n:12507
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
|