retrieving R G B values from an image
Posted: 2019-09-20T06:20:14-07:00
I am using ImageMagick++ 6.9.10. I am trying to read an image and get the R, G, B values. In whichever way I try, I always get the same values for the green and blue channels. Below is a sample code that illustrates the problem:
Magick::Image img_one('test.jpg');
Magick::ColorRGB img_one_px(img_one.pixelColor(10, 10)); // can be any pixel location in the image
cout << img_one_px.red() << " " << img_one_px.green() << " " << img_one_px.blue() << endl;
Irrespective of the pixel we choose in the second line above, the code always prints the same value for green() and blue(). I feel this is a bug that needs fixing. Please correct me if I am going wrong somewhere.
Magick::Image img_one('test.jpg');
Magick::ColorRGB img_one_px(img_one.pixelColor(10, 10)); // can be any pixel location in the image
cout << img_one_px.red() << " " << img_one_px.green() << " " << img_one_px.blue() << endl;
Irrespective of the pixel we choose in the second line above, the code always prints the same value for green() and blue(). I feel this is a bug that needs fixing. Please correct me if I am going wrong somewhere.