Pages: [1]   Go Down

Author Topic: understanding the histogram in lab mode  (Read 7026 times)

bwana

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 309
understanding the histogram in lab mode
« on: May 14, 2014, 09:11:57 am »

in rgb mode, the histogram represents the pixel count of the three colored pixels at pixel intensities from 0 to 255 (i don't really know why the number is 255 if i am working with a 16 bit image, shouldn't it be 65535?) anyway if i have a bright image, the histogram is skewed to the right with a bunch of pixels being clipped. when i switch to lab mode, the histogram is vastly different, the luminance channel is still skewed to the right (but less so) and now there is a big hump in the middle (the a and b channels). In fact almost any image has the a and b channels as a peak in the middle in lab mode. why are the a and b channels not skewed to the right like luminance? If the a and b channels are pure color information, then they really have no brightness value so shouldn't they actually be 0 on the histogram? or an arbitrary brightness value (giving a single sharp line, not a hump)?
Logged

digitaldog

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 20630
  • Andrew Rodney
    • http://www.digitaldog.net/
Re: understanding the histogram in lab mode
« Reply #1 on: May 14, 2014, 09:51:17 am »

The histogram represents one vertical 'line' pre tone. Yes, it should in theory show you 65K individual lines but you'd need a display the size of a barn! So the representation is reduced to 255 vertical lines. And FWIW, you really don't need any more than that number to get the job done.
This may help too:
Everything you thought you wanted to know about Histograms

Another exhaustive 40 minute video examining:

What are histograms. In Photoshop, ACR, Lightroom.
Histograms: clipping color and tones, color spaces and color gamut.
Histogram and Photoshop’s Level’s command.
Histograms don’t tell us our images are good (examples).
Misconceptions about histograms. How they lie.
Histograms and Expose To The Right (ETTR).
Are histograms useful and if so, how?

Low rez (YouTube): http://www.youtube.com/watch?v=EjPsP4HhHhE
High rez: http://digitaldog.net/files/Histogram_Video.mov
Logged
http://www.digitaldog.net/
Author "Color Management for Photographers".

howardm

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 1984
Re: understanding the histogram in lab mode
« Reply #2 on: May 14, 2014, 10:11:23 am »

the a and b histograms connote color information along the x/y axis's of blue/yellow (ala temperature) and red/green (tint) (the gurus here will
slaughter me for using those color names :) ).  the histo. do NOT connote brightness.  0,0 on a,b is grey (ie. no color) so you can see why many
images have clustered histograms.  Images w/ distributions of intense color will have wider a,b histograms.

bjanes

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 3387
Re: understanding the histogram in lab mode
« Reply #3 on: May 14, 2014, 11:28:21 am »

the a and b histograms connote color information along the x/y axis's of blue/yellow (ala temperature) and red/green (tint) (the gurus here will
slaughter me for using those color names :) ).  the histo. do NOT connote brightness.  0,0 on a,b is grey (ie. no color) so you can see why many
images have clustered histograms.  Images w/ distributions of intense color will have wider a,b histograms.

Yes, if the image contains saturated colors, the *a and *b histograms will be pushed to the right. I rendered an image with saturated colors into ProPhotoRGB with minimal clipping. I then converted to L*a*b. The histograms are shown below. The *b histogram (blue vs yellow) is pushed to the right because of the saturated yellow.

Bill
Logged

bwana

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 309
Re: understanding the histogram in lab mode
« Reply #4 on: May 14, 2014, 11:42:08 am »

tnx all, i think i get it. with a L*a*b image, the horizontal axis for a and b ranges between two colors - not dark to light. As a consequence it will be in the middle for an image whose colors are randomly (evenly?) distributed. 

@digital dog, at one point in your video, a histogram appears with a puff of smoke/dust like you just slammed a book down onto a dusty desk. (~24 minutes into the clip) the composite effect of the smoke is interesting as you could see through it to the underlying histogram. how was it done?

also interesting  was that manipulating the sliders in the levels dialog histogram, PS causes data loss but lightroom does not. is that because lightroom interpolates tones to fill in the gaps? I guess that's another "benefit" of the 2012 process (besides automatic highlight recovery). in your example (26 minutes) you illustrate this with a jpeg, not a raw file.
Logged

digitaldog

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 20630
  • Andrew Rodney
    • http://www.digitaldog.net/
Re: understanding the histogram in lab mode
« Reply #5 on: May 14, 2014, 11:46:04 am »

@digital dog, at one point in your video, a histogram appears with a puff of smoke/dust like you just slammed a book down onto a dusty desk. (~24 minutes into the clip) the composite effect of the smoke is interesting as you could see through it to the underlying histogram. how was it done?
Just a fun Keynote effect. Got your attention ;D
Quote
also interesting  was that manipulating the sliders in the levels dialog histogram, PS causes data loss but lightroom does not.
Every operation in LR takes place on high bit data, not necessarily the same in Photoshop.
Logged
http://www.digitaldog.net/
Author "Color Management for Photographers".

MarkM

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 428
    • Alaska Photographer Mark Meyer
Re: understanding the histogram in lab mode
« Reply #6 on: May 14, 2014, 12:08:40 pm »

Yes, if the image contains saturated colors, the *a and *b histograms will be pushed to the right.

I'm sure this is just a typo, but to prevent confusion: increasing saturation pushes the histograms away from the center — both left or right depending on the particular color.

Logged

SZRitter

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 384
Re: understanding the histogram in lab mode
« Reply #7 on: May 14, 2014, 12:19:31 pm »

also interesting  was that manipulating the sliders in the levels dialog histogram, PS causes data loss but lightroom does not. is that because lightroom interpolates tones to fill in the gaps? I guess that's another "benefit" of the 2012 process (besides automatic highlight recovery). in your example (26 minutes) you illustrate this with a jpeg, not a raw file.

I believe, but Digital Dog can correct me if I'm wrong, that using ACR as a filter in CC would work in the same manner as Lightroom. That said, it can be a little harder to work with than an adjustment layer.
Logged

Tim Lookingbill

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 2436
Re: understanding the histogram in lab mode
« Reply #8 on: May 15, 2014, 03:57:20 pm »

If it hasn't already been mentioned keep in mind the Lab L* channel histogram is linear scale encoding while ProPhotoRGB is 1.8 gamma and AdobeRGB 2.2 gamma.

This might only be important if you wanted to match luminance levels in numbers between the two encodings. For instance ProPhotoRGB (1.8 gamma) midgray is encoded at 118RGB and AdobeRGB (2.2 gamma) is at 128RGB.

To see the differences create a B&W gradient in a new doc set to Lab in Photoshop and another new doc in a gamma encoded space of your choosing and Posterize set to '21' under Image>Adjustments>Posterize... menu. There will be a difference in the rate of luminance progression coming out of black.
Logged

Jim Kasson

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 2370
    • The Last Word
Re: understanding the histogram in lab mode
« Reply #9 on: May 15, 2014, 04:21:48 pm »

If it hasn't already been mentioned keep in mind the Lab L* channel histogram is linear scale encoding while ProPhotoRGB is 1.8 gamma and AdobeRGB 2.2 gamma.

Uh, L* varies as the cube root of linear intensity over almost all its range. In the funny way we talk about gamma, we'd say that it has a gamma of 3.

Jim

Tim Lookingbill

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 2436
Re: understanding the histogram in lab mode
« Reply #10 on: May 16, 2014, 01:25:20 pm »

Uh, L* varies as the cube root of linear intensity over almost all its range. In the funny way we talk about gamma, we'd say that it has a gamma of 3.

Jim

Uh, just to remind you Lab is a color description model and has no connection to gamma (a power function associated with input/output of light intensity on a display) seeing you want to confuse with irrelevant points to my visual concept of linear regarding editing and creating a grayramp in Lab space on a 2.2 gamma encoded display. That's the only way to see and analyze Lab's histogram in Photoshop or else examine the numbers in the Info Palette.

Your cube root of linear intensity comment which doesn't explain and pretty much adds confusion on how that appears or even connects with a histogram also doesn't take into account Lab's non-uniformity issues. What's not being described here effectively is the look and appearance of the term "Linear" as it's used in an editing environment as opposed to using it to describe power function mathematics and sensor linearity and how it can be understood by a person using an editing program. I chose to associate the term "Linear" on how a B&W gradient's tone distribution appearance changes depending on the space it's encoded. I also didn't confuse by including that gradient's tone distribution can be changed by tweaking Photoshop's Gradient tool dialog box Smoothness slider.

Or maybe you can tell us how we can use "cube root of linear intensity" in the real world of editing on a transmissive, gamma encoded display. Do you actually believe light on a transmissive display behaves that predictably and precise considering the human visual system's constant adaptive nature to changing luminance intensity?

« Last Edit: May 16, 2014, 01:37:04 pm by Tim Lookingbill »
Logged

MarkM

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 428
    • Alaska Photographer Mark Meyer
Re: understanding the histogram in lab mode
« Reply #11 on: May 16, 2014, 05:31:29 pm »

Tim, I think when most of us talk about 'linear encoding' we mean the input intensity is related to the encoded value by a linear relationship. So a source that emits or reflects 0%, 18%, and 100% of white would be encoded 0, 18 and 100 respectively. This is certainly not the case for LAB. L* as Jim points out has a non-linear encoding out = 116*(in)^(1/3)-16. This is why 18% is encoded as L* 50 not 18. The history of L* and gamma might be different, but the effect is the same — you are taking input and raising to an exponent creating a non-linear relationship.

Logged

bwana

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 309
Re: understanding the histogram in lab mode
« Reply #12 on: May 16, 2014, 06:35:11 pm »

Ok,I am now sufficiently confused with these off topic comments to request clarification. When I say "l*a*b" mode I am talking about that menu choice in ps - another choice is RGB and another choice is indexed color. My understanding is that pro photo , adobeRGB, and sRGB are colorspaces that only apply to RGB color. Why they have different gammas is not clear to me. Do we also speak of gamma with Lab mode, indexed color, etc?
Logged

