in reply to Pixel by pixel reading of images

Thanks for your help - I'm now using Image::Magick. However, it was hard to come by the docs, so just to help anyone else passing this way...
use Image::Magick; my $IMimage = Image::Magick->new; $IMimage->Read($filename); $readval=$IMimage->Get('pixel['.$xcount.','.$ycount.']');
It doesn't appear to be documented on the Image Magick perl page... it returns "red,green,blue,alpha" (which might interface with a four-element array). All of the colours are 0..255

Replies are listed 'Best First'.
Re: Re: Pixel by pixel reading of images
by Mina (Acolyte) on Oct 08, 2001 at 07:36 UTC

    Hello,
    thank you for posting that - its certainly saved me - I've been running all over looking for something just like that.

    My problem happens to be that I need the graylevels, not the RGBA values.

    Would you, or anyone else, happen to know exactly how to retrieve that value for each pixel in my .pgm image using Image:Magick? I'm using the code posted above to get the RGB values, but I can't do anything with them really... Pointers to more Image::Magick documentations are welcome as well.

    Thanks,

    ~mina

      As merlyn alluded to above, you need to add an RGB to luminance conversion. There is no one right way to do this, but the one used in American TV broadcasting is:

         Luma (gray value) = 0.299*Red + 0.587*Green + 0.114*Blue

      Reference: Keith Jack, Video Demystified, 2nd Ed. (HighText Publications)