Hi,
I was wondering if its possible to activate the tiff lossless compression and change the order of the bands. Right now we are interested to have the created tiff in BGR order instead or RGB. So the metadata of tiff would have to be changed as well.
We can of course change the order by exchanging the blue and red channel before the tiff creation but the tiff metadata is not changed accordingly obviously. Is there any way of doing that by activating a flag or something ?
This is useful for us for our remote sensing application since we want the bands to appear from the shortest to the highest wavelength.
Thanks in advance.
Greg
LibRaw' tiff writer is very
LibRaw' tiff writer is very simplified.
Use LibRaw::dcraw_make_mem_image(): https://www.libraw.org/docs/API-CXX.html#dcraw_make_mem_image to create in-memory RGB data array, than write it to preferred file format (e.g. tiff) using preferred library (e.g. libtiff) with preferred options.
-- Alex Tutubalin @LibRaw LLC
Alright thank you. So no easy
Alright thank you. So no easy way except using an external library then. Also I wanted to ask. What exactly is the difference between the RawProcessor.imgdata.image pointer obtained after dcraw_process() and dcraw_make_mem_image(). Is there a memory copy done or is it the same pointer ?
imgdata.image is 4-component
imgdata.image is 4-component (per pixel) array: https://www.libraw.org/docs/API-datastruct.html#libraw_data_t
dcraw_make_mem_image will create 3-component (and gamma corrected) array): https://www.libraw.org/docs/API-datastruct.html#libraw_processed_image_t
(I also suggest to read docs and samples source code)
-- Alex Tutubalin @LibRaw LLC
Thanks again for the
Thanks again for the information. So except for the difference in size in one case the gamma correction and some other processes occurs when the tiff is created (with dcraw_process() ) and dcraw_make_mem_image() really produces the final processed pixel data.
image[][4] is used for both
image[][4] is used for both intermediate results and for final result.
After dcraw_proces() is called,
image[i][0..2] contains final image in 16-bit and in linear space for i-th pixel
image[i][3] contains some garbage (not used intermediate results, etc).
Also, image[] is not rotated (if rotation is set via metadata or via user_flip)
make_mem_image prepares final result: 3 components per pixel, gamma corrected (according to imgdata.params.gamm[]), 8 or 16 bit (according to params.output_bps)
-- Alex Tutubalin @LibRaw LLC
That's very useful. Thanks
That's very useful. Thanks for the info.