Hi,
when working with ImageIntegration, I was interested in understanding how Linear Fit Clipping
http://pixinsight.com/doc/tools/ImageIntegration/ImageIntegration.html#linear_fit_clipping works. As a result I wrote a simulator for this in R
http://www.r-project.org/, which is an open source tool for statistical analysis (R is available for all relevant platforms). I found it useful for understanding how Linear Fit Clipping works, and for experimenting with other rejection algorithms.
In the following, I would like to present the R script, how it works, and which results I found. I am publishing it in case there is someone who would like to experiment with this as well. The script is open source as specified in the header:
# (C) 2012 Georg Viehoever, except code for wle.poisson() .
# Permission is granted to use the code any way to like, but I would welcome if you make
# any derived work available as source as well.
#
# Code for wle.poisson() is licensed under GPL2, see header of this function
The script is attached below.
The ScriptImageIntegration works by creating a PixelStack of pixels at the same location in different images. It analyses the stack to remove outliers (e.g. from cosmic rays or airplanes), and integrates the remaining pixels into a true pixel value (e,g. by computing the average). The script provides a number of pixel rejection and integration algorithms (
PI.*Fit()), amongst them a reimplementation of the Linear Fit Clipping algorithm with averaging (
PI.linFit(), I hope my implementation derived
http://pixinsight.com/doc/tools/ImageIntegration/ImageIntegration.html#linear_fit_clipping is correct...).
Pixels (as modeled by the script, there are other sources like amplifier noise as well) receive noise (unwanted variation) from two sources: 1. Poisson noise due to the random nature of arriving photons, 2. impulse noise from airplains, cosmic rays, ... . The method
PI.genPixelStack(n=40,meanVal=maxVal/16,spikeProb=0.05,minVal=0,maxVal=16383) allows to generate such pixel stacks of size n, mean true value meanVal, a probility of uniform impulse noise of spikeProb with values in the [minVal,maxVal] interval. I think the defaults shown here make sense for my Canon EOS40D....
I can now evaluate the quality of a pixel rejection algorithm using the method
PI.fitExperiment(first=100,last=16300,runs=100,rep=100,sigma=2,spikeProb=0.05,fitFunc=PI.linFit). For runs different mean values in [first,last], it will do rep runs for each mean. It returns a table of the true mean, the estimated mean using the given fitFunc, and other values. A run with the default paramaters consumes 5-10 minutes on my laptop.
I can evaluate this table using commands from the R toolset. For example,
r.lin is the table regenerated for the PI LinearFitClipping algorithm.
boxplot(mean-estimate~mean,data=r.lin,ylim=range(-100,100)) creates a box plot (see screenshot 1) showing the difference between true mean and estimated mean. The closer the fat black bars are to 0, the better is the average estimate. The other boxes visualize the variance within the estimates. The smaller the variance, the less remaining noise has the image.
The script as delivered here will automatically compute some of those tables (see the last lines). It needs roughly 30 minutes for those.
Georg