IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 1822


Ignore:
Timestamp:
Sep 16, 2004, 2:49:04 PM (22 years ago)
Author:
harman
Message:

Updated per conversations with Robert DeSonia and Paul Price

Location:
trunk/psModules/src
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/Makefile.am

    r1786 r1822  
    22bin_PROGRAMS = tst_pmFlatField
    33
    4 libpsmodule_a_SOURCES = pmFlatField.c
    5 libpsmodule_a_HEADERS =  pmFlatField.h
     4libpsmodule_a_SOURCES = pmFlatField.c pmMaskBadPixels.c
     5libpsmodule_a_HEADERS = pmFlatField.h pmMaskBadPixels.h
    66libpsmodule_adir = .
    77
  • trunk/psModules/src/Makefile.in

    r1792 r1822  
    134134bin_PROGRAMS = tst_pmFlatField
    135135
    136 libpsmodule_a_SOURCES = pmFlatField.c
    137 libpsmodule_a_HEADERS = pmFlatField.h
     136libpsmodule_a_SOURCES = pmFlatField.c pmMaskBadPixels.c
     137libpsmodule_a_HEADERS = pmFlatField.h pmMaskBadPixels.h
    138138libpsmodule_adir = .
    139139
     
    149149libpsmodule_a_AR = $(AR) cru
    150150libpsmodule_a_LIBADD =
    151 am_libpsmodule_a_OBJECTS = pmFlatField.$(OBJEXT)
     151am_libpsmodule_a_OBJECTS = pmFlatField.$(OBJEXT) \
     152        pmMaskBadPixels.$(OBJEXT)
    152153libpsmodule_a_OBJECTS = $(am_libpsmodule_a_OBJECTS)
    153154bin_PROGRAMS = tst_pmFlatField$(EXEEXT)
     
    163164am__depfiles_maybe = depfiles
    164165@AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/pmFlatField.Po \
     166@AMDEP_TRUE@    ./$(DEPDIR)/pmMaskBadPixels.Po \
    165167@AMDEP_TRUE@    ./$(DEPDIR)/tst_pmFlatField.Po
    166168COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
     
    279281
    280282@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pmFlatField.Po@am__quote@
     283@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pmMaskBadPixels.Po@am__quote@
    281284@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tst_pmFlatField.Po@am__quote@
    282285
  • trunk/psModules/src/pmFlatField.c

    r1815 r1822  
    1 /** @file  pmFlatField.cS
     1/** @file  pmFlatField.c
    22 *
    3  *  @brief Given an input image and a flat-field image, pmFlatField shall divide the input image by the flat-field image.
     3 *  @brief Given an input image and a flat field image, pmFlatField shall divide the input image by the flat
     4 *  field image.
    45 *
    5  *  The input image, in, and the flat-field image, flat, need not be the same size, since the input image may already have
    6  *  been trimmed (following overscan subtraction), but the function shall use the offsets in the image (in->x0
    7  *  and in->y0) to determine the appropriate offsets to obtain the correct pixel on the flat-field. In the event that the flat
    8  *  image is too small (i.e., pixels on the input image refer to pixels outside the range of the flat image), the function shall
    9  *  generate an error. Pixels which are negative or zero in the flat shall be masked in the input image with the value PM_MASK_FLAT
    10  *  Negative pixels in the flat may be set to zero so that they are treated identically to zeroes. Any pixels masked in the flat
    11  *  shall be masked with corresponding values in the output. The function shall not normalize the flat; this responsibility is
    12  *  left to the caller. This function is basically equivalent to a divide (with psImageOp), but with care for the region that is
    13  *  divided, checking for negative pixels, and copying of the mask from the flat to the output.
     6 *  The input image, in, and the flat field image, flat, need not be the same size, since the input image may
     7 *  already have been trimmed (following overscan subtraction), but the function shall use the offsets in the
     8 *  image (in->x0 and in->y0) to determine the appropriate offsets to obtain the correct pixel on the flat
     9 *  field. In the event that the flat image is too small (i.e., pixels on the input image refer to pixels
     10 *  outside the range of the flat image), the function shall generate an error. Pixels which are negative or
     11 *  zero in the flat shall be masked in the input image with the value PM_MASK_FLAT. Negative pixels in the
     12 *  flat may be set to zero so that they are treated identically to zeroes. Any pixels masked in the flat
     13 *  shall be masked with corresponding values in the output. The function shall not normalize the flat; this
     14 *  responsibility is left to the caller. This function is basically equivalent to a divide (with psImageOp),
     15 *  but with care for the region that is divided, checking for negative pixels, and copying of the mask from
     16 *  the flat to the output.
    1417 *
    1518 *  @author Ross Harman, MHPCC
    1619 *
    17  *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
    18  *  @date $Date: 2004-09-15 01:08:23 $
     20 *  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
     21 *  @date $Date: 2004-09-17 00:49:04 $
    1922 *
    2023 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2932
    3033#include "pmFlatField.h"
     34#include "pmMaskBadPixels.h"
    3135
    32 
    33 #define CHECK_NULL(STRUCT)                                                                                   \
    34 if (STRUCT == NULL) {                                                                                        \
    35     psError(__func__, " : Line %d - Null not allowed for %s", __LINE__, #STRUCT);                            \
    36     return false;                                                                                            \
    37 }                                                                                                            \
    38 
    39 bool pmFlatField(psReadout *in, psReadout *inMask, const psReadout *flat)
     36bool pmFlatField(psReadout *in, const psReadout *flat)
    4037{
    4138    int i = 0;
     
    4744    psElemType maskType;
    4845    psImage *inImage = NULL;
     46    psImage *inMask = NULL;
    4947    psImage *flatImage = NULL;
    50     psImage *maskImage = NULL;
    5148
    52     CHECK_NULL(in);
    53     CHECK_NULL(flat);
    54     CHECK_NULL(inMask);
    5549
    56     inImage = in->image;
    57     flatImage = flat->image;
    58     maskImage = inMask->image;
    59 
    60     CHECK_NULL(inImage);
    61     CHECK_NULL(flatImage);
    62     CHECK_NULL(maskImage);
    63 
    64     totOffCol = inImage->col0 + in->col0;
    65     totOffRow = inImage->row0 + in->row0;
    66 
    67     if(inImage->numRows > flatImage->numRows) {
    68         psError(__func__, " : Line %d - Input image exceeds flat image in number of rows. (%d vs %d).",
    69                 __LINE__, inImage->numRows, flatImage->numRows);
     50    // Check for nulls
     51    if (in == NULL) {
     52        psError(__func__, " : Line %d - Null not allowed for input readout", __LINE__);
     53        return false;
     54    } else if(flat==NULL) {
     55        psError(__func__, " : Line %d - Null not allowed for flat readout", __LINE__);
    7056        return false;
    7157    }
    7258
    73     if(inImage->numCols > flatImage->numCols) {
    74         psError(__func__, " : Line %d - Input image exceeds flat image in number of columns. (%d vs %d).",
     59    inImage = in->image;
     60    inMask = in->mask;
     61    flatImage = flat->image;
     62    if (inImage == NULL) {
     63        psError(__func__, " : Line %d - Null not allowed for input image", __LINE__);
     64        return false;
     65    } else if(flatImage) {
     66        psError(__func__, " : Line %d - Null not allowed for flat image", __LINE__);
     67        return false;
     68    } else if(inMask == NULL) {
     69        inMask = psImageAlloc(inImage->numCols, inImage->numRows, PS_TYPE_MASK);
     70    }
     71
     72    // Check input image and its mask are not larger than flat image
     73    if(inImage->numRows > flatImage->numRows) {
     74        psError(__func__, " : Line %d - Input image exceeds mask image in number of rows. (%d vs %d).",
     75                __LINE__, inImage->numRows, flatImage->numRows);
     76        return false;
     77    } else if(inImage->numCols > flatImage->numCols) {
     78        psError(__func__, " : Line %d - Input image exceeds mask image in number of columns. (%d vs %d).",
     79                __LINE__, inImage->numCols, flatImage->numCols);
     80        return false;
     81    } else if(inMask->numRows > flatImage->numRows) {
     82        psError(__func__, " : Line %d - Input image mask exceeds mask image in number of rows. (%d vs %d).",
     83                __LINE__, inImage->numRows, flatImage->numRows);
     84        return false;
     85    } else if(inMask->numCols > flatImage->numCols) {
     86        psError(__func__, " : Line %d - Input image mask exceeds mask image in number of columns. (%d vs %d).",
    7587                __LINE__, inImage->numCols, flatImage->numCols);
    7688        return false;
    7789    }
    7890
     91    // Determine total offset based on image offset with chip offset
     92    totOffCol = inImage->col0 + in->col0;
     93    totOffRow = inImage->row0 + in->row0;
     94
     95    // Check that offsets are within image limits
    7996    if(totOffRow > flatImage->numRows-1) {
    80         psError(__func__, " : Line %d - Initial row offset exceeds that of flat image. (%d vs %d).",
     97        psError(__func__, " : Line %d - Initial row offset exceeds that of mask image. (%d vs %d).",
    8198                __LINE__, totOffRow, flatImage->numRows);
     99        return false;
     100    } else if(totOffCol > flatImage->numCols-1) {
     101        psError(__func__, " : Line %d - Initial column offset exceeds that of mask image. (%d vs %d).",
     102                __LINE__, totOffCol, flatImage->numCols);
     103        return false;
     104    } else if(totOffRow > inImage->numRows-1) {
     105        psError(__func__, " : Line %d - Initial row offset exceeds that of input image. (%d vs %d).",
     106                __LINE__, totOffRow, inImage->numRows);
     107        return false;
     108    } else if(totOffCol > inImage->numCols-1) {
     109        psError(__func__, " : Line %d - Initial column offset exceeds that of input image. (%d vs %d).",
     110                __LINE__, totOffCol, inImage->numCols);
     111        return false;
     112    } else if(totOffRow > inMask->numRows-1) {
     113        psError(__func__, " : Line %d - Initial row offset exceeds that of input image mask. (%d vs %d).",
     114                __LINE__, totOffRow, inMask->numRows);
     115        return false;
     116    } else if(totOffCol > inMask->numCols-1) {
     117        psError(__func__, " : Line %d - Initial column offset exceeds that of input image mask. (%d vs %d).",
     118                __LINE__, totOffCol, inMask->numCols);
    82119        return false;
    83120    }
    84121
    85     if(totOffCol > flatImage->numCols-1) {
    86         psError(__func__, " : Line %d - Initial column offset exceeds that of flat image. (%d vs %d).",
    87                 __LINE__, totOffCol, flatImage->numCols);
    88         return false;
    89     }
    90 
    91     if(totOffRow > inImage->numRows-1) {
    92         psError(__func__, " : Line %d - Initial row offset exceeds that of input image. (%d vs %d).",
    93                 __LINE__, totOffRow, inImage->numRows);
    94         return false;
    95     }
    96 
    97     if(totOffCol > inImage->numCols-1) {
    98         psError(__func__, " : Line %d - Initial column offset exceeds that of input image. (%d vs %d).",
    99                 __LINE__, totOffCol, inImage->numCols);
    100         return false;
    101     }
    102 
     122    // Check for incorrect types
    103123    inType = inImage->type.type;
    104124    flatType = flatImage->type.type;
    105     maskType = maskImage->type.type;
    106 
     125    maskType = inMask->type.type;
    107126    if(PS_IS_PSELEMTYPE_COMPLEX(inType)) {
    108         psError(__func__, " : Line %d - Complex types not allowed for input image", __LINE__);
     127        psError(__func__, " : Line %d - Complex types not allowed for input image. Type: %d", __LINE__,
     128                inType);
    109129        return false;
    110     }
    111 
    112     if(PS_IS_PSELEMTYPE_COMPLEX(flatType)) {
    113         psError(__func__, " : Line %d - Complex types not allowedfor flat image", __LINE__);
     130    } else if(PS_IS_PSELEMTYPE_COMPLEX(flatType)) {
     131        psError(__func__, " : Line %d - Complex types not allowed for flat image. Type: %d", __LINE__,
     132                flatType);
    114133        return false;
    115     }
    116 
    117     if(PS_IS_PSELEMTYPE_COMPLEX(maskType)) {
    118         psError(__func__, " : Line %d - Complex types not allowed for mask image", __LINE__);
     134    } else if(maskType != PS_TYPE_MASK) {
     135        psError(__func__, " : Line %d - Mask must be PS_TYPE_MASK type. Type: %d", __LINE__, maskType);
    119136        return false;
    120     }
    121 
    122     if(PS_IS_PSELEMTYPE_REAL(maskType)) {
    123         psError(__func__, " : Line %d - Floating point types not allowed for mask image", __LINE__);
    124         return false;
    125     }
    126 
    127     if(inType != flatType) {
    128         psError(__func__, " : Line %d - Input and flat image types don't agree. (%d vs %d).",
    129                 __LINE__, inType, flatType);
     137    } else if(inType != flatType) {
     138        psError(__func__, " : Line %d - Input and flat image types differ. (%d vs %d)", __LINE__, inType,
     139                flatType);
    130140        return false;
    131141    }
     
    133143    // Macro for all PS types
    134144    #define PM_FLAT_DIVISION(TYPE)                                                                           \
    135 case PS_TYPE_##TYPE:                                                                                     \
     145case PS_TYPE_##TYPE:                                                                                         \
    136146    /* Per Eugene's request, use two sets of loops: first to fill mask, second to avoid div with bad pix */  \
    137147    for(j = totOffRow; j < inImage->numRows; j++) {                                                          \
     
    139149            if(flatImage->data.TYPE[j][i] <= 0.0) {                                                          \
    140150                /* Negative or zero flat pixels shall be masked in input image as  PM_MASK_FLAT */           \
    141                 maskImage->data.F64[j][i] = PM_MASK_FLAT;                                                    \
     151                inMask->data.PS_TYPE_MASK_DATA[j][i] = PM_MASK_FLAT;                                         \
    142152            }                                                                                                \
    143153        }                                                                                                    \
     
    145155    for(j = totOffRow; j < inImage->numRows; j++) {                                                          \
    146156        for(i = totOffCol; i < inImage->numCols; i++) {                                                      \
    147             if(!maskImage->data.F64[j][i]) {                                                                 \
     157            if(!inMask->data.PS_TYPE_MASK_DATA[j][i]) {                                                      \
    148158                /* Module shall divide the input image by the flat-fielded image */                          \
    149159                inImage->data.TYPE[j][i] /= flatImage->data.TYPE[j][i];                                      \
     
    165175        PM_FLAT_DIVISION(F64);
    166176    default:
    167         psError(__func__, "Unsupported image datatype (%d)", inType);
     177        psError(__func__, "Unsupported image datatype. Type: %d", inType);
    168178    }
    169179
    170     return in;
     180    return true;
    171181}
  • trunk/psModules/src/pmFlatField.h

    r1814 r1822  
    11/** @file  pmFlatField.h
    22 *
    3  *  @brief Given an input image and a flat-field image, pmFlatField shall divide the input image by the flat-field image.
     3 *  @brief Given an input image and a flat field image, pmFlatField shall divide the input image by the flat
     4 *  field image.
    45 *
    5  *  The input image, in, and the flat-field image, flat, need not be the same size, since the input image may already have
    6  *  been trimmed (following overscan subtraction), but the function shall use the offsets in the image (in->x0
    7  *  and in->y0) to determine the appropriate offsets to obtain the correct pixel on the flat-field. In the event that the flat
    8  *  image is too small (i.e., pixels on the input image refer to pixels outside the range of the flat image), the function shall
    9  *  generate an error. Pixels which are negative or zero in the flat shall be masked in the input image with the value PM_MASK_FLAT
    10  *  Negative pixels in the flat may be set to zero so that they are treated identically to zeroes. Any pixels masked in the flat
    11  *  shall be masked with corresponding values in the output. The function shall not normalize the flat; this responsibility is
    12  *  left to the caller. This function is basically equivalent to a divide (with psImageOp), but with care for the region that is
    13  *  divided, checking for negative pixels, and copying of the mask from the flat to the output.
     6 *  The input image, in, and the flat field image, flat, need not be the same size, since the input image may
     7 *  already have been trimmed (following overscan subtraction), but the function shall use the offsets in the
     8 *  image (in->x0 and in->y0) to determine the appropriate offsets to obtain the correct pixel on the flat
     9 *  field. In the event that the flat image is too small (i.e., pixels on the input image refer to pixels
     10 *  outside the range of the flat image), the function shall generate an error. Pixels which are negative or
     11 *  zero in the flat shall be masked in the input image with the value PM_MASK_FLAT. Negative pixels in the
     12 *  flat may be set to zero so that they are treated identically to zeroes. Any pixels masked in the flat
     13 *  shall be masked with corresponding values in the output. The function shall not normalize the flat; this
     14 *  responsibility is left to the caller. This function is basically equivalent to a divide (with psImageOp),
     15 *  but with care for the region that is divided, checking for negative pixels, and copying of the mask from
     16 *  the flat to the output.
    1417 *
    1518 *  @author Ross Harman, MHPCC
    1619 *
    17  *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
    18  *  @date $Date: 2004-09-15 01:04:50 $
     20 *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
     21 *  @date $Date: 2004-09-17 00:49:04 $
    1922 *
    2023 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2326#include "pslib.h"
    2427
    25 /** Mask values */
    26 typedef enum {
    27     PM_MASK_TRAP    = 0x0001,   ///< The pixel is a charge trap
    28     PM_MASK_BADCOL  = 0x0002,   ///< The pixel is a bad column
    29     PM_MASK_SAT     = 0x0004,   ///< The pixel is saturated
    30     PM_MASK_FLAT    = 0x0008    ///< The pixel is non-positive in the flat-field
    31 } pmMaskValue;
     28/** Execute flat field module.
     29 *
     30 *  Given an input image and a flat-field image, pmFlatField shall divide the input image by the flat field
     31 *  image.
     32 *
     33 *  @return  bool: True or false for success or failure
     34 */
     35bool pmFlatField(
     36    psReadout *in,          ///< Redout with input image and mask
     37    const psReadout *flat   ///< Readout with flat image
     38);
    3239
    33 bool pmFlatField(psReadout *in, psReadout *inMask, const psReadout *flat);
    34 
Note: See TracChangeset for help on using the changeset viewer.