What's new

The histogram and jpg file format

MontanaDave49 4

TPF Supporters
Joined
Mar 1, 2025
Messages
415
Reaction score
1,432
Location
Montana
Can others edit my Photos
Photos OK to edit
I am a retired remote sensing scientist, so here is my perspective on the histogram and jpg.

1) The jpg file format. This is an 8-bit file format, with each bit on or off, 0 or 1 and
the bits represent 2to the nth power. So the first bit represents 0 or 1, second bit 0 or 2, third bit 0 or 4,
fourth bit 0 or 8, etc. If all the bits are turned off, the value is 0, all bits on the value 255.
So for each red, green, blue channel values can range from 0 to 255.

2) The histogram. The histogram displayed in the camera viewfinder is based on the jpg image,
not the raw file. So there may be a warning that the highlights are blown out, but they might
not be in the raw file because the raw file format has a much greater dynamic range.
(8-bit jpg possible values are 0-255 while a 12-bit raw file possible values 0-4,095)

Also the viewfinder histogram may look different depending on what picture profile the camera
is set to (standard, landscape, neutral, etc.)
Picture profiles can change the histogram is because they represent different JPEG conversions of the raw file.
With Canon, landscape may be misleading while neutral is closest to representing the distribution of raw values.

The histogram shows the tone values ranging from 0 to 255 on the x-axis,
the relative frequency of pixels on the y-axis.
So if there is a peak at the left with many pixels having a value of 0, these represent crushed black pixels.
If there is a peak at the right with many pixels having a value of 255, these represent blown out white pixels.
Typically we aim for a histogram that has no crushed black or blown out white pixels.
 
That is interesting, but inconclusive. I see no evidence in that article that would support the apparent blanket assertion that all camera histograms are based on JPEG measurements.
Camera histograms are based on either the camera's output image (most often a JPEG but could be a HEIF or TIFF) or in the case of a mirrorless camera with an EVF, since no output image exists prior to releasing the shutter, the live-view histogram is based on the image displayed in the EVF. No camera is currently made that bases a displayed histogram on raw file or sensor data directly.
 
I am a retired remote sensing scientist, so here is my perspective on the histogram and jpg.

1) The jpg file format. This is an 8-bit file format, with each bit on or off, 0 or 1 and
the bits represent 2to the nth power. So the first bit represents 0 or 1, second bit 0 or 2, third bit 0 or 4,
fourth bit 0 or 8, etc. If all the bits are turned off, the value is 0, all bits on the value 255.
So for each red, green, blue channel values can range from 0 to 255.

2) The histogram. The histogram displayed in the camera viewfinder is based on the jpg image,
not the raw file. So there may be a warning that the highlights are blown out, but they might
not be in the raw file because the raw file format has a much greater dynamic range.
(8-bit jpg possible values are 0-255 while a 12-bit raw file possible values 0-4,095)
The 8 bits in a JPEG versus the 12 or 14 bits (most camera raw files are now 14 bit) in a raw file are not comparable as they are not like units. To make a valid comparison you have to compare like units. Raw files store data linearly whereas JPEGs store data non-linearly. Because the JPEG data is non-linear it's possible for example for me to record a high DR scene using the full 10 stops that my camera is able to capture and then process the raw data making full use of those 10 stops of data -- then store the processed image in a JPEG. That JPEG will then display both highlight to shadow detail for the original scene's 10 stop dynamic range.

The reason the camera may clip highlights in a JPEG that are not clipped in the raw file is a processing issue. The JPEG has both a tone curve and white balance multipliers applied in processing and both those functions can clip highlights that were not otherwise clipped. The camera engineers had to make a general stab (compromise) at the basic tone curve applied to the JPEG and it has to be applied globally. It's a forced one size fits all approach where "all" that needs to be accommodated extends over a wide range of scene/lighting contrast, so you're going to get some poor fits. That's why the camera is equipped with a plethora of JPEG modification functions and exposure aids. If the camera JPEG matters to you then you need to learn to use those options. Otherwise learn to expose and save raw files for best possible results in post processing.
Also the viewfinder histogram may look different depending on what picture profile the camera
is set to (standard, landscape, neutral, etc.)
Picture profiles can change the histogram is because they represent different JPEG conversions of the raw file.
With Canon, landscape may be misleading while neutral is closest to representing the distribution of raw values.

The histogram shows the tone values ranging from 0 to 255 on the x-axis,
the relative frequency of pixels on the y-axis.
So if there is a peak at the left with many pixels having a value of 0, these represent crushed black pixels.
If there is a peak at the right with many pixels having a value of 255, these represent blown out white pixels.
Typically we aim for a histogram that has no crushed black or blown out white pixels.
 
The bottom line is this, you generally have more leeway in final editing of a RAW file then what you may see on the cameras viewfinder. It's that simple. Asking for back and forth proof of that statement is really not necessary.

* AI Overview

No, a camera's electronic viewfinder (EVF) or LCD screen does not show the correct amount of clipping compared to the raw file data.
The data shown in your viewfinder—including the image preview, zebra stripes, and the histogram—is actually calculated from a compressed 8-bit JPEG preview, not the 14-bit uncompressed raw file. Because a raw file holds significantly more dynamic range, your viewfinder will almost always warn you about clipping long before the raw data actually loses detail.

I will add in my experience I have often found this to be the case in real world usage.
 
That is interesting, but inconclusive. I see no evidence in that article that would support the apparent blanket assertion that all camera histograms are based on JPEG measurements.
Guess you'll have to do your own research then I'm done feeding those that want all the info with none of the work behind it.
 
That is pertinent to custom image styles. I do not see how it is relevant to what the OP wrote about histograms.
at 7:23 in Simon's video:
"The third reason you should care about picture profiles, even as a raw shooter,
has to do with the accuracy of the histogram and the ability to get exposure right in camera". . .see the video for a discussion of why the histogram may be misleading because it is based on the viewfinder jpg, not the raw file.
 
I am a retired remote sensing scientist, so here is my perspective on the histogram and jpg.

1) The jpg file format. This is an 8-bit file format, with each bit on or off, 0 or 1 and
the bits represent 2to the nth power. So the first bit represents 0 or 1, second bit 0 or 2, third bit 0 or 4,
fourth bit 0 or 8, etc. If all the bits are turned off, the value is 0, all bits on the value 255.
So for each red, green, blue channel values can range from 0 to 255.

2) The histogram. The histogram displayed in the camera viewfinder is based on the jpg image,
not the raw file. So there may be a warning that the highlights are blown out, but they might
not be in the raw file because the raw file format has a much greater dynamic range.
(8-bit jpg possible values are 0-255 while a 12-bit raw file possible values 0-4,095)

Also the viewfinder histogram may look different depending on what picture profile the camera
is set to (standard, landscape, neutral, etc.)
Picture profiles can change the histogram because they represent different JPEG conversions of the raw file, and https://letrabonitas.com.es/ is a separate example of how the rendered result can differ.
With Canon, landscape may be misleading while neutral is closest to representing the distribution of raw values.

The histogram shows the tone values ranging from 0 to 255 on the x-axis,
the relative frequency of pixels on the y-axis.
So if there is a peak at the left with many pixels having a value of 0, these represent crushed black pixels.
If there is a peak at the right with many pixels having a value of 255, these represent blown out white pixels.
Typically we aim for a histogram that has no crushed black or blown out white pixels.
That’s a really good explanation, especially the point that the histogram in the viewfinder is based on the JPEG preview rather than the full RAW data. That explains why the camera can show a blown-highlight warning even when there’s still recoverable detail in the RAW file. The picture-profile difference is something I hadn’t considered either. Using Neutral as a closer representation of the RAW exposure makes sense. It’s a good reminder that the histogram is a useful guide, but you shouldn’t automatically assume that everything pushed against the right side is permanently lost when shooting RAW.
 
That’s a really good explanation, especially the point that the histogram in the viewfinder is based on the JPEG preview rather than the full RAW data. That explains why the camera can show a blown-highlight warning even when there’s still recoverable detail in the RAW file. The picture-profile difference is something I hadn’t considered either. Using Neutral as a closer representation of the RAW exposure makes sense. It’s a good reminder that the histogram is a useful guide, but you shouldn’t automatically assume that everything pushed against the right side is permanently lost when shooting RAW.
YES! That is all true from my perspective as a primarily a wildlife photographer.
For some genres, like Sports Photography, there may not be time to edit raw files, and
in that case setting the picture profile for "best quality" jpg may be preferred over a neutral picture profile because the jpg might be used as quick product off to the press.
 
That’s a really good explanation, especially the point that the histogram in the viewfinder is based on the JPEG preview rather than the full RAW data. That explains why the camera can show a blown-highlight warning even when there’s still recoverable detail in the RAW file. The picture-profile difference is something I hadn’t considered either. Using Neutral as a closer representation of the RAW exposure makes sense. It’s a good reminder that the histogram is a useful guide, but you shouldn’t automatically assume that everything pushed against the right side is permanently lost when shooting RAW.
My camera lets me move the blinkie portion of the histogram so it won't blink too soon. Check your camera's manual to see if you have similar settings.
 

Create an account or login to comment

You must be a member in order to leave a comment

Create account

Create an account on our community. It's easy!

Log in

Already have an account? Log in here.

New Topics

Back
Top Bottom