This is a copy of my forum post because I think more people read the list
than the forums. This is my function to read each pixel of a greyscale image
into a vector:
Starting on line 79: *Code:*
int ReadPGM::readImage(char *filename, vector<double> &pixelData) {
Magick::Image image;
image.read(filename);
Magick::Pixels view(image);
int x = view.x; //testing
MagickLib::PixelPacket *pixels = view.getConst(view.x, view.y,
view.columns, view.rows);
//TODO: if there's an error, return -1
for (unsigned int row=0; row < view.rows; row++) {
for (unsigned int col=0; col < view.columns; col++ ) {
Magick::Color color(pixels[row * view.rows + col]);
pixelData[row * view.rows + col] =
Magick::Color::scaleQuantumToDouble(color.blueQuantum());
cout << pixels[row][col];
}
cout << endl;
}
return 1;
}
These are the errors I'm getting:
*Errors:*
g++ -I/sw/include -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"ReadPGM.d"
-MT"ReadPGM.d" -o"ReadPGM.o" "../ReadPGM.cpp"
../ReadPGM.cpp: In member function 'int ReadPGM::readImage(char*,
std::vector<double, std::allocator<double> >&)':
../ReadPGM.cpp:83: error: argument of type 'int (Magick::Pixels::)()const'
does not match 'int'
../ReadPGM.cpp:84: error: no matching function for call to
'Magick::Pixels::getConst(<unknown type>, <unknown type>, <unknown type>,
<unknown type>)'
/sw/include/Magick++/Pixels.h:37: note: candidates are: const
MagickLib::PixelPacket* Magick::Pixels::getConst(int, int, unsigned int,
unsigned int)
../ReadPGM.cpp:88: error: invalid use of member (did you forget the '&' ?)
../ReadPGM.cpp:89: error: invalid use of member (did you forget the '&' ?)
../ReadPGM.cpp:90: error: invalid use of member (did you forget the '&' ?)
../ReadPGM.cpp:91: error: invalid use of member (did you forget the '&' ?)
../ReadPGM.cpp:92: error: no match for 'operator[]' in '*((+(row * 8u)) +
pixels)[col]'
../ReadPGM.cpp:83: warning: unused variable 'x'
This is the method I gleaned from reading the Pixel.h documentation and
example, but there's probably a better way of doing it...? Any enlightenment
appreciated.
_______________________________________________
Magick-users mailing list
[email protected]
http://studio.imagemagick.org/mailman/listinfo/magick-users