#ifndef PP_IMAGE_DETREND_H
#define PP_IMAGE_DETREND_H

#include "pslib.h"
#include "psmodules.h"
#include "ppImageOptions.h"

// Cells to be used in the detrend
typedef struct {
    pmCell *input;                      // The input cell, to be operated upon
    pmCell *mask;                       // The bad pixel mask
    pmCell *bias;                       // The bias correction
    pmCell *dark;                       // The dark correction
    pmCell *flat;                       // The flat-field correction
} ppImageDetrend;


bool ppImageDetrendCell(ppImageDetrend *detrend, ppImageOptions *options, pmConfig *config);
bool ppImageDetrendMask(pmCell *cell, pmReadout *input, pmReadout *mask);
bool ppImageDetrendNonLinear(pmCell *cell, pmReadout *input, ppImageOptions *options);
bool ppImageDetrendNonLinearLookup(pmReadout *input, psMetadataItem *dataItem);
bool ppImageDetrendNonLinearPolynomial(pmReadout *input, psMetadataItem *dataItem);
bool ppImageDetrendBias(pmReadout *inputReadout, pmReadout *bias, pmReadout *dark, ppImageOptions *options);
pmReadout* ppImageDetrendSelectFirst(pmCell *cell, char *name, bool doThis);


#endif
