0

Using CImg; I'll keep this quick and simple.

CImg<float> i = *spectralImages->at(currentImage);
disp.display(i);
float* f = i.data();

disp is displaying a black image despite the fact that stepping through *(f), *(f+1), *(f+2), etc. is retrieving the correct numbers (255.0, 245.0, etc.)

I've been working on this all day. Is there a quirk with CImg that I'm missing?

EDIT: Saving the file as a BMP seems to make the correct result, so there's just an issue with drawing it.

ThatSnail
  • 67
  • 2
  • 12

1 Answers1

0

If your CImg image contains only a single value, or several equal values, the default display will display them as black images, because of the normalization applied to the pixel values for the display. As CImg is able to manage any type of images (including float-valued), it always normalize the pixel values in [0,255] for the display (it does not change the pixel value in your object of course, it just normalizes them internally for its display). So if your image has a single pixel values, the normalization will always result to '0', hence the black image as a result.

That means you probably didn't construct your CImgDisplay disp with the right pixel normalization argument (by default, it is enabled). disp should be constructed like this :

CImgDisplay disp(100,100,"my display",0);

to disable the default normalization of pixel values.

bvalabas
  • 241
  • 1
  • 1