The Histogram

The image histogram acts as a graphical representation of the tonal distribution in a digital image.  It plots the number of pixels for each tonal value.  The histogram will quickly highlight problems with an image including under exposure, over exposure or colour balance issues and is used to help capture the highest quality data possible.

The histogram can be shown by clicking the Image Histogram icon in the Tool Bar:

image

which will display the Image Histogram in the Work Area of the Main Screen, as shown below.

image

Clicking the FX Selection Area icon in the Tool Bar shows a red rectangle on the image which can be dragged and re-sized. While this selection area rectangle is enabled, the histogram is only calculated for the parts of the image within the rectangle.  This allows for more detailed scrutiny of a restricted region of the image and of how the histogram in the region appears.

image

Notice the two histograms above are different but no camera settings have been changed.

The Histogram in Detail

image

Auto Hide – at the top right, the ‘pin’ icon can be used to auto hide the histogram when the mouse is moved away from it.  Moving the mouse back over the collapsed histogram tab will re-show it.

Logarithmic/linear selection – the checkbox will switch between a logarithmic display and a linear display.

Mean and Standard Deviation (SD) – statistical information for each colour channel giving the mean and standard deviation of the pixel values for that channel. These are measured in ADU (Analogue to Digital Units) with a maximum value of 255 at 100% for 8-bit images and 65535 at 100% for 10/12/14/16-bit images.

Crosshairs – these show when the mouse is moved over the histogram area and allow you to read off the ADU value and pixel count for any point on the histogram graph easily.

Horizontal axis – the % of maximum pixel brightness (in 8 bit modes the pixel brightness is 0 to 255, in 16 bit modes 0 to 65535).  This is scaled as 0 – 100 and caters for 8-bit, 12-bit, 14-bit and 16-bit cameras in a uniform presentation.

Vertical axis – the number of pixels at that brightness.

The Histogram Lines – The four lines on the histogram graph showing the brightness distribution of each of the three primary colour channels (Red, Green and Blue) and the distribution of the total brightness of each pixel (often referred to as Luminance).

Horizontal Colour Bars – these bars below the horizontal axis represent the ranges of the Luminance, Red, Green and Blue channels (commonly referred to as LRGB).

This histogram below conveys the following information:

·         Approximately 400k pixels have 3% of maximum pixel brightness.  This is the histogram peak.

·         Approximately 15 pixels have 100% of maximum pixel brightness”, that is, are saturated in this case.  This is a very small number of pixels compared to the total number in the image, so the clipping at the right-hand side is of little significance.

image

 

Note when using a Mono colour space, there is only a single white horizontal bar (Luminance) and single line on the graph.

image

 

Understanding the Histogram Axes

The diagram below defines the units of the horizontal and vertical axes. 

image

Note SharpCap shows the horizontal scale as a %, giving a uniform method of labelling to cover 8, 12, 14 and 16-bit cameras.

The horizontal scales can be found on the internet using a representation of the bit depth capability of the camera.  The table indicates alternate horizontal scales that may be encountered, the numbers being derived as 2n-1, where n = bit depth of camera.

Camera bit depth

Histogram horizontal scale

8

0..255

12

0..4095

14

0..16383

16

0..65535

 

Linear and Logarithmic Scales

By deselecting or selecting the Logarithmic checkbox at the top right, the shape of the SharpCap histogram can be changed.

image

image

Vertical scale is linear, checkbox not selected

Vertical scale is logarithmic, checkbox selected

 

In the graphics above, notice the vertical scales are different.  The following is a description of the difference between Linear and Logarithmic scales.

Note: ~ means approximately in the calculations.  The slight inaccuracies are due to rounding errors when scaling to fit the screen.

 

image

Linear Scale   image is unchecked in the Image Histogram.

 

·         The numbers are uniform.

·         The tick marks are equally spaced.

·         The tick marks have uniform differences between their values.

