get gray values with magick++

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
mrjvak

get gray values with magick++

Post by mrjvak »

Hello,
I have read a gray pgm-file into the Image object. Can anyone please supply me with an example of how to put the gray values into a vector<int> for example!

is it going to be someting like this:
vector<int> vec;
for( x=0; x<width; x++)
for( y=0; y<height; y++)
vec.push_back( image.get(x,y) )

put get returns a PixelPacket, and how do I get the gray value from that?

many thanks
J
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Post by magick »

If the image is already gray, just grab the redQuantum() of your pixel for the gray intensity.
mrjvak

Post by mrjvak »

ok many thanks,
but please don't take for granted I know the concepts here, I am trying to learn. I suppose I should use readPixels() in order to use QuantumTypes. BUt where are they documented maybe they are not part of magick++ ?
Post Reply