Pages: [1]   Go Down

Author Topic: Making your DSLR show Linear Histogram  (Read 30017 times)

bansal98

  • Newbie
  • *
  • Offline Offline
  • Posts: 5
Making your DSLR show Linear Histogram
« on: December 31, 2007, 05:22:44 am »

As we know, the histogram shown on the LCD of a digital camera is based on the gamma-corrected jpeg image and not on the linear raw data. Since the raw files typically have an exposure latitude of one f-stop and the the blown out highlights can be recovered easily in the raw converter, we don’t want the in-camera histogram to treat this as over-exposure. Otherwise we’d be doing negative exposure compensation to get a pleasing in-camera histogram and thus losing valuable shadow detail.

It is easy to get your (Nikon) DSLR to show linear histogram by disabling the gamma correction using custom curves. I have written an article about this on my blog. I wanted to post the article in this thread but the html formatting was not proper.

I would be grateful if you could post your experiences with this technique. Thanks!!

Linear Histogram
Logged

John Sheehy

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 838
Making your DSLR show Linear Histogram
« Reply #1 on: December 31, 2007, 08:28:42 am »

Quote
It is easy to get your (Nikon) DSLR to show linear histogram by disabling the gamma correction using custom curves. I have written an article about this on my blog. I wanted to post the article in this thread but the html formatting was not proper.
[a href=\"index.php?act=findpost&pid=164174\"][{POST_SNAPBACK}][/a]

You also want to set the saturation to minimum as well, since in the process of making JPEGs, red values may be exaggerated far beyond what they really are in the RAW in red and oranges, and the greens can also be exaggerated in yellows.

When you get those blown out red flowers in a JPEG, for instance, the red may still be a stop or two from clipping in the RAW data.
Logged

bansal98

  • Newbie
  • *
  • Offline Offline
  • Posts: 5
Making your DSLR show Linear Histogram
« Reply #2 on: December 31, 2007, 08:46:08 am »

You are correct about the saturation settings. As a matter of fact, all the parameters should be set so that there is minimum tempering of raw data. That means:

Saturation - 0
Contrast - lowest value possible
Color Space - Biggest gamut (usually Adobe RGB)
Sharpening - lowest value possible
Logged

bjanes

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 3387
Making your DSLR show Linear Histogram
« Reply #3 on: December 31, 2007, 08:58:03 am »

Quote
When you get those blown out red flowers in a JPEG, for instance, the red may still be a stop or two from clipping in the RAW data.
[a href=\"index.php?act=findpost&pid=164193\"][{POST_SNAPBACK}][/a]

This can be handled by uploading a UniWB white balance curve to the camera. This sets the blue and red white balance multipliers to unity.
Logged

John Sheehy

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 838
Making your DSLR show Linear Histogram
« Reply #4 on: December 31, 2007, 09:14:23 am »

Quote
This can be handled by uploading a UniWB white balance curve to the camera. This sets the blue and red white balance multipliers to unity.
[a href=\"index.php?act=findpost&pid=164199\"][{POST_SNAPBACK}][/a]

That has nothing to do with what I said.  I understood that the natural WB of the camera was possible.  The fact is, two areas of equal red RAW luminance can be two stops apart, easily, in the JPEG, when one comes from a white and the other from a flower.  Channel scaling can not address that issue.
Logged

bjanes

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 3387
Making your DSLR show Linear Histogram
« Reply #5 on: December 31, 2007, 12:23:14 pm »

Quote
That has nothing to do with what I said.  I understood that the natural WB of the camera was possible.  The fact is, two areas of equal red RAW luminance can be two stops apart, easily, in the JPEG, when one comes from a white and the other from a flower.  Channel scaling can not address that issue.
[{POST_SNAPBACK}][/a]

Of course, I did not say that WB contributed to the clipping, but if the red channel is blown and the red multiplier is 1.8, there is a good chance that channel scaling for white balance contributed to the clipping. In your example, it is likely that the white subject and the red flower occupy different positions in the image, and would be less likely to show up in a luminance histogram, which keeps track of the pixel location in its calculations as explained by [a href=\"http://www.cambridgeincolour.com/tutorials/histograms2.htm]The Cambridge in Color Tutorial on histograms.[/url]
Logged

Panopeeper

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 1805
Making your DSLR show Linear Histogram
« Reply #6 on: December 31, 2007, 09:39:53 pm »

It is a misconception to attribute an important role to the non-linear transform (which is popularly but incorrectly called gamma correction) in the misleading character of the in-camera histogram.

The contributiong factors are whitebalance (the greatest factor by far), contrast, saturation, sharpness and the color space conversion; I can not quantify the last one.

The role of the transform function is restricted to the assessment of the magnitude of the difference between the right end of the actual histogram and the end of the range; however, this is constant (with any given camera). In other words, if the histogram ends at a certain distance from the right end of the range, then a fixed amound of exposure can be added. Although the choice of the color space does cause some difference, that is too small to be regarded for this purpose.

However, there is a bigger problem: one achieved a perfect exposure, starts the raw processor - and that reports clipping. The opposite too happens regularly, without people noticing it: the raw converter hides existing clipping.
Logged
Gabor

bansal98

  • Newbie
  • *
  • Offline Offline
  • Posts: 5
Making your DSLR show Linear Histogram
« Reply #7 on: January 01, 2008, 08:32:54 am »

Quote
It is a misconception to attribute an important role to the non-linear transform (which is popularly but incorrectly called gamma correction) in the misleading character of the in-camera histogram.

The contributiong factors are whitebalance (the greatest factor by far), contrast, saturation, sharpness and the color space conversion; I can not quantify the last one.
WhiteBalance being the greatest factor contributing to the histogram difference is a bit surprising to me. I did some experimentation around this in dcraw [it has an option to set the multipliers to 1 for all three colors (RGB)] and found that the gamma correction had much higher impact than uniWB.

Quote
The role of the transform function is restricted to the assessment of the magnitude of the difference between the right end of the actual histogram and the end of the range; however, this is constant (with any given camera). In other words, if the histogram ends at a certain distance from the right end of the range, then a fixed amound of exposure can be added. Although the choice of the color space does cause some difference, that is too small to be regarded for this purpose.
I did not understand this part. Can you please explain it in a bit more detail. Thanks!
Logged

bjanes

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 3387
Making your DSLR show Linear Histogram
« Reply #8 on: January 01, 2008, 09:58:32 am »

Quote
As we know, the histogram shown on the LCD of a digital camera is based on the gamma-corrected jpeg image and not on the linear raw data. Since the raw files typically have an exposure latitude of one f-stop and the the blown out highlights can be recovered easily in the raw converter, we don’t want the in-camera histogram to treat this as over-exposure. Otherwise we’d be doing negative exposure compensation to get a pleasing in-camera histogram and thus losing valuable shadow detail.

It is easy to get your (Nikon) DSLR to show linear histogram by disabling the gamma correction using custom curves. I have written an article about this on my blog. I wanted to post the article in this thread but the html formatting was not proper.

I would be grateful if you could post your experiences with this technique. Thanks!!

[{POST_SNAPBACK}][/a]

Manish,

Your article is very well written with excellent documentation, but I do not agree with your conclusion that a linear histogram is best for evaluation of exposure to the right, because everything is moved to the left in that type of histogram and it can be hard to read without a magnifying glass. This is shown in an article by [a href=\"http://www.adobe.com/digitalimag/pdfs/linear_gamma.pdf]Bruce Fraser.[/url]

Looking at the linear histogram, many people would give more exposure since the right of the histogram does not appear well filled out, whereas as the gamma encoded histogram demonstrates good exposure. Gamma encoding affects the mid tones, and the black and white points are not affected as shown by Bruce's gamma 2.2 curve. However, you have to look very carefully to see the white point, which hardly rises above baseline.

What is needed for using the histogram for setting exposure is one that accurately reflects the raw data, so that when clipping starts, it is shown on the histogram. Many cameras allow a certain degree of headroom, so that when the histogram is all the way to the right, the raw channels are short of clipping. This "protects" the highlights, but impedes exposure to the right. In this case, one could adjust the camera curve so that clipping and the appearance of the histogram are in agreement.

Bill
« Last Edit: January 01, 2008, 10:01:02 am by bjanes »
Logged

John Sheehy

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 838
Making your DSLR show Linear Histogram
« Reply #9 on: January 01, 2008, 10:59:32 am »

Quote
Manish,

Your article is very well written with excellent documentation, but I do not agree with your conclusion that a linear histogram is best for evaluation of exposure to the right, because everything is moved to the left in that type of histogram and it can be hard to read without a magnifying glass.

That's a very common complaint, but I really don't see the problem, if one's goal is ETTR.  Giving a lot of space to the top stop is crucial for determining how much more to expose the next shot.  Why would I care about the stuff scrunched up at the left side?  What decision is it going to affect?


Quote
This is shown in an article by Bruce Fraser.

Looking at the linear histogram, many people would give more exposure since the right of the histogram does not appear well filled out, whereas as the gamma encoded histogram demonstrates good exposure. Gamma encoding affects the mid tones, and the black and white points are not affected as shown by Bruce's gamma 2.2 curve. However, you have to look very carefully to see the white point, which hardly rises above baseline.
[a href=\"index.php?act=findpost&pid=164363\"][{POST_SNAPBACK}][/a]

And the simple solution is to give more weight in the y axis for populations closer to saturation.  With the proper curve, a step wedge without any background would have equal Y strength at every horizontal location the patches are located at.
Logged

John Sheehy

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 838
Making your DSLR show Linear Histogram
« Reply #10 on: January 01, 2008, 11:06:26 am »

Quote
Of course, I did not say that WB contributed to the clipping, but if the red channel is blown and the red multiplier is 1.8, there is a good chance that channel scaling for white balance contributed to the clipping. In your example, it is likely that the white subject and the red flower occupy different positions in the image, and would be less likely to show up in a luminance histogram, which keeps track of the pixel location in its calculations as explained by The Cambridge in Color Tutorial on histograms.
[a href=\"index.php?act=findpost&pid=164236\"][{POST_SNAPBACK}][/a]

The context in which I was writing was one where WB (WB is necessary for perfect daylight, too) was already taken into account, and a significant issue which still remains.  For certain hues and saturations, the saturation is boosted tremendously in conversions, pushing one color up one or two stops sometimes, and dropping one or both of the other colors, too, after WB.
Logged

bjanes

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 3387
Making your DSLR show Linear Histogram
« Reply #11 on: January 01, 2008, 12:37:39 pm »

Quote
And the simple solution is to give more weight in the y axis for populations closer to saturation.  With the proper curve, a step wedge without any background would have equal Y strength at every horizontal location the patches are located at.
[a href=\"index.php?act=findpost&pid=164374\"][{POST_SNAPBACK}][/a]

The advantage of a gamma 2.2 curve is that it more closely approaches the response of the human eye, which is logarithmic. Personally, I would prefer a log base 2 histogram rather than a power curve. Having all values of a step wedge with the same Y values does not make sense to me.
« Last Edit: January 01, 2008, 12:48:14 pm by bjanes »
Logged

eronald

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 6642
    • My gallery on Instagram
Making your DSLR show Linear Histogram
« Reply #12 on: January 01, 2008, 02:05:52 pm »

I don't want to say anything technical here, but just be practical:

As a street shooter/ or in fashion shows  you don't get an opportunity to ETTR, because you always need to keep a stop or so of headroom for the cases the camera overexposes something essential: There are no reshoots.


I know that while shooting fashion shows overexposure with the Canons is a constant problem, a spotlight shining somewhere on the model means a wrecked shot.

Thus having a histogram which "blows out" about one stop under real overexposure is about what you need in practice.

Studio shooters may have a different opinion; I have been underexposing everything I shoot outside the studio for the last five years, and it may mean inferior quality images, but it also means a lot of "one time" keepers. Incidentally, my impression is metering on the Nikon was better than on Canon, on Mamiya it is really bad.

Edmund
Logged
If you appreciate my blog posts help me by following on https://instagram.com/edmundronald

Panopeeper

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 1805
Making your DSLR show Linear Histogram
« Reply #13 on: January 01, 2008, 06:17:01 pm »

Quote
WhiteBalance being the greatest factor contributing to the histogram difference is a bit surprising to me

Change the WB in your favourite raw processor and look the change in the resulting color histogram.

Quote
I did not understand this part. Can you please explain it in a bit more detail.

The problem with displaying the RGB histogram when shooting is the shift between the channels, due to applying the setting. For example in daylight in a typical scenery the green values in teh raw data far outweight the red and green, and the green is, what most probaby causes factual clipping. You don't see any of that in the RGB histogram.

Applying the transformation effects all RGB channels the same way. It does not change the relations between the channels, only the distribution along the x axis.

Quote
I would prefer a log base 2 histogram rather than a power curve. Having all values of a step wedge with the same Y values does not make sense to me.

The original, linear histogram reflects the true nature of the data; the result after the RGB transformation reflects human perception. What would a logarithmic histogram reflect?

Here are the histogramns of the Stouffer wedge (based on your own shot). The first one is the linear raw; the second one is white balanced and sRGB mapped, the third one is 2-based log of the raw value (I made a temporary modification for this purpose).
« Last Edit: January 01, 2008, 06:19:01 pm by Panopeeper »
Logged
Gabor

Panopeeper

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 1805
Making your DSLR show Linear Histogram
« Reply #14 on: January 01, 2008, 06:20:35 pm »

Quote
There are no reshoots

What about exposure bracketing? Is that too slow with the DBs?

I can make three shots with exposure bracketing by a single click, in less than one half of a second (assumed short shutter time, of course), even without mirror slap in between.
Logged
Gabor

John Sheehy

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 838
Making your DSLR show Linear Histogram
« Reply #15 on: January 01, 2008, 07:16:06 pm »

Quote
The advantage of a gamma 2.2 curve is that it more closely approaches the response of the human eye, which is logarithmic. Personally, I would prefer a log base 2 histogram rather than a power curve. Having all values of a step wedge with the same Y values does not make sense to me.
[a href=\"index.php?act=findpost&pid=164389\"][{POST_SNAPBACK}][/a]

I meant more along the lines of area-under-the-curve; not peak height.  The volume could be the same.
Logged

Guillermo Luijk

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 2005
    • http://www.guillermoluijk.com
Making your DSLR show Linear Histogram
« Reply #16 on: January 09, 2008, 05:24:39 pm »

Quote
WhiteBalance being the greatest factor contributing to the histogram difference is a bit surprising to me. I did some experimentation around this in dcraw [it has an option to set the multipliers to 1 for all three colors (RGB)] and found that the gamma correction had much higher impact than uniWB.


Manish (I think this is your real name), Panopeeper is totally right, the WB (if applied using >=1 multipliers, which is the way cameras do unless I am wrong) severely affects your exposure. WB means to linearly multiply all levels in a channel. Since most sensors have a greater sensibility on the G channel, G levels are usually left unaltered (multiplier=1.0) while R and B channels are scaled up easily by +1EV and even more, blowing highlights in those channels.

For instance, the tungsten preset multipliers for the Canon 350D are: R=1.392498 G=1.000000 B=2.375114
Scaling the B channel by 2.375 means log(2.375)/log(2)=1,25EV overexposure!

Regarding gamma, I am not an expert, but a pure gamma correction:
OUT = MAX * ( (IN/MAX)^(1/2.2) )
will not blow anything, it will simply expand the shadows and compress the highlights but without blowing just 1 pixel.

No idea if a pure gamma correction is applied on most cameras, but whatever they do, is surely much less restricting for exposure than WB.

That is why I think your article, being very well written and having a good idea in mind, fails to think gamma is a key factor. Using that curve you will get very dark displays and will not assure to be properly representing the blown areas since WB is still being applied.

In postprocessing, many tricks can be used not to blow those channels when applying the WB during the RAW development, like for example using <=1.0 multipliers. This has the problem of creating magenta casts in the blown areas, but this can be easily fixed by special algorithms that ensure that the blown highlights remain neutral (R=G=B ). For instance DCRAW achieves this through the effective -H 2 option.

________________

An example is coming: I used this option in a severely ETTR shot (see whole article here: ETTR LANDSCAPE, Spanish).

When developed with 1.0 multipliers, i.e. no WB (DCRAW's -r 1 1 1 1 option), you get this log histogram:



When developed with <=1 multipliers (DCRAW's -H 2 option) the R channel remains unchanged in this case and the G and B channels are underexposed to balance the image and always assuring white highlights:



But cameras don't work this way, they apply >=1 multipliers (DCRAW's -H 0 option) which would have lead to B and specially R blowing, remaining G unaltered:




Regards.
« Last Edit: January 09, 2008, 06:16:05 pm by GLuijk »
Logged

Shirley Bracken

  • Full Member
  • ***
  • Offline Offline
  • Posts: 117
    • http://ssbracken.com
Making your DSLR show Linear Histogram
« Reply #17 on: December 28, 2009, 10:16:30 am »

This thread has helped me so much.  A little late in posting I guess.  bjanes, thanks for that article too.  Really good for basics!
Logged
ssbracken.com  (Formerly Bumperjack)
Pages: [1]   Go Up