·         The values are 0, 37k (1*37), 75k (~2*37), 113k (~3*37k), 150k (~4*37k), 188k (~5*37k).

·         The increment from one tick mark to the next is ~37k (37000), that is 37k is added to each value to get the next value.

·         If the graph is twice as high in one place (say at 50% brightness) as another (say 25% brightness), meaning there are twice as many pixels with 50% brightness as with 25% brightness.

 

 

 

image

Logarithmic Scale    image is checked in the Image Histogram.

 

·         The numbers are non-uniform.

·         The tick marks are equally spaced.

·         The tick marks do not have uniform differences when moving from one value to the next – instead they are multiplied by some amount.  For instance, the values are 13, 180 (~13*13), 2400 (~13*13*13) and so on. 

·         Those who can remember basic algebra, will recognise 130, 131, 132, 133 and so on.

·         The vertical scale increases the height of areas where there are small values and reduces the height where there are large values.

·         Becomes easier to see those parts of the graph with a much-reduced number of pixels at each level. 

·         Logarithmic scales help to get all the data on the chart so the values are readable – they supress the high values and enhance the low values.

 

 

After reading the above, the question is “Should a Logarithmic scale or a Linear scale be chosen when using the Image Histogram?”

The answer is “think about the type of object being imaged and use whichever obtains the best images” but, bear in mind the following:

·         Linear makes most sense when the area the histogram is being applied to is roughly uniform in brightness, for instance:

o   A lunar or solar image when the frame is filled.

o   A planetary image when the ROI is used to select a region inside the planetary disk.

·         Logarithmic makes sense when there are distinct different regions inside the histogram area, for instance:

o   A deep sky full frame containing a small area of nebulosity.

If the deep sky was looked at with a linear histogram, the peaks from the nebulosity and stars would be swamped by the vast black level peak and therefore invisible.  However, the logarithmic scale gets around this.

The following two examples both use a logarithmic scale but depending on the type of object being imaged (deep sky or large disk) the desired histogram shape is totally different.

image

Deep Sky

image

Large Disk

image

image

 

Using the Histogram to Improve Image Quality

The shape of a ‘good’ Histogram can vary depending on:

·         A logarithmic or linear vertical scale being selected.

·         The object being viewed:

o   Deep Sky.

o   Solar/Lunar/Planetary.

o   Solar/Lunar/Planetary when ROI (Region of Interest) is used to select an area inside the disk.

Guidelines for ‘good’ histogram shapes for linear/logarithmic vertical scales and object types are summarised below.  Following these guidelines will help ensure images are correctly exposed.

image

Deep sky - linear

 

image

Deep sky - logarithmic

 

 

image

Solar/lunar/planetary – linear

 

image

Solar/lunar/planetary - logarithmic

 

 

image

Solar/lunar/planetary with ROI or when target is filling frame (i.e. no black background) – linear

 

image

Solar/lunar/planetary with ROI - logarithmic

 

It is helpful to consider the following information to understand why these shapes of histogram are associated with the given types of image:

·         Deep sky histograms have a peak at low intensity levels due to the dark background and typical low brightness of any nebulosity.

·         Solar/lunar/planetary histograms usually have a peak near the black level due to the dark background and another peak for the (relatively) large and bright image.

·         Solar and Lunar histograms where an ROI is used or the sun/moon fill the entire frame will not have a peak near the black level as there is no black background.

The following two diagrams show the type of problems (plus suggested fixes) encountered with a histogram.

image

Under-exposed image

When the histogram looks like this (shifted too far left), the image is said to be under-exposed or black level clipped.  This will result in an image with a grainy background.  The grainy background is difficult to remove with post-processing software.  Faint detail will be hard to bring out.  To fix, expose the image for longer (preferred) and/or increase gain and/or increase brightness or offset.

image

Over-exposed image

When the histogram looks like this (shifted too far right), the image is said to be over-exposed.  Pixels in the image become saturated, resulting in detail being lost.  To fix, expose the image less (preferred) and/or reduce gain.

 

