Linear Fit (RGB)

ngc1535

PixInsight Ambassador
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
 
Hi Adam,

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.
 
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.
 
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
 
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
 
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
 
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.
 
Back
Top