greyscale EXR writing, Magick++
Posted: 2015-11-26T07:27:41-07:00
I've got data captured from a machine vision camera in memory, which is easiest stored as a float image and ideally saved in a suitable HDR format such as EXR. The data is greyscale however, and I'm finding that when I save the image with Magick++ it gets saved as RGB. Any help would be appreciated to force this to save as single channel exr file.
This is a very basic code sample that produces the behaviour:
And this shows identify as run on the output file:
person@machine:~/src$ identify test.exr
test.exr EXR 240x240 240x240+0+0 16-bit RGB 350KB 0.000u 0:00.000
This is a very basic code sample that produces the behaviour:
Code: Select all
#include <Magick++.h>
#include <vector>
int main(void)
{
// fake image for testing. Equivalent to my data - float array with known width/height
unsigned w,h;
w = 240;
h = 240;
std::vector<float> i;
i.assign( 240*240, 0.5 );
// float array directly into magick image
Magick::Image mimg(w, h, "I", Magick::FloatPixel, &i[0]); // 'I' for single channel intensity data, right?
mimg.type( Magick::GrayscaleType ); // didn't seem to help at all.
mimg.write("test.exr");
}
person@machine:~/src$ identify test.exr
test.exr EXR 240x240 240x240+0+0 16-bit RGB 350KB 0.000u 0:00.000