Author Topic: What is a linear verus non-linear image?  (Read 9089 times)

Offline LD

  • PixInsight Enthusiast
  • **
  • Posts: 86
What is a linear verus non-linear image?
« on: 2007 November 30 08:30:54 »
The latest tutorials say that various processes should only be enacted on linear images. Does this mean an image that has had absolutely no non-linear stretches or transforms applied to it? In other words, if I either move the mid-tones slider in Histograms Transform or apply any move in Curves, is that image now  and forever "non-linear?" Or does it become linear again if it is saved as a new image? Obviously the answer will impact the flow of processing as I often apply curves to get my contrast right before applying various filters (HDRWavelets, noise reduction, etc.).
Thanks for any help,
Larry Durst

Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 7111
    • http://pixinsight.com/
What is a linear verus non-linear image?
« Reply #1 on: 2007 November 30 09:04:44 »
Hi Larry,

An image is linear if the values of its pixels follow a linear function of the source intensities.

In simple words: Suppose we have three pixels A, B, C, such that:

B has received twice as much light as A
C has received twice as much light as B

then if the image is linear, we have:

B/A = C/B = constant

(replace the word 'twice' above by any constant)

This happens with most digital raw images -CCD and DSLR raw images-, because they have been acquired with linear sensors. This does not happen with nonlinear media, such as film for example.

If you apply a HistogramTransform with a midtones balance  different from 0.5, or a curve with CurvesTransform that isn't a straight line, then your image will no longer be linear.

However, if you manage to find an inverse transformation, then you can put the image back to a linear distribution. Suppose that you have applied a histogram transform with midtones balance = 0.005. Then a midtones balance = 1 - 0.005 = 0.995 is the inverse transformation. With CurvesTransform the situation is more complex, but in theory any curve has an inverse curve that unwises it. Of course, this usually requires working with sufficient accuracy, i.e. with a floating point format or the 32-bit integer format, or roundoff errors may become a serious problem.

In general, a linear image is preferable to work with detail enhancement techniques. Deconvolution must in fact be applied to linear images for physical reasons. As you can see in the last tutorial, ATrousWaveletTransform also performs much better with linear images. Numerically, a linear image is much more controllable because all pixels are mutually linked by the simplest possible function (a straight line).
Juan Conejero
PixInsight Development Team
http://pixinsight.com/

Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 7111
    • http://pixinsight.com/
Re: What is a linear verus non-linear image?
« Reply #2 on: 2007 November 30 09:17:08 »
I forgot to answer this:

Quote
I often apply curves to get my contrast right before applying various filters (HDRWavelets, noise reduction, etc.).


HDRWaveletTransform is a bit special. It usually doesn't perform well with linear images, so you must stretch your image before applying it. However, if HDRWT is properly used (i.e. if not applied to too few layers), it doesn't change the linearity (or non-linearity) of the data at small scales. So you can apply a HistogramTransform with midtones = m, apply HDRWT, then HistogramTransform again with m' = 1 - m. The resulting image is linear at small scales, and it hence can be deconvolved. We have used this "trick" successfully sometimes, and in fact a first version of the deconvolution tutorial (which I decided not to publish due to its excessive complexity) used this technique.

However, the "standard" recommended tecnique is to apply HDRWT to the stretched image, after deconvolution and other restoration or detail enhancement techniques.

We usually apply noise reduction to nonlinear images, that is to stretched images. The ACDNR algorithm requires significant structures well separated in terms of local contrast.
Juan Conejero
PixInsight Development Team
http://pixinsight.com/

Offline LD

  • PixInsight Enthusiast
  • **
  • Posts: 86
What is a linear verus non-linear image?
« Reply #3 on: 2007 November 30 09:42:39 »
Thank you, Juan. That was fast! That's good news for me about HDRWavelets.
Larry

Offline Jack Harvey

  • PTeam Member
  • PixInsight Padawan
  • ****
  • Posts: 975
    • PegasusAstronomy.com & Starshadows.com
Linear vs non Linear
« Reply #4 on: 2007 December 02 08:08:47 »
This is an interesting thread for me.  In fact I see it changing the work flow for my processing.  Like the vast majority of imagers I used adjustments with the gamma and the curves tool in the initial steps of preparing the image for processing.  Now with the screen stretch I can just use the linear aspects of the histogram and not touch the gamma, Curves or Saturation until the very last steps.  Thus I have turned my processing ass backwards<G>.  I think this should give me much more realistic images in terms of color balance etc.  I re processed my 2070 and got surprisingly much better colors and results IMO.

Juan you said the use of STF tool was covered in a previous tutorial - but I cannot seem to find it.  Can you point me there.  It does seem pretty intuitive but I just want to see that I don't miss a few tips or shortcuts.
Jack Harvey, PTeam Member
Team Leader, SSRO/PROMPT Imaging Team, CTIO