Worked Examples

The following two examples use these guidelines (not rules) for a ‘reasonable’ histogram for a deep sky object with the vertical axis set to use a logarithmic scale:

·         Horizontal LRGB bars not touching left axis (otherwise black clipped).

·         Horizontal LRGB bars not touching right axis (otherwise white saturated).

·         Red and blue horizontal bars approximately level at each end (colour balance).

·         LRGB histograms very close together in the graph.

·         Histogram peak at around 20% on horizontal axis.  The peak can move depending on light pollution.

·         Sharp gradient at left of peak.

·         Gentle gradient to right of peak.

A Monochrome Deep Sky Example

The example below documents the preparation to image M42.  The equipment used was:

·         Celestron C8 SCT.

·         Celestron CG5 Equatorial Mount.

·         Altair Astro GPCAM MONO V1 set to MONO8 colour space.

·         A 0.5x focal reducer and Astronomik CLS filter.

·         Imaging laptop was a Lenovo X61 ThinkPad, with 1.8GHz Core 2 Duo CPU, 4Gb RAM, 120Gb SSD & Windows 10 Pro 32-bit.

 

image

The M42 object has a wide range of brightness.  Rather than try to set exposure and gain for the whole image, the FX Area Selection tool was used to set the histogram for a restricted area, effectively excluding the bright core of M42 from the calculations.  This choice led to the core being over exposed but gave a chance of capturing the nebulosity – a trade-off.

Checking against the guidelines listed above for a deep sky object with the vertical axis set to use a logarithmic scale:

Guideline

Whether satisfied

Horizontal LRGB bars not touching left axis (otherwise black clipped).

Yes, mono therefore no RGB.

Horizontal LRGB bars not touching right axis (otherwise white saturated).

Touching, but looking at the log scale, ~80 pixels saturated.

Red and blue horizontal bars approximately level at each end (colour balance). 

Not applicable, as mono.

LRGB histograms very close together in the graph. 

Not applicable, as mono.

Histogram peak at around 20% on horizontal axis. 

At 10% but shape is good.

 

Sharp gradient at left of peak.

Yes.

Gentle gradient to right of peak.

Yes.

 

The stack was cleared and stacking restarted, the histogram was still reasonable, nebulosity was starting to build after 1 x 30s frame.

image

At each stage, most attention was paid to the histogram in the Work Area.

Here is a copy of the FITS capture file loaded into FITS Liberator – with no post-processing.  The histogram had kept ‘reasonable’ shape suggesting worthwhile data was being captured for subsequent processing. 

image

A Colour Deep Sky Example

This capture was taken using an AVS DSO-1 analogue video camera with USB2 video capture device (frame grabber).  The video grabber is classed as a DirectShow device, no camera controls are exposed in SharpCap, so adjustments are made using the camera’s internal menu.

image

Checking against the guidelines listed above:

Guideline

Whether satisfied

Horizontal LRGB bars not touching left axis (otherwise black clipped).

Yes.

Horizontal LRGB bars not touching right axis (otherwise white saturated).

Yes.

Red and blue horizontal bars approximately level at each end (colour balance). 

Reasonable.

LRGB histograms very close together in the graph. 

Yes.

Histogram peak at around 20% on horizontal axis. 

Yes.

Sharp gradient at left of peak.

Yes.

Gentle gradient to right of peak.

Yes.

 

The four Trapezium stars at the core of M42 can be seen.  Improvements here would be to try to extend the histogram more to the right, by adjusting exposure, gain and brightness.

The resultant Save as Viewed PNG file when the Live Stack count was 293 is shown below (Save as Viewed = no post-processing).  The core was blown out but some nebulosity was captured.

image

AVS DSO-1 camera settings

·         AGC = 36

·         Colour = Red 63, Blue 101

·         INTG = X8

·         Brightness = 60

·         Gamma = 0.3

·         INTMUL = 5