read pixel value

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
waggs
Posts: 2
Joined: 2013-08-23T04:38:18-07:00
Authentication code: 6789

read pixel value

Post by waggs »

Is it possible to read the pixel value at any particular x,y pixel coordinate using IM?
If so, how?

cheers
waggs

ImageMagick 6.8.6-6 2013-08-08 Q16
iMac
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: read pixel value

Post by snibgo »

For example, to read the pixel from the in-built rose image at coordinate (40,50):

Code: Select all

convert rose: -format "%[pixel:p{40,50}]" info:
The result is: srgb(80,78,52)
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: read pixel value

Post by fmw42 »

see http://www.imagemagick.org/Usage/transform/#fx_escapes for more examples and discussion
waggs
Posts: 2
Joined: 2013-08-23T04:38:18-07:00
Authentication code: 6789

Re: read pixel value

Post by waggs »

Thanks both - does what I want.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: read pixel value

Post by anthony »

If you are wanting a lot of pixels and not just one, then outputing the image as a "txt:" file will be better.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply