hdrgen's response curve file

Hi list,

to compare the response curve as determined by hdrgen with the one by
pfstools, I would like to plot it using gnuplot. To do so, I would like
to know what the six values per line are. I guess with that info, I
should be able to plot a run using Paul E. Debevec's and Jitendra
Malik's algorithm as published.

I guess that the lines correspond to the sensor's channels, but
everything else is unknown to me right now...

Lars.

Or is it just a*x^4+b*x^3+c*x^2+d*x+e ?

What is the first (integer) column then?

Thank you, Lars.

That's correct, Lars. I like to keep my file formats as obvious as possible. The first integer is merely the maximum degree of the equation, which should be 4 in this case. It can be as low as 2 and as high as 5 out of hdrgen.

The first line is for the red channel response, the second is green, and the third is blue.

-Greg

···

From: "Lars O. Grobe" <[email protected]>
Date: June 10, 2008 4:44:26 AM PDT

Or is it just a*x^4+b*x^3+c*x^2+d*x+e ?

What is the first (integer) column then?

Thank you, Lars.

I like to keep my file formats as obvious as possible.

While in general this works, in my case it was not obvious enough - at
least I had to ask :slight_smile: Thank you for the explanation.

Now, I see that I get a function for each channel. What I guess is that
the function is sensor response ( picture luminance ), is this
assumption true?

What I actually would like to do is, for a range of picture luminances,
plot a graph of the sensor output using the polynomal as given by
hdrgen, and overlay it with the response curve as written by pfstools. I
am using both tools at the moment and would like to see the differences
for the given range of luminances caused by the different algorithms.

Is this possible at all?

Is there any kind of unit related to the sensor response values?

TIA&CU Lars.

Hi Lars,

There are no units for the sensor response function, which isn't luminance, but individual responses for the three color channels (red, green, and blue). Sadly, even these are mixed up, since there is a non-linear (and unknown) color transform between the sensors RGB and the image RGB values.

BTW, most of the accuracy from HDR sequences is unrelated to the derived camera response. Rather, it's from the proper combining of closely-spaced exposures with accurately reported ISO, speed, and aperture. If those things are not reported correctly by the camera, then all bets are off. Other things that undermine accuracy are lens flare (trying to measure a dark area near a bright one or with direct light entering the camera), and vignetting for wide apertures. Absolute response is also a big issue, which is why you should probably have at least one luminance reading from each captured scene if the actual values (and not just relative values) matter to you.

-Greg

···

From: "Lars O. Grobe" <[email protected]>
Date: June 10, 2008 11:49:25 PM PDT

I like to keep my file formats as obvious as possible.

While in general this works, in my case it was not obvious enough - at
least I had to ask :slight_smile: Thank you for the explanation.

Now, I see that I get a function for each channel. What I guess is that
the function is sensor response ( picture luminance ), is this
assumption true?

What I actually would like to do is, for a range of picture luminances,
plot a graph of the sensor output using the polynomal as given by
hdrgen, and overlay it with the response curve as written by pfstools. I
am using both tools at the moment and would like to see the differences
for the given range of luminances caused by the different algorithms.

Is this possible at all?

Is there any kind of unit related to the sensor response values?

TIA&CU Lars.

Hi Greg,

thank you for giving some insight on hdrgen...!

There are no units for the sensor response function, which isn't
luminance, but individual responses for the three color channels
(red, green, and blue). Sadly, even these are mixed up, since there
is a non-linear (and unknown) color transform between the sensors RGB
and the image RGB values.

I understood the graphs / curves that I see response dependant on
luminance? If I draw the curve as a graph, and I write "response" to the
y-axis, what is the label for the x-axis in this case?

BTW, most of the accuracy from HDR sequences is unrelated to the
derived camera response.

I can confirm this, as even the most awful response data gives only
slightly different results when taking pixel values from the generated
HDR, as far as I could experience :wink:

Rather, it's from the proper combining of
closely-spaced exposures with accurately reported ISO, speed, and
aperture. If those things are not reported correctly by the camera,
then all bets are off. Other things that undermine accuracy are lens
flare (trying to measure a dark area near a bright one or with direct
light entering the camera), and vignetting for wide apertures.
Absolute response is also a big issue, which is why you should
probably have at least one luminance reading from each captured scene
if the actual values (and not just relative values) matter to you.

