detlin.h

00001 #ifndef DETLIN_H
00002 #define DETLIN_H
00003 
00004 /*******************************************************************************
00005 * E.S.O. - VLT project
00006 *
00007 * "@(#) $Id: detlin.h,v 1.6 2005/04/19 11:38:19 amodigli Exp $"
00008 *
00009 * who       when      what
00010 * --------  --------  ----------------------------------------------
00011 * schreib  18/04/02  created
00012 */
00013 
00014 /************************************************************************
00015  * detlin.h
00016  * detector linearity routines
00017  * to search for static bad pixels
00018  *----------------------------------------------------------------------
00019  */
00020 
00021 /*
00022  * header files
00023  */
00024 
00025 /*
00026 #include <stdio.h>
00027 #include <cpl.h>
00028 */
00029 /* 
00030 #include <xmemory.h> 
00031 #include "spiffi_types.h"
00032 #include "eclipse.h"
00033 #include "recipes.h"
00034 #include <math.h>
00035 */
00036 #include "cube_ops.h"
00037 #include <qfits.h>
00038 
00039 /*----------------------------------------------------------------------------
00040  *                      Function ANSI C prototypes
00041  *--------------------------------------------------------------------------*/
00042 
00043 /*----------------------------------------------------------------------------
00044    Function     :       fitIntensityCourse()
00045    In           :       flatStack: flats with in/decreasing intensity
00046                                    stacked in a data cube
00047                         order:     order of the fit polynomial
00048    Out          :       data cube containing the fit result.
00049                         the first polynomial coefficients in the first plane
00050                         and so on.
00051    Job          :       this routine fits polynomials along the z-axis of
00052                         a data cube and stores the resulting coefficients
00053                         in a data cube. The eclipse routine fit_1d_poly()
00054                         is used for polynomial fitting
00055                         The input is assumed to be a cube containing flatfield frames of
00056                         different intensities (usually increasing or decreasing).
00057                         for each pixel position on the detector, a curve is plotted
00058                         of the pixel intensity in each plane against the clean mean
00059                         intensity of the plane. Then a polynomial of user defined
00060                         order is fitted to the curves.
00061  ---------------------------------------------------------------------------*/
00062 
00063 /*<python>*/
00064 OneCube * fitIntensityCourse( OneCube * flatStack,
00065                               int       order,
00066                               float     loReject,
00067                               float     hiReject ) ;
00068 /*</python>*/
00069 
00070 /*----------------------------------------------------------------------------
00071    Function     :       searchBadPixels()
00072    In           :       coeffs: fitted polynomial coefficients
00073                                 stored in a cube
00074                         threshSigmaFactor: factor of determined sigma of an
00075                                            image plane to determine the
00076                                            threshold for good or bad pixels
00077                         nonlinearThresh:   absolute threshold value of the found
00078                                            non-linear polynomial coefficients beyond
00079                                            which the pixels are declared as bad.
00080                         loReject, hiReject: percentage (0...100) of extreme pixel
00081                                             values that is not considered for image
00082                                             statistics
00083    Out          :       Bad pixel mask image (1: good pixel, 0: bad pixel).
00084    Job          :       this routine searches for static bad pixel positions
00085                         by searching the fitted polynomial coefficients of each pixel response
00086                         for outliers.
00087                         Pixel with high non-linear response are also declared as bad.
00088  ---------------------------------------------------------------------------*/
00089 /*<python>*/
00090 OneImage * searchBadPixels( OneCube *  coeffs,
00091                             double     threshSigmaFactor,
00092                             double     nonlinearThresh,
00093                             float      loReject,
00094                             float      hiReject ) ;
00095 /*</python>*/
00096 
00097 /*----------------------------------------------------------------------------
00098    Function     :       searchBadPixelsViaNoise()
00099    In           :       darks: sequence of darks (NDIT = 1)
00100                                stored in a cube, at least 10 to get good statistics
00101                         threshSigmaFactor: factor to determined standard deviation
00102                                            in each pixel to determine the threshold
00103                                            beyond which a pixel is declared as bad.
00104                         loReject, hiReject: percentage (0...100) of extreme pixel
00105                                             values that is not considered for image
00106                                             statistics
00107    Out          :       Bad pixel mask image (1: good pixel, 0: bad pixel).
00108    Job          :       this routine searches for static bad pixel positions
00109                         This is done by building a cube of dark frames and examine
00110                         the noise variations in each pixel. If big deviations
00111                         from a clean mean pixel noise occurr, the pixel is
00112                         declared as bad.
00113  ---------------------------------------------------------------------------*/
00114 /*<python>*/
00115 OneImage * searchBadPixelsViaNoise( OneCube *  darks,
00116                                     float      threshSigmaFactor,
00117                                     float      loReject,
00118                                     float      hiReject ) ;
00119 /*</python>*/
00120 
00121 /*----------------------------------------------------------------------------
00122    Function     :       countBadPixels()
00123    In           :       bad: bad pixel mask
00124    Out          :       number of bad pixels.
00125    Job          :       this routine counts the number of bad pixels
00126  ---------------------------------------------------------------------------*/
00127 
00128 /*<python>*/
00129 int countBadPixels ( OneImage * bad ) ;
00130 /*</python>*/
00131 
00132 /*----------------------------------------------------------------------------
00133    Function     :       meanImageInSpec()
00134    In           :       image, a threshold parameter
00135    Out          :       resulting image
00136    Job          :       mean filter, calculates the mean for an image
00137                         by using the 4 closest pixels of every pixel in spectral direction
00138                         (column).
00139                         The values in the output image are determined according
00140                         to the values of the input parameter.
00141                         If fmedian = 0: always replace by mean
00142                         if fmedian < 0: replace by mean if |pixel - mean| >
00143                                         -fmedian
00144                         if fmedian > 0: replace by mean (fmedian as a factor of
00145                                         the square root of the mean itself)
00146                                         if |pixel - mean| >= fmedian * sqrt ( mean )
00147                                         This can be used to consider photon noise.
00148                                         This considers a dependence of the differences on the
00149                                         pixel values themselves.
00150    Notice       :       it is assumed that most of the 4 nearest neighbor pixels
00151                         are not bad pixels!
00152                         blank pixels are not replaced!
00153  ---------------------------------------------------------------------------*/
00154 
00155 /*<python>*/
00156 OneImage * meanImageInSpec( OneImage * im, float fmedian ) ;
00157 /*</python>*/
00158 
00159 
00160 /*----------------------------------------------------------------------------
00161    Function     :       absDistImage()
00162    In           :       image, a threshold parameter
00163    Out          :       resulting image
00164    Job          :       filter, calculates the absolute distances
00165                         of the nearest neighbors for an image
00166                         by using the 8 closest pixels of every pixel.
00167                         The values in the output image are determined according
00168                         to the values of the input parameter.
00169                         If fmedian = 0: always replace by abs. distances
00170                         if fmedian < 0: replace by abs. distances if |median_dist - dist| >
00171                                         -fmedian
00172                         if fmedian > 0: replace by abs. distances (fmedian as a factor of
00173                                         the square root of the distance itself)
00174                                         if |median_dist - dist| >= fmedian * sqrt ( dist )
00175                                         This can be used to consider photon noise.
00176                                         This considers a dependence of the differences on the
00177                                         pixel values themselves.
00178    Notice       :       it is assumed that most of the 8 nearest neighbor pixels
00179                         are not bad pixels!
00180                         blank pixels are not replaced!
00181  ---------------------------------------------------------------------------*/
00182 
00183 /*<python>*/
00184 OneImage * absDistImage( OneImage * im, float fmedian ) ;
00185 /*</python>*/
00186 
00187 /*----------------------------------------------------------------------------
00188    Function     :       localMedianImage()
00189    In           :       im: input image
00190                         fmedian:  a factor to the local standard deviation
00191                         loReject, hiReject: fraction of rejected values to determine
00192                                             a clean standard deviation
00193                         half_box_size: integer half size of the running box to determine
00194                                        the local clean standard deviation
00195    Out          :       resulting image
00196    Job          :       filter, calculates the local stdev in a moving box
00197                         Then it calculates the difference of the pixel to the median
00198                         of the nearest neighbors
00199                         by using the 8 closest pixels of every pixel.
00200                         The values in the output image are determined according
00201                         to the values of the input parameter.
00202                         If fmedian = 0: always replace by median
00203                         if fmedian > 0: replace median if |median_dist - dist| >
00204                                         fmedian * stdev
00205    Notice       :       it is assumed that most of the 8 nearest neighbor pixels
00206                         are not bad pixels!
00207                         blank pixels are not replaced!
00208  ---------------------------------------------------------------------------*/
00209 
00210 /*<python>*/
00211 OneImage * localMedianImage( OneImage * im,
00212                              float fmedian,
00213                              float loReject,
00214                              float hiReject,
00215                              int half_box_size ) ;
00216 /*</python>*/
00217 
00218 /*----------------------------------------------------------------------------
00219    Function     :       localMedianImage2()
00220    In           :       im: input image
00221                         fmedian:  a factor to the local standard deviation
00222                         loReject, hiReject: fraction of rejected values to determine
00223                                             a clean standard deviation
00224                         half_box_size: integer half size of the running box to determine
00225                                        the local clean standard deviation
00226    Out          :       resulting image
00227    Job          :       filter, calculates the local stdev in a moving box
00228                         Then it calculates the difference of the pixel to the
00229                         clean mean of the moving box.
00230                         The values in the output image are determined according
00231                         to the values of the input parameter.
00232                         If fmedian = 0: always replace by clean mean
00233                         if fmedian < 0: replace clean mean if |cleanmean - dist| >
00234                                         fmedian * stdev
00235                         if fmedian > 0: replace by clean mean (fmedian as a factor of
00236                                         the square root of the clean mean itself)
00237                                         if |pixel - cleanmean| >= fmedian * sqrt ( cleanmean )
00238                                         This can be used to consider photon noise.
00239                                         This considers a dependence of the differences on the
00240                                         pixel values themselves.
00241    Notice       :       it is assumed that most of the 8 nearest neighbor pixels
00242                         are not bad pixels!
00243                         blank pixels are not replaced!
00244  ---------------------------------------------------------------------------*/
00245 
00246 /*<python>*/
00247 OneImage * localMedianImage2( OneImage * im,
00248                              float fmedian,
00249                              float loReject,
00250                              float hiReject,
00251                              int half_box_size ) ;
00252 /*</python>*/
00253 
00254 
00255 
00256 #endif 
00258 /*--------------------------------------------------------------------------*/

Generated on Wed Oct 26 13:08:52 2005 for SINFONI Pipeline Reference Manual by doxygen1.2.13.1 written by Dimitri van Heesch, © 1997-2001