/** @file  pmReadoutCombine.h
 *
 *  This file will contain a module which will combine multiple readout images.
 *
 *  @author GLG, MHPCC
 *
 *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
 *  @date $Date: 2006-06-01 02:26:32 $
 *
 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
 *
 */

#if !defined(PM_READOUT_COMBINE_H)
#define PM_READOUT_COMBINE_H

#if HAVE_CONFIG_H
#include <config.h>
#endif

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

// Combination parameters for pmReadoutCombine.  These values define how the combination is performed, and
// should not vary by detector, so that it can be re-used for multiple combinations.
typedef struct
{
    psStatsOptions combine;             // Statistic to use when performing the combination
    psMaskType maskVal;                 // Mask value
    int nKeep;                          // Mimimum number of pixels to keep
    float fracHigh;                     // Fraction of high pixels to immediately throw
    float fracLow;                      // Fraction of low pixels to immediately throw
    int iter;                           // Number of iterations for clipping (for CLIPPED_MEAN only)
    float rej;                          // Rejection threshould for clipping (for CLIPPED_MEAN only)
}
pmCombineParams;

// Allocator
pmCombineParams *pmCombineParamsAlloc(psStatsOptions statsOptions // Statistic to use for combination
                                     );

// Combine multiple readouts, applying zero and scale, with optional minmax clipping
bool pmReadoutCombine(pmReadout *output,// Output readout; altered and returned
                      psArray *inputs,  // Array of input readouts (F32 image and weight, U8 mask)
                      const psVector *zero, // Zero corrections to subtract from input, or NULL
                      const psVector *scale, // Scale corrections to divide into input, or NULL
                      pmCombineParams *params // Combination parameters
                     );

#endif
