/* @file  pmStack.h
 *
 * This file will perform image combination of several images of the
 * same field, produce a list of questionable pixels, then tag some
 * of those pixels as defects.
 *
 * @author Paul Price, IfA
 * @author GLG, MHPCC
 *
 * @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
 * @date $Date: 2007-08-23 23:43:12 $
 *
 * Copyright 2004-2007 Institute for Astronomy, University of Hawaii
 */

#ifndef PM_STACK_H
#define PM_STACK_H

#include <pslib.h>
#include <pmHDU.h>
#include <pmFPA.h>

/// @addtogroup imcombine Image Combinations
/// @{


/// Container for input image
typedef struct {
    pmReadout *readout;                 ///< Warped readout (sky cell)
    psPixels *pixels;                   ///< Pixels to inspect or reject
    float weight;                       ///< Weight to apply
} pmStackData;

/// Constructor
pmStackData *pmStackDataAlloc(pmReadout *readout, ///< Warped readout (sky cell)
                              float weight ///< Weight to apply
    );

/// Stack input images
bool pmStackCombine(pmReadout *combined,///< Combined readout (output)
                    psArray *input,     ///< Input array of pmStackData
                    psMaskType maskVal, ///< Mask value of bad pixels
                    psMaskType bad,     ///< Mask value to give rejected pixels
                    int numIter,        ///< Number of iterations
                    float rej           ///< Rejection limit (standard deviations)
    );

#if 0
psImage *pmStackCombine(psImage *combine, ///< Combined image (output)
                        psArray **questionablePixels, ///< Array of rejection masks
                        const psArray *images, ///< Array of input images
                        const psArray *errors, ///< Array of input error images
                        const psArray *masks, ///< Array of input masks
                        psU32 maskVal,  ///< Mask value
                        const psPixels *pixels, ///< Pixels to combine
                        psS32 numIter,  ///< Number of rejection iterations
                        psF32 sigmaClip ///< Number of standard deviations at which to reject
);
#endif

#if 0
/// Reject pixles in input images
bool pmStackReject(psArray *input,      ///< Input array of pmStackData
                   psMaskType maskVal,  ///< Value to mask
                   float extent,        ///< Gaussian convolution extent, in Gaussian sigmas
                   float threshold      ///< Rejection threshold, in standard deviations
                   );
#endif

#if 0
psArray *pmStackReject(
    const psArray *images,              ///< Array of input images
    const psArray *masks,               ///< Array of input image masks
    const psArray *errors,              ///< The pixels which were rejected in the combination
    const psArray *inToOut,             ///< Transformation from input to output system
    const psArray *outToIn,             ///< Transformation from output to input system
    psF32 rejThreshold,                 ///< Rejection threshold
    psF32 gradLimit                     ///< Gradient limit
);
#endif

/// @}
#endif
