Author Topic: What is 'happening' inside the BackgroundNeutralisation process?  (Read 4383 times)

Offline Niall Saunders

  • PTeam Member
  • PixInsight Jedi Knight
  • *****
  • Posts: 1456
  • We have cookies? Where ?
A question for Juan, methinks,

"Without giving away your 'trade secrets', Juan, what does BN actually do to the image?"

Obviously we start out with a specified area deemed to be 'the background'. The algorithm must then look at that area and decide that, of the three histograms, the 'peaks' do not coincide, and that there must therefore be a general 'colour cast' in this background area.

At that point, are the offending channels 'normalised' (correct terminology?) by 'addition' or by 'multiplication' - or by a 'combination of both'? Presumably two channels need to be 'normalised' to the third channel? If so, how does BN decide which of the three channels 'remains static', as some sort of 'reference' if you like?

Thanks in advance
Cheers,
Niall Saunders
Clinterty Observatories
Aberdeen, UK

Altair Astro GSO 10" f/8 Ritchey Chrétien CF OTA on EQ8 mount with homebrew 3D Balance and Pier
Moonfish ED80 APO & Celestron Omni XLT 120
QHY10 CCD & QHY5L-II Colour
9mm TS-OAG and Meade DSI-IIC

Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 7111
    • http://pixinsight.com/
Re: What is 'happening' inside the BackgroundNeutralisation process?
« Reply #1 on: 2010 November 09 13:11:01 »
Hi Niall,

Quote
"Without giving away your 'trade secrets', Juan, what does BN actually do to the image?"

There is no problem at all; I could even give you the source code of this process without any problems. Let me know if you are interested.

The BackgroundNeutralization task is actually very simple. For each nominal channel of the target image, let's define:

M0 is the initial median value calculated for all significant pixels. Significant pixels are those in the interval ]b0,b1], where b0 and b1 are the lower and upper limit parameters, respectively.

M1 is the final median value. This value is the same for all channels (or otherwise we wouldn't be normalizing). In the target background mode of BackgroundNeutralization, M1 is a user-defined value (the target background value). In the other working modes, we always have M1=0.

Then the neutralization phase consists of applying, for each pixel v0:

v1 = v0 + M1 - M0

Where v1 is the corresponding neutralized pixel value. After neutralization, the three channels will have the same median to an accuracy that normally is better than 0.00001. The achieved accuracy depends on the existing dispersion of values on background areas.

After neutralization, note that the image can have negative pixels and also pixels greater than one. Hence, some type of normalization is necessary. The tool provides four options: target background, rescale, rescale as needed and truncate:

- In target background mode any resulting out-of-range values will be truncated to the [0,1] interval, as this is the only way to force a user-defined, fixed background. This can cause some data clippings but they are usually negligible. Only additive operations are applied to the image (the neutralization formula above).

- In rescale mode the image will always be rescaled to keep all resulting pixel values while achieving a neutral background. In this mode you have no control over the final background values; you only know that the background will be neutral. Rescaling involves a multiplicative operation.

- In rescale as needed mode the image will only be rescaled if there are negative pixel values. This mode provides a better control over the final background, for example if a small pedestal is added before BackgroundNeutralization, in order to prevent negative values. This is the default mode.

- In truncate mode all out-of-range values will be truncated. This will result in clippings, which can be important.


Juan Conejero
PixInsight Development Team
http://pixinsight.com/

Offline Niall Saunders

  • PTeam Member
  • PixInsight Jedi Knight
  • *****
  • Posts: 1456
  • We have cookies? Where ?
Re: What is 'happening' inside the BackgroundNeutralisation process?
« Reply #2 on: 2010 November 09 13:30:24 »
Juan, thank-you for such a speedy reply.

I was asked the following question by Ron Wodaski - and I did not want to give him a 'best guess' answer (he deserves better than that !)

Ron asked :
Quote
Does BackgroundNeutralisation remove bias, balance color, or both?
and then clarified his question with
Quote
Just to be clear, by bias in this case I mean relative color bias, and correcting it involves aligning the black level in all planes

So, I take from your reply that the answer is, or at least can be, 'both'. I assume this because BN can, depending on its usage, perform both the 'additive' calculations that will remove, or set, a 'bias pedestal' AND it can perform the 'multiplicative' calculations that 'aligns the black level in all planes'. Am I close? (In fact, I have just realised that I am NOT 'close' - your explanation clearly shows that there is NO 'multiplication' involved - the 'neutralisation' algorithm is purely 'additive'. It is ONLY in the two 'rescale' modes where a 'multiplicative' operation is used to keep the data confined to the standard PI [0.0, 1.0] working range).

I now realise that, of course, BN does actually (or 'can' actually) affect all three colour planes, the intention being to bring the 'final median value' (M1 in your example) for EACH channel to the SAME VALUE (a vaue that is under reasonable user-control)

Can I go back to him with your explanation and my thoughts as above?
Cheers,
Niall Saunders
Clinterty Observatories
Aberdeen, UK

Altair Astro GSO 10" f/8 Ritchey Chrétien CF OTA on EQ8 mount with homebrew 3D Balance and Pier
Moonfish ED80 APO & Celestron Omni XLT 120
QHY10 CCD & QHY5L-II Colour
9mm TS-OAG and Meade DSI-IIC

Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 7111
    • http://pixinsight.com/
Re: What is 'happening' inside the BackgroundNeutralisation process?
« Reply #3 on: 2010 November 09 14:46:16 »
Hi Niall,

Quote
Can I go back to him with your explanation and my thoughts as above?

Sure. You can also implement background neutralization with PixelMath, in case you want to make some tests. For example, the PixelMath expression would be:

$T - med( $T ) + 0.05

for a target median value of 0.05. The above expression must be applied with the rescaling option of PixelMath disabled. As you see the background neutralization procedure is very simple.

Note however, that background neutralization is not a color calibration procedure. In other words, a neutral background does not guarantee a valid color balance --to some plausible definition of valid, as the concept of real color does not exist in astrophotography. For example, our ColorCalibration tool applies a documentary criterion for color calibration, which pursues maximization of information representation through color, and is spectrum-agnostic, that is, it doesn't favor any specific color or spectral type as a white reference.
Juan Conejero
PixInsight Development Team
http://pixinsight.com/

Offline Niall Saunders

  • PTeam Member
  • PixInsight Jedi Knight
  • *****
  • Posts: 1456
  • We have cookies? Where ?
Re: What is 'happening' inside the BackgroundNeutralisation process?
« Reply #4 on: 2010 November 09 16:16:57 »
As usual Juan,

Thanks for taking the time to help clarify things.

In fact, your answer is actually pretty close to the documentation needed for the BackgroundNeutralisation section of the PixInsight user manual  ::)
Cheers,
Niall Saunders
Clinterty Observatories
Aberdeen, UK

Altair Astro GSO 10" f/8 Ritchey Chrétien CF OTA on EQ8 mount with homebrew 3D Balance and Pier
Moonfish ED80 APO & Celestron Omni XLT 120
QHY10 CCD & QHY5L-II Colour
9mm TS-OAG and Meade DSI-IIC