Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Perl Image Analysis

by grep (Monsignor)
on Oct 04, 2006 at 19:31 UTC ( [id://576387]=note: print w/replies, xml ) Need Help??


in reply to Perl Image Analysis

I thought Image::Magick had a method to read a pixel color but, I could not find one. But GD does - The only problem, GD doesn't seem to handle TIF natively, so you may have to do a conversion to an uncompressed JPEG or PNG.

From the GD Docs:

$index = $image->getPixel(x,y) object method This returns the color table index underneath the specified point. + It can be combined with rgb() to obtain the rgb color underneath the + pixel. Example: $index = $myImage->getPixel(20,100); ($r,$g,$b) = $myImage->rgb($index);


grep
One dead unjugged rabbit fish later

Replies are listed 'Best First'.
Re^2: Perl Image Analysis
by LTjake (Prior) on Oct 04, 2006 at 19:43 UTC

    Or, perhaps they could use Imager. It has a getpixel method:

    my $color = $img->getpixel(x=>50, y=>70);

    ...and can read TIFF files (given the existence of libtiff).

    --
    "Go up to the next female stranger you see and tell her that her "body is a wonderland."
    My hypothesis is that she’ll be too busy laughing at you to even bother slapping you.
    " (src)

Re^2: Perl Image Analysis
by Koosemose (Pilgrim) on Oct 04, 2006 at 20:37 UTC

    Actually you were right, Image::Magick does have a method to query pixel color:

    $image->Get('Pixel[x,y]')

    It returns a scalar value containing a comma seperated list R,G,B,A. There's also $image->GetPixels(), but I've had some issues getting accurate color readings from it, though that's likely an error on my part.

    Just Another Perl Alchemist

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://576387]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2024-04-19 01:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found