#include <Magick++.h>
#include <iostream>
using namespace std;
dest.size(Magick::Geometry(w,h));
dest.depth(8);
for (int i=0; i<h; i++) {
Magick::PixelPacket *packet = dest.setPixels(0,i,w,1);
dest.readPixels(Magick::RGBQuantum,(
unsigned char *)(&src.
pixel(0,i)));
}
dest.syncPixels();
}
Magick::Geometry g = src.size();
int h = g.height();
int w = g.width();
src.depth(8);
for (int i=0; i<h; i++) {
Magick::PixelPacket *packet = src.getPixels(0,i,w,1);
src.writePixels(Magick::RGBQuantum,(
unsigned char *)(&dest.
pixel(0,i)));
}
src.syncPixels();
}
int main(
int argc,
char **argv)
{
try {
for (
int i=0; i<yimg1.
width(); i++) {
for (
int j=0; j<yimg1.
height(); j++) {
}
}
printf("Creating a YARP image, and showing the value of one pixel\n");
printf(
"rgb %d %d %d\n", pixel1.
r, pixel1.
g, pixel1.
b);
copyImage(yimg1,mimg);
printf("Copying image to Magick, and tracking the value of the same pixel\n");
Magick::Color c = mimg.pixelColor(10, 20);
printf("rgb %d %d %d\n", c.redQuantum(),c.greenQuantum(),c.blueQuantum());
printf("Saving image as test.gif\n");
mimg.write("test.gif");
copyImage(mimg,yimg2);
printf("Copying image back to YARP, and tracking the value of the same pixel\n");
printf(
"rgb %d %d %d\n", pixel2.
r, pixel2.
g, pixel2.
b);
}
catch( Magick::Exception &error_ )
{
cout << "Caught exception: " << error_.what() << endl;
return 1;
}
return 0;
}
T & pixel(size_t x, size_t y)
size_t width() const
Gets width of image in pixels.
void resize(size_t imgWidth, size_t imgHeight)
Reallocate an image to be of a desired size, throwing away its current contents.
size_t height() const
Gets height of image in pixels.
yarp::rosmsg::sensor_msgs::Image Image
int main(int argc, char *argv[])