Kevin Mudrick on 11 Dec 2003 09:03:02 -0500 |
On Wed, Dec 10, 2003 at 11:59:40PM -0500, Jeff Abrahamson wrote: > I want a list of pixel values by coordinate. I don't want to spend > hours doing this. > > Any thoughts on how to pull this off? Perl::Magick comes to mind. I did something similar on a project not too long ago, where I needed to figure out if an image was mostly dark, or mostly light. The following snippet might help, checkout http://www.imagemagick.org/www/perl.html for more details: ## Open File my $image = new Image::Magick; $image->Read($file); $image->Set( magick => 'rgb' ); ## Get RGB pixels my @pixels = unpack "C*", $image->ImageToBlob(); my ($width, $height) = $image->Get('columns','rows'); foreach my $p (1..$width*$height) { my ($r,$g,$b) = splice @pixels, 0, 3; my $colorvalue = $r+$g+$b; } What I was doing was slightly different (Reducing to black and white, checking to see if colorvalue was < 382, which would be dark, > 382 would be light), but the above might be helpful. -kevin -- kevin mudrick // kevin@furhurts.com gpg fingerprint: 5E00 FCDF 79E4 2FEB 629C AA16 2E0B B526 8DAC 6BEA Attachment:
signature.asc
|
|