我正在尝试从每个像素中获取 rgb。但是当我运行我的C++
代码时,我会在 shell 上看到类似这样的红色
55512
55255
55255
为什么它不是我预期的 0 到 255 之间的数字?
这是我的代码
Image image("image_test.jpg");
int w = image.columns();
int h = image.rows();
// get a "pixel cache" for the entire image
PixelPacket *pixels = image.getPixels(0, 0, w, h);
// now you can access single pixels like a vector
int row = 0;
int column = 0;
Color color = pixels[w * row + column];
for(row=0; row<h-1; row++){
for(column=0; column<w-1; column++){
Color color = pixels[w * row + column];
cout<<pixels[w * row + column].red;
image.syncPixels();
}
}
//image.syncPixels();
// write the image to file.
//image.write("test_modified.jpg");