Recent comments

Reply to: cam_mul array to Temperature and Tint and back   8 years 6 months ago

rgb_cam is [3][4] matrix, while pre_mul are [4] WB multipliers.

Reply to: cam_mul array to Temperature and Tint and back   8 years 6 months ago

Am I right to think that rgb_cam is filled with the values of pre_mul?

Thanks,
Sylvain.

Reply to: Using Unprocessed raw data for OpenCV   8 years 6 months ago

Bayer images contains only one color channel information per pixel (each pixel is red or green or blue).
To get full-colored image from raw bayer data one need to
1) decode bayer (one component per pixe) data
2) do demosaic (de-bayer) so:
- apply white balance
- interpolate color data for missing color values
- convert to output color space
- do gamma correction.

In LibRaw this is made by this call sequence:
open_file() ; // read image metadata
unpack(); // decode bayer data
dcraw_process(); // white balance, color interpolation, color space conversion
dcraw_make_mem_image(); // gamma correction, image rotation, 3-component RGB bitmap creation

Reply to: Using Unprocessed raw data for OpenCV   8 years 6 months ago

Thanks,

I had finally some rawdatas but, it wasn't what i expected. It seems that i have a monochromous picture only raw_image is filled how can i acces the raw data without processes ?

Because i've always worked with ppm and pgm pictures, for that projecti needd to use my .NEF in order to make some deep image processing on it with OpenCV. I'd like to get frow libraw a Matrix (Height x Width x Channels (here 3)) to put it in OpenCV and start to process the images.

Really thanks again !

Bdaniel

Reply to: .rawdata.raw_image and .image after unpack()   8 years 6 months ago

Alright Alex, thank you for these precisions, they are very helpful.

Reply to: .rawdata.raw_image and .image after unpack()   8 years 6 months ago

quote from libraw_cxx:

    if (O.ca_correc >0 ) {cablue=O.cablue; cared=O.cared; CA_correct_RT(cablue, cared);}
    if (O.cfaline >0 ) {linenoise=O.linenoise; cfa_linedn(linenoise);}
    if (O.cfa_clean >0 ) {lclean=O.lclean; cclean=O.cclean; cfa_impulse_gauss(lclean,cclean);}

CA_correct_RT() - is for demosaic pack GPL3, backported code from RawTherapee, chromatic abberration corrector.
cfs_linedn() - some kind of de-banding by high frequency filtering, again from Emil Martinec/RawTherapee/GPL3
cfa_impulse_gauss() - out of range pixels cleaning, same source/copyright

All three was contributed by RawTherapee in 2011.

LibRaw contribution policy is very simple
1) we accept *all* contributed code
2) the default settings are 'not used'
3) no extensive testing, just test that output image is not completely damaged

The same true for dcraw_process() itself.
Our "mission" is to decode RAW data and metadata. We're happy if user (developer) interaction with LibRaw ends just after unpack()/unpack_thumb() calls and all postprocessing is done by calling application. Standard postprocessing is very similar to dcraw (as dcraw_process() implies), it is not fast and not high quality.

Reply to: .rawdata.raw_image and .image after unpack()   8 years 6 months ago

Ok, that addresses wf_debanding(), thanks.

What about the cfaline / linenoise parameters, 1st block, with:

int cfaline; float linenoise;
Line noise (banding) reduction.
positive value turns this feature on (default: off).
linenoise - amount of reduction. Useful range is 0.001 to 0.02. Default value is 0.0

It's used for the same purpose apparently. Is that directly coming from dcraw? You didn't play with it either? Any idea if that's meant to affect things for unpack() or for raw2image()/dcraw_process()/dcraw_make_mem_image()?

I'll try to reverse-engineer this a bit but would be great to have any additional information on what your source code does with this if you have it hanging around. The code is quite... dense on that level!

Reply to: .rawdata.raw_image and .image after unpack()   8 years 6 months ago

