in reply to Extracting pixel values

You've been given a few excellent answers to your question already, but I'd like to suggest that if you're manipulating images, you might want to do so in a vector sort of way. Check out PDL from CPAN or the PDL home page if you haven't already.