I have a fixed lense (no zoom etc), I am trying to correct for
vignetting, aperture is fixed, flare should not appear on the images
taken (rather uniform gradients), and I created a HDR of a known
calibrated light source under the same settings, allowing me to estimate
the factor between reported luminance from the HDR and "real" luminance
(according to the calibrated light source used). So I try to handle
these uncertainties. I wanted to document the differences in the tools
used, and one of the main differences between hdrgen and pfstools seams
to be the response-curve fitting. So it would be great to be able to
overlay the curves (six curves all in all, three channels for both tools
each). But I do not really know how the function is applied to which
datasets.

CU Lars.

Hi Lars,

Sorry for the poor response to your previous question. I was a bit confused by it. This is clearer:

I understood the graphs / curves that I see response dependant on
luminance? If I draw the curve as a graph, and I write "response" to the
y-axis, what is the label for the x-axis in this case?

In fact, the response curve is reversed. The independent axis (x) is "sensor output" scaled from the 0-255 in the image to a 0-1 range for the recorded polynomial. The dependent axis (y) produced by the polynomial should be proportional to luminance, but it needs to be multiplied by the appropriate scale factors taken from the ISO, speed, aperture, and calibration.

I hope this makes better sense.

-Greg

Hi Lars and Greg,
Very interesting discussion from a long time ago,
I think it is still the response function is a bit unclear for me,

Assuming I have the following information calculated by hdrgen as response function:

3 1.3236 -0.715269 0.394196 -0.00252275
3 1.32927 -0.719204 0.394354 -0.00442475
3 1.23812 -0.581367 0.344069 -0.000819191

I understand that the first, second, and third lines are the coefficients of the polynomials of the RGB response function, respectively.
in this example, are the following the right polynomials? Is the order of coefficients applied correctly? I am asking this because I am not getting the same curves by any ordering of the coefficients as the ones I saw in this tutorial paper by C.Pearson ,but the graphs I draw do not look like these ones in this paper, I guess I am missing something.
I’ve put the graphs below,
Can you please make it clearer?

R= 1.3236 -0.715269x+0.394196xˆ2-0.00252275xˆ3
G=1.32927 -0.719204x+0.394354xˆ2-0.00442475xˆ3
B=1.23812 -0.581367x+0.344069xˆ2-0.000819191xˆ3

Kind regards,
Nima

Looks like you have the coefficient order reversed. It is different between Photosphere’s preferences file and hdrgen. In hdrgen, the highest order coefficient is first on each line, so you should use:

R= 1.3236x^3 -0.715269x^2 +0.394196x -0.00252275
G= 1.32927x^3 -0.719204x^2 +0.394354x -0.00442475
B= 1.23812x^3 -0.581367x^2 +0.344069x -0.000819191

Cheers,
-Greg

1 Like

Dear @Greg_Ward ,

Working with hdrgen, I am wondering how reasonable is to have a response curve of a second-degree polynomial. My camera sometimes has 2 degrees of a polynomial and am not sure to find the average RC, does it make sense to find the average of those?

Thanks,

A second-degree fit is not unheard of. I don’t know the best way to average multiple curve results, and I don’t generally recommend it.

Best,
-Greg

2 Likes

A side-note: I think that since current cameras can commonly provide 14bit or 16bit raw data, that is also usually linear over most of the pixel range, one should think twice before reconstructing the response curve from jpg images. My recent work with HDR was all based either on 16bit tiffs converted to HDR (and stackes with e.g. pcomb when necessary) or direct access to sensor data. Of course there may be cases when you just dont have access to raw data (at least before gamma adjustment), but I would consider to address image acquisition first and only then look into compensating for a non-linear process.

Best, Lars.

1 Like

Interesting comment by Greg regarding the importance of ISO, speed and aperture

OpenCV uses a ‘Debevec’ algorithm that only requires reporting speed for each of the bracketed exposures. OpenCV: High Dynamic Range (HDR)

Does this suggest that the accuracy of this algorithm is unreliable for calculating absolute values of luminance even if ISO and aperture are kept constant for all exposures, but are not reported for consideration when generating the scale factors?

Yes, I believe so. Most HDR construction methods leave an uncontrolled scale factor, which is important for calibration in the case of photometry. The hdrgen tool and Photosphere estimate this calibration factor by considering the aperture and ISO as well, but an in situ luminance measurement is the best way to assure accuracy.

The fact that aperture and ISO are not included in OpenCV’s algorithm means the aperture must not change between exposures. This is recommended practice in any case, but some cameras if they are in auto-bracket mode will change the aperture during the sequence, so care is needed.

Cheers,
-Greg