wf_debanding() is contributed to LibRaw by one of our users.
I've never used it in real processing, just several experiments several years ago. So, try to play with parameters yourself

Reply to: .rawdata.raw_image and .image after unpack()   8 years 6 months ago

Hi there,

Made some progress thanks to your explanations. I can play with the color channels and display the results of some personal post-processing. Very nice.

I wanted to ask you some more details on what "banding / debanding" does? In your documentation, I read this for Structure libraw_rawdata_t: holds unpacked RAW data:

int cfaline; float linenoise;
Line noise (banding) reduction.
positive value turns this feature on (default: off).
linenoise - amount of reduction. Useful range is 0.001 to 0.02. Default value is 0.0 i.e. not clean anything.

(...)

int wf_debanding; float wf_deband_treshold[4];
wf_debanding: 1 turns on banding suppression (slow!), 0 turns it off.
wf_deband_treshold[] - per channel debanding thresholds.

I'm reading some general stuff about banding in general, I understand the noise pattern that is targeted. Could you explain in which respect the first parameter (1st block) and the 2nd ones (2nd block) affect the image? They both deal with "banding", so it is unclear what each does.

In addition, do they affect the raw image right after unpack(), or does one, or both, affect only the post-processed one in imgdata.image? (after either raw2image() or dcraw_process())

Thanks

Reply to: Using Unprocessed raw data for OpenCV   8 years 6 months ago

Do you use bayer-matrix camera to test with?

If not, rawdata.raw_image will be NULL, while rawdata.color3_image or rawdata.color4_image is not

Reply to: .rawdata.raw_image and .image after unpack()   8 years 6 months ago

All clear! :-)

Will start implementing Libraw functions in my project (still at a very early, poorly documented and modest stage).
You can currently see it as "QtFits" in github: https://github.com/raphaelattie/QtFits.git
Dealing so far with FITS files, the name of the future app will of course change after implementing Libraw-dependent classes, thanks to which I will not just handle FITS files anymore.

Thanks

Reply to: .rawdata.raw_image and .image after unpack()   8 years 6 months ago

dcraw_make_mem_image() just copies values from image[] to separate memory array with
- gamma curve
- 16 to 8 bit correction (if requested; this is default)
- rotation.

It is that simple :)

UPD: so, yes, use it after dcraw_process()

Reply to: .rawdata.raw_image and .image after unpack()   8 years 6 months ago

That's good.

Does dcraw_make_mem_image() also perform:

- do white balance
- than bayer interpolation
- and other possible postprocessing such as denoise or highlight recovery

as dcraw_process()?

Just to be clear:

Do i invoke dcraw_make_mem_image() INSTEAD OF dcraw_process() or AFTER dcraw_process()?

Reply to: .rawdata.raw_image and .image after unpack()   8 years 6 months ago

I think, I need to describe processing stages in LibRaw (simplified case, bayer image)

1) open_file() - reads metadata (EXIF and makernotes)
2) unpack() - decodes file contents into imgdata.rawdata.raw_image.
COLOR() call is useful after that: to know what color has pixel at (row,col).

3) dcraw_process():
- do raw2image() internally, allocate imgdata.image[] and populate
imgdata.image[row*width+col[COLOR(row,col)] = rawdata.raw_image[(row+top)*raw_width+col+left]
- do white balance
- than bayer interpolation
- and other possible postprocessing such as denoise or highlight recovery
- than output color conversion and data scale

After that, image[row*width+col] has [0..2] components filled with RGB values and something in [3]

4) dcraw_make_mem_image() may be used to create 3-component bitmap (with gamma correction), in 8- or 16-bit per component to be written into TIFF/JPEG or displayed on screen..

That's all that simple :)

You may repeat steps 3 and 4 with different imgdata.params settings to get different renderings

Reply to: .rawdata.raw_image and .image after unpack()   8 years 6 months ago

If image has dcraw_processed() (so, bayer data interpolated), you possibly do not need COLOR():

