Home > Net >  how to output float to tiff using CImg?
how to output float to tiff using CImg?

Time:07-25

I'm trying to have float values in a .tiff file. The values in display are fine, but once on disk, it is unsigned short.

#include<X11/Xlib.h>
#include "CImg.h"
#define cimg_use_tif

using namespace cimg_library;

int main()
{
    CImg<float> imgFloat(640, 400);

    for(int i=0; i<640; i  )
        for(int j=0; j<400; j  )
            imgFloat(i,j) = float(i*640 j)/10000;

    imgFloat.save_tiff("V_float.tiff"); // cant get anything but unsigned short in the actual output

    imgFloat.display();

    return(0);
}

CodePudding user response:

You need:

#define cimg_use_tif

before (i.e. above)

#include "CImg.h"

Or actually, preferably define it on the compilation command-line:

g   -D cimg_use_tif ...
  • Related