in reply to Re^2: How to Parse Network Data Graph
in thread How to Parse Network Data Graph
#!/usr/bin/perl use strict; use warnings; use Imager; # assumes a rgba image ( with alpha ) # otherwise use rgb instead of rgba my $image_source = shift @ARGV; my $image = Imager->new; $image->read( file => $image_source ) or die "Cannot load $image: ", $image->errstr; my $width = $image->getwidth(); my $height = $image->getheight(); print "Image dimensions: height = $height, width = $width\n"; # only grab some pixels on line 10 # for the whole image iterate over $width and $height my $x = 10; foreach my $y ( 10 .. 15 ) { my $color = $image->getpixel( x => $x, y => $y ); my ( $r, $g, $b, $a ) = $color->rgba(); print " shade = $r, $g, $b\n"; }
|
|---|