image[row*iwidth+col][0..3] will contain Red, Green, Blue in 0..2 and some garbage (not-interpolated G2 or zero) in [3]

Reply to: .rawdata.raw_image and .image after unpack()   8 years 6 months ago

See below instead, reply fields got too narrow...

Reply to: .rawdata.raw_image and .image after unpack()   8 years 6 months ago

Can you confirm the following code, for the usage of COLOR():

In image after dcraw_processed, to get the color of pixel at, e.g., (10, 3):

int row = 3;
int col = 10;
int iwidth = rawProcess.imgdata.sizes.iwidth;
int color value = rawProcess.imgdata.image[iwidth*row + col][COLOR(row, col)];

The row and col variables in image[iwidth*row + col] are the same expected in COLOR(row, col), is that correct?

Reply to: .rawdata.raw_image and .image after unpack()   8 years 6 months ago

Excellent, useful information! Thanks! Will post soon on the other forum topic the github link for the software (opensource of course)

Raphael

Reply to: .rawdata.raw_image and .image after unpack()   8 years 6 months ago

To extract one channel only, there is several ways
1) extract it from raw_image: find 1-st green component (using COLOR) coordinate in (0,0)-(1,1) square and than go from pixel to pixel with +2 increment in both directions
2) do raw2image with params.half_size
It will create half-sized image[] array with all 4 components are non-zero (because each bayer 2x2 square will go into one image[] pixel)
Than use [1] plane from image

Reply to: .rawdata.raw_image and .image after unpack()   8 years 6 months ago

Ok, I see dcraw_make_mem_image() in documentation, that's good, I will use it.

I might need to do coaligmnent of series of images with just, say, their green component.
So I need to just extract a bitmap of just one of the three RGB components of the demosaiced image, what function do you recommend to use?

Reply to: .rawdata.raw_image and .image after unpack()   8 years 6 months ago

This is demosaiced, white balanced, brightness adjusted, not rotated (!) image with linear gamma.

If you wish to get RGB bitmap (8 or 16 bit) with gamma applied and without extra (4th) component. use dcraw_make_mem_image() call.

Reply to: .rawdata.raw_image and .image after unpack()   8 years 6 months ago

After dcraw_process, image[][] contains demosaiced data? only 3-values RGB and not 4-values-RGBG, is that correct?

After dcraw_process(), if I do:
color value = image[pixel number][COLOR(row,col)] and I get... interpolated color?

Thanks

Reply to: .rawdata.raw_image and .image after unpack()   8 years 6 months ago

color value = image[pixel number][COLOR(row,col)], indeed, but it is not intended to use this way.

If one uses dcraw_process(), he will get image[] with interpolated colors after this call.
If one uses own processing, he hardly need 4-component image[] array.

raw2image is *compatibility layer* for some programs created to use with Libraw pre-0.15 (separate raw_image and image was introduced in version 0.15).

Reply to: .rawdata.raw_image and .image after unpack()   8 years 6 months ago

For bayer images, COLOR is just FC()
For fuji (SuperCCD, X-Trans) it is not

Reply to: .rawdata.raw_image and .image after unpack()   8 years 6 months ago

Thank you for these caveats. I noticed the need of using the user_black, user_cblack.

I notice the use of COLOR() is somehow same as using FC(), right? The latter is used in raw2image() apparently.
I haven't go through those functions yet. COLOR() is not documented so can you say a bit more about how to use this? I had a look in libraw.h
You wrote:

int COLOR(int row, int col) { return libraw_internal_data.internal_output_params.fuji_width? FCF(row,col):FC(row,col);}

If COLOR(row, col) gives a color value at pixel(2,2), that value must be in some color table, right? Where/how do I know which color table this COLOR() output value corresponds to?

Or did you mean, more simply, that COLOR(row,col) is meant to be used like this:

colorValue at pixel (2,2) = imgdata.image(COLOR(row,col)) ?

which would just consist in converting 2D coordinates in the 1D buffer index.

Pages