I wanted to understand how I can save an image of type float
:
float * image;
Allocated in this way:
int size = width * height;
image = (float *)malloc(size * sizeof(float));
I tried using the CImg library, but does not accept float directly. Infact, i only use it to capture image to float, because I need only float images.
CImg<float> image("image.jpg");
int width = image.width();
int height = image.height();
int size = width*height
float * image = image.data();
How do I save this picture to float
from .jpg
or .bmp
readable. I thought to open a write buffer but not save me anything and I can not read from a file!
well, what you need is first of all to realize what you are tying to do. you are creating a pointer to float array
and then you're doing
which is double use of
image
that will cause a compiler error and a bad thing to do also if you could.now you should read on
CImg
here and see thatData()
returns a pointer to the first pixel of the image.now that we established all of that let's go to the solution: if you want to save the float array to a file use this example