Diagnosing Raw Data Filtering


Introductory Comments

For longer exposures, many cameras filter their raw data in order to remove bright pixels that would add to the image noise. The Sony "star eater" was the infamous version of this. The raw data filtering is often referred to as HPS (hot pixel suppression) in discussions on Nikon cameras or as spatial filtering. The purpose of this web page is to describe a method of diagnosing what the camera is doing.


Example of Filtering

The Sony A7S is a good example to begin with because the raw data filtering is applied only in bulb mode. It is therefore possible to take two dark exposures of 30sec and compare them.

Here is the plot of ISO 8000 30sec room temperature dark image where the raw file was taken and each pixel value has been plotted against the maximum value found in the 24 neighbours in the 5x5 box that surrounds that pixel:



In the above plot, the red, green and blue pixel values all appear together in one plot but each colour channel can be plotted separately:



These plots are typical of unfiltered raw data of a long exposure dark frame. In particular, note the strong "vertical arm" of the plot. The pixel values in this region are those that are brighter than their 24 neighbours.

For comparison, here is the same plot of an ISO 8000 30sec room bulb-mode image taken seconds later:



In this data, the effects of the raw data filtering are very obvious. The vertical arm has disappeared, except for a small number of pixels which for some reason have escaped treatment by the raw data filtering algorithm. There is now a very strong diagonal with slope 1. The pixel values on this diagonal are those whose value matches the maximum value found among its 24 neighbours. It is clear that the algorithm works by identifying values that are higher than their neighbours (i.e. outlying values) and then capping them to the value of one of their neighbours.

As before we can examine each colour channel separately and see identical behaviour in each colour channel:



Sony Star Eater

More detail can be inferred about the algorithm used by the Sony A7S bulb mode by taking each colour channel separately and plotting each pixel value against the maximum of its 8 neighbours of the same colour (instead of all 24 neighbours which have different colours):



It immediately becomes clear that the raw data filtering algorithm is taking each colour channel separately, identifying values that are higher than their 8 neighbours and then capping them to the maximum value of those 8 neighbours.



8 neighbours of the same colour

For further clarity of what is meant by neighbours of the same colour, here are the pixel colours of the standard Bayer matrix:



For the red, green and blue channels the 8 neighbours of the same colour taken into account by the Sony star eater algorithm, are the following:

     



Sony Star Eater v2

For Sony mirrorless cameras of the second generation and beyond the raw data filtering algorithm was changed. This can be seen by examining the green channel plot of a dark frame:



Notice that the plot has a vertical arm which shows there are large number of green pixels which have higher values than the maximum of their 8 same-colour neighbours. It appears that the changed algorithm used 12 same-colour neighbours for the green pixels, illustrated here:



Plotting each green pixel value against the maximum of its 12 same-colour neighbours gives the following:



There are very few exceptions to this rule. The other change that Sony made at the same time was to apply the new raw data filtering algorithm to all exposures longer than a few seconds instead of restricting it bulb-mode exposures.

The change in algorithm has an interesting effect on small tightly-focused stars occupying an area of just a few pixels. The red and blue are more likely to have their value capped then the green pixels. This has the effect of giving star colours a green bias.



Nikon D5300

The Sony "star eater" algorithm is identical to that used by early Nikon cameras. The Nikon D5300 is a later camera and an interesting case. Here is a plot of a long exposure dark frame:



There is a clear line of demarcation in the upper region of the plot where there is not a single pixel whose bias-subtracted value (bias level is 600) is more than twice the maximum bias-subtracted value of the neighbouring pixels. By examining the plots for individual colour channels it is possible to see what happens in each colour channel:



The vertical arm in the green channel shows that there are many green pixels whose value is greater than the 8 same-colour neighbours. Looking at the 12 same-colour neighbours instead, gives the following:



This time there is no vertical arm to the plot, so it's clear that for the green channel the raw data filtering algorithm is taking the 12 same-colour neighbours into consideration

This Nikon D5300 algorithm causes the same problem to small tightly-focused stars as version 2 of the Sony star eater algorithm i.e. red and blue pixels are more likely to have their value capped then the green pixels which has the effect of giving star colours a green bias.



Nikon D800

Here is the usual plot of a long exposure dark frame, this time for the Nikon D800:



This shows many strong diagonal lines with various slopes. This is caused by a more sophisticated raw data filtering which takes into account neighbouring adjacent pixels of different colours before deciding whether or not to cap the pixel value. It also white balances the data before it performs this comparison, which is the cause of the various slopes of the diagonal lines. As a result, this algorithm is far less destructive to small tightly-focused stars occupying an area of just a few pixels.

The Nikon D800 is one of the models for which a firmware hack is available. With this hack applied, there is no hint of raw data filtering:



Nikon Z6

The Nikon Z6 mirrorless camera is a much newer camera and appears to have a more sophisticated raw data filtering algorithm. Here is the usual plot of a long exposure dark frame:



The strong diagonal with slope 1 is clear evidence of some kind of filtering but there is still a remnant of the vertical arm in the plot. In other words, a large number of isolated bright pixels are being left alone, unlike previous algorithms. The following plot shows that the behaviour is very similar in each colour channel:



I have not seen any evidence of destructive impact on stars.



Fujifilm GFX 50R

Here is the usual plot of a long exposure dark frame from a completely different camera - the Fujifilm GFX 50R:



There's a sharp discontinuity at a value of 1150 (which also appears in a histogram) and the vertical arm splits in two above that point. It causes unsaturated, undersampled stars to turn magenta


Conclusion

Many cameras show evidence of raw data filtering and in many cases this has a destructive impact on stars. This page serves as an introduction to the subject. A complete list of cameras known to filter the raw data is beyond the scope of this introduction but will hopefully be the subject of a future page.

Last updated by Mark Shelley: 11 April 2023 (astro@markshelley.co.uk)