Jim Kasson

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 2370
    • The Last Word
Re: understanding the histogram in lab mode
« Reply #13 on: May 16, 2014, 07:21:01 pm »

Ok,I am now sufficiently confused with these off topic comments to request clarification. When I say "l*a*b" mode I am talking about that menu choice in ps - another choice is RGB and another choice is indexed color. My understanding is that pro photo , adobeRGB, and sRGB are colorspaces that only apply to RGB color. Why they have different gammas is not clear to me. Do we also speak of gamma with Lab mode, indexed color, etc?

RGB color spaces are defined by the relationship of their primary colors to 1931 CIE XYZ, and the nature of their non-linearity, if they have one. Their primaries are specified by a 3x3 matrix which, when multiplied by a color in XYZ (which is linear), yields the same color in the RGB color space before the non-linearity is applied. The convention in RGB color is to apply the same non-linearity to all three color planes. If there is no nonliterary, an RGB color space is called a linear RGB space. Another way to say the same thing is that the gamma is one. The nonlinearities of common RGB spaces often are not pure power laws, but have a linear portion near zero. We photographers can safely ignore that nicety almost all the time, and just refer to the non-linearity by the number in the power law. Back in the dim past of photography and video, RGB color spaces were defined in terms of real monitors, so that the colors in an analog or data stream encoded in a particular monitor space would display properly on a monitor whose native space was that one. Because of this, we refer quaintly to gamma in the inverse of what would normally make sense. When we cay that a file is encoded in a RGB space with a gamma of 2.2, we really mean that it is encoded such that it will display properly on a physical or mathematical monitor with a gamma of 2.2. To get from linear, say R, to R with a gamma of 2.2, assuming R is in the range [0,1], we raise the linear values to the power of 1/2.2 or 0.454545. To get back to linear, we raise the encoded values to the power 2.2.

With modern color management, the colors in RGB files are encoded for abstract, ideal monitors. Some of these monitors are pure mathematical constructs, and can never be created. An example is ProPhotoRGB, which has two physically unreliable primaries. Gamma compressed RGB just happens to be a convenient way to encode color, and an efficient one with gammas between say, 1.8 and 4, since the human's response to varying light intensity under some laboratory conditions goes approximately as the cube root of the light intensity, so files encoded in that range of gamma don't waste a lot of space on distinctions that don't make much difference to humans, unless they have extreme primaries like ProPhotoRGB.

You need to understand the gamma of an RGB file only if you're planning on looking closely at the histogram. The  choice is usually between 1.8 and 2.2, the most common gammas for RGB encodings. If you're interested, I can compute some histograms for files encoded with various gammas, and you can see how that works. If your looking at L*'s histogram in Photoshop be aware that it has power law scaling very like that of each of the three planes in an RGB image. 18% gray is in the middle (right in the middle with the twist on the power lab that the CIE specified for L*; if it were a pure 1/3 power law, 18% gray would map to L* =~ 56), for example, not on the left as you'd find in a linear representation. We don't speak of gamma when we talk about Lab, because the non-linearity is always the same, unlike RGB color spaces, which can have different non-linearities.

You brought up indexed color. The indices don't have gamma, but the indices point to tables that convert them to RGB triplets in some RGB color space. From then on, it's as if the images were directly encoded in that space, which does have a gamma, and primaries, and a white point. Let me know if you need more explanation on that point, This post is getting long and my hands are tired.

Jim
« Last Edit: May 16, 2014, 09:54:02 pm by Jim Kasson »
Logged

Jim Kasson

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 2370
    • The Last Word
Re: understanding the histogram in lab mode
« Reply #14 on: May 17, 2014, 11:59:21 am »

Ok,I am now sufficiently confused with these off topic comments to request clarification. When I say "l*a*b" mode I am talking about that menu choice in ps - another choice is RGB and another choice is indexed color.

If you are trying to understand the L* part of the Lab histogram, the discussion of the L* nonlinearity is not off topic. Here are plots of the various gamma encodings that we're talking about, including the not-strictly-power-law L* encoding. The linear representation is on the x-axis, and the encoded value is on the y-axis:



You can see that, although white and black are encoded to the same values regardless of the non-linearity, all the other tones have non-linearity dependent middle tones. That will affect the histograms.

Here's an example.

Here's the Photoshop histogram of an image in Adobe RGB, which has a gamma of 2.2:



Here's a histogram of the same image converted to ProPhotoRGB, which has a gamma of 1.8. The histogram is shifted/scaled to the left:



Here's a histogram of the same image converted to Lab. The L* histogram is shifted/scaled to the right. (The spike in the middle is the histogram of the a* and b* planes, all of which have the value 0 in the test image.):



Jim

« Last Edit: May 17, 2014, 12:09:34 pm by Jim Kasson »
Logged
Pages: [1]   Go Up