Getting pixel coordinates of individual pixels in an image

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
slimprize
Posts: 2
Joined: 2012-08-01T09:07:51-07:00
Authentication code: 15

Getting pixel coordinates of individual pixels in an image

Post by slimprize »

Hi all,
How do I get the x and y coordinates and the brightness of all the pixels that comprise an image? Is the exportPixels method in the magick wand the way to go? I need to get these values for each pixel. I have a program in ansi C to which I need to pass these coordinates. I can however use C++ too since I am probably going to convert that program to c++.

I have also seen the commandline interface where the convert utility looks promising. However, I cannot tell what parameters to use for this utility.

My program will run chiefly on Linux (Ubuntu) but I plan to run it on the rasbperry pie too.
Pranav
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Getting pixel coordinates of individual pixels in an ima

Post by fmw42 »

In command line, see the txt: format for output. It has color values and x,y coordinates.

What do you mean by "brightness"? Do you just have a grayscale image? Brightness is usually associated with the B channel of HSB colorspace. Similarly Lightness is the L channel of HSL colorspace. When converting to grayscale you get an intensity from a given combination of R/G/B, which is also the Y channel of YUV/YIQ/YCbCr colorspaces.

see http://www.imagemagick.org/Usage/files/#txt

convert image txt:

Sorry I am not sure how you would express that in one of the IM APIs.
slimprize
Posts: 2
Joined: 2012-08-01T09:07:51-07:00
Authentication code: 15

Re: Getting pixel coordinates of individual pixels in an ima

Post by slimprize »

[quote="fmw42"]In command line, see the txt: format for output. It has color values and x,y coordinates.
PL] Many thanks. The txt file is what I needed.
What do you mean by "brightness"? Do you just have a grayscale image? Brightness is usually associated with the B channel of HSB colorspace. Similarly Lightness is the L channel of HSL colorspace. When converting to grayscale you get an intensity from a given combination of R/G/B, which is also the Y channel of YUV/YIQ/YCbCr colorspaces.
PL] I am converting to grayscale so I am using the average of RGB values.
see http://www.imagemagick.org/Usage/files/#txt
PL] Yes and this helpped.

Pranav
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Getting pixel coordinates of individual pixels in an ima

Post by anthony »

Topic split to...
"colorspace: gray channel handling"
viewtopic.php?f=1&t=21608
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply