use GD::Simple; my $png = GD::Image->newFromPng('test.png'); my @sw; my ($width, $height) = $png->getBounds; for my $x ( 0 .. $width-1 ) { for my $y ( 0 .. $height-1 ) { $sw[$y].=getPixel($x,$y); } } sub getPixel { my $p; my ($index) = $png->getPixel($_[0],$_[1]); my ($r,$g,$b) = $png->rgb($index); if ($b>128 || $r>128) {$p=0;} else {$p=1;} return $p; }