Author Topic: Linear Fit (RGB)  (Read 8560 times)

Offline ngc1535

  • PixInsight Old Hand
  • ****
  • Posts: 326
Linear Fit (RGB)
« on: 2014 August 06 15:08:35 »
Hi,

There are multiple references to applying Linear Fit to RGB channels/images.
I understand you can model a line (y=mx+b) between the two images and determine b (the offset) and m (the slope/multiplicative coefficient).

However, by matching (fitting) a channel to a reference it will multiply by a number that equals the slope of the reference image. Wouldn't this assign a (meaningless) ratio between images. Assuming the detector (or system) response is 1:1:1- no problem! However, the system (and sky conditions) ultimately determine the ratio. As I learned at the PI workshop the coefficients can be set by using white sources like galaxies.

The question I have is, why apply a Linear Fit and mess with channel ratios? The offset will certainly be taken care of- but this can be done by NeutralizeBackground. I think I am missing something...

(I do understand that it is good to match a channel like Ha to Red etc... Linear Fit does good stuff here...)

Thanks in advance,
Adam

Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 7111
    • http://pixinsight.com/
Re: Linear Fit (RGB)
« Reply #1 on: 2014 September 09 09:26:57 »
Hi Adam,

Quote
However, by matching (fitting) a channel to a reference it will multiply by a number that equals the slope of the reference image. Wouldn't this assign a (meaningless) ratio between images.

To understand how the LinearFit tool works, it is useful to describe the main steps that it performs:

- We have two images, which the tool indentifies as reference and target. For simplicity, call these images R and T, respectively. Also for simplicity, assume that the pixels in both images have a single component; the process extends trivially to multichannel data such as RGB color images.

- Generate a set P of pixel value pairs: P := {{r1,t1}, ..., {rN,tN}}, where each ri is a pixel of the reference image, and its ti companion is the corresponding pixel at the same coordinates of the target image. The set P is formed with the subset of pixels of R and T whose values are within the range defined by the reject low and reject high parameters.

- Fit a straight line to all the points in the set P. Essentially, we are considering here that the components of each pair {ri,ti} are the X and Y coordinates of a point on the plane. The current versions of LinearFit implement a robust fitting algorithm based on mean absolute deviation minimization. With a few changes to adapt it to our platform, the algorithm has been described in Reference 1. The fitted line can be characterized by the usual parameters: Y axis intercept (b) and slope (m): y = mx + b. This linear function attempts to represent the "average difference", so to say, between R and T. For example, if R = T, then we obviously have m=1 and b=0.

- Apply the fitted linear function to all the pixels in T.

The result of this operation is that the target image T is adapted to match the reference image R. In fact, perhaps a better name for this tool would be LinearMatch, instead of LinearFit, because the term match represents more closely what it actually does. So the key concept here is that we are fitting a straight line to represent the difference between two images, not the distribution of pixel values in one of the images.


[1] W. H. Press et al. (2007) Numerical Recipes, The Art of Scientific Computing Third Edition, Cambridge University Press, Sect. 15.7.3, pp. 822-824.
Juan Conejero
PixInsight Development Team
http://pixinsight.com/

Offline jerryyyyy

  • PixInsight Old Hand
  • ****
  • Posts: 425
    • Astrobin Images
Re: Linear Fit (RGB)
« Reply #2 on: 2014 September 10 08:01:19 »
Hey, here's my simple explanation, if you do NOT do a linear fit with RGB components, the image will look screwed up in terms of colors... merge with and without the linear fit and you will see the difference. Also, when you view the finished product make sure the link button is pushed on the STF. 

I am not sure if it is needed, but I do this on my narrow band images also when merged for the Hubble Pallet or equivalents.
Takahashi 180ED
Astrophysics Mach1
SBIG STT-8300M and Nikon D800
PixInsight Maxim DL 6 CCDComander TheSkyX FocusMax

Offline topboxman

  • PixInsight Addict
  • ***
  • Posts: 292
    • Peter's Gallery
Re: Linear Fit (RGB)
« Reply #3 on: 2014 September 10 08:34:21 »
What's the best reference image to use for Linear FIT for let's say RGB images? Red images tend to have histogram furthest to the left (toward black point) so would Red image be the best reference for Linear FIT?

I have tried Linear FIT in the past but never see much difference. DBE, Background Neutralization and Color Calibration take care of balancing the colors if I don't use Linear FIT.

Peter

Offline jkmorse

  • PixInsight Padawan
  • ****
  • Posts: 931
  • Two questions, Mitch . .
    • Jim Morse Astronomy
Re: Linear Fit (RGB)
« Reply #4 on: 2014 September 11 10:45:07 »
Peter,

I use LinearFit regularly and use the Red as my reference doc.  I agree that on the right image using LF versus background neutralization and ColorCalibration doen't show much difference (though I still prefer what I get from LFit in side by sides).  But where LFit really shines is where you are dealing with lots of nebulosity or a galaxy that doesn't give you a really clean white point reference (M51 comes to mind with all those wonderful blues).

For what it's worth.

Jim
Really, are clear skies, low wind and no moon that much to ask for? 

New Mexico Skies Observatory
Apogee Aspen 16803
Planewave CDK17 - Paramount MEII
Planewave IFR90 - Astrodon LRGB & NB filters
SkyX - MaximDL - ACP

http://www.jimmorse-astronomy.com
http://www.astrobin.com/users/JimMorse

Offline topboxman

  • PixInsight Addict
  • ***
  • Posts: 292
    • Peter's Gallery
Re: Linear Fit (RGB)
« Reply #5 on: 2014 September 11 13:08:45 »
Hi Jim,

What you said might make sense. But I am not sure I would treat Linear FIT as an alternative to color calibration. I agree that it's difficult to use PI's color calibration tools (DBE, BN, CC) if the majority or whole image is covered with nebulosity.

Peter

Offline M Covington

  • Member
  • *
  • Posts: 65
Re: Linear Fit (RGB)
« Reply #6 on: 2018 January 20 22:04:04 »
For what it's worth, FIT is not an abbreviation -- it's just the word "fit."  The algorithm fits one image to the brightness range of another.