IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 1, 2006, 2:55:23 PM (20 years ago)
Author:
Paul Price
Message:

Addition of a vast quantity of assertions in public functions. Adopted a policy of using assert() within file-static functions (since they are only called internally, any errors there are problems with the program) and using the PS_ASSERT_WHATEVER() macros within public functions. Cleaned a few things up in the process.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/detrend/pmFlatField.c

    r6873 r7278  
    1 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
    2 // XXX WARNING: I have completely replaced this file with an OLD VERSION (that works) instead of the
    3 // one that was being worked on.
    4 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
    5 
    6 
    71/** @file  pmFlatField.c
    82 *
     
    2418 *  @author Ross Harman, MHPCC
    2519 *
    26  *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
    27  *  @date $Date: 2006-04-17 18:10:08 $
     20 *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
     21 *  @date $Date: 2006-06-02 00:55:23 $
    2822 *
    2923 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    4640bool pmFlatField(pmReadout *in, const pmReadout *flat)
    4741{
    48     int i = 0;
    49     int j = 0;
     42    PS_ASSERT_PTR_NON_NULL(in, false);
     43    PS_ASSERT_PTR_NON_NULL(in->image, false);
     44    PS_ASSERT_IMAGE_NON_EMPTY(in->image, false);
     45    PS_ASSERT_PTR_NON_NULL(flat, false);
     46    PS_ASSERT_PTR_NON_NULL(flat->image, false);
     47    PS_ASSERT_IMAGE_NON_EMPTY(flat->image, false);
     48    if (in->mask) {
     49        PS_ASSERT_IMAGE_TYPE(in->mask, PS_TYPE_U8, false);
     50    }
     51    PS_ASSERT_IMAGE_TYPE(flat->image, in->image->type.type, false);
     52
    5053    int totOffCol = 0;
    5154    int totOffRow = 0;
     
    147150
    148151    // Macro for all PS types
    149     #define PM_FLAT_DIVISION(TYPE)                                                                           \
    150 case PS_TYPE_##TYPE:                                                                                         \
    151     /* Per Eugene's request, use two sets of loops: first to fill mask, second to avoid div with bad pix */  \
    152     for(j = totOffRow; j < inImage->numRows; j++) {                                                          \
    153         for(i = totOffCol; i < inImage->numCols; i++) {                                                      \
    154             if(flatImage->data.TYPE[j][i] <= 0.0) {                                                          \
    155                 /* Negative or zero flat pixels shall be masked in input image as  PM_MASK_FLAT */           \
    156                 if (inMask) {                                                                                \
    157                     inMask->data.PS_TYPE_MASK_DATA[j][i] |= PM_MASK_FLAT;                                    \
    158                 }                                                                                            \
    159                 flatImage->data.TYPE[j][i] = 0.0;                                                            \
    160             }                                                                                                \
    161         }                                                                                                    \
    162     }                                                                                                        \
    163     for(j = totOffRow; j < inImage->numRows; j++) {                                                          \
    164         for(i = totOffCol; i < inImage->numCols; i++) {                                                      \
    165             if(inMask && !inMask->data.PS_TYPE_MASK_DATA[j][i]) {                                            \
    166                 /* Module shall divide the input image by the flat-fielded image */                          \
    167                 inImage->data.TYPE[j][i] /= flatImage->data.TYPE[j][i];                                      \
    168             }                                                                                                \
    169         }                                                                                                    \
    170     }                                                                                                        \
     152    #define FLAT_DIVISION_CASE(TYPE) \
     153case PS_TYPE_##TYPE: \
     154    for (long j = totOffRow; j < inImage->numRows; j++) { \
     155        for (long i = totOffCol; i < inImage->numCols; i++) { \
     156            if (flatImage->data.TYPE[j][i] <= 0.0) { \
     157                if (inMask) { \
     158                    inMask->data.U8[j][i] |= PM_MASK_FLAT; \
     159                } \
     160                flatImage->data.TYPE[j][i] = 0.0; \
     161            } else { \
     162                if (!inMask || !inMask->data.U8[j][i]) { \
     163                    inImage->data.TYPE[j][i] /= flatImage->data.TYPE[j][i]; \
     164                } \
     165            } \
     166        } \
     167    } \
    171168    break;
    172169
    173170    switch(inType) {
    174         PM_FLAT_DIVISION(U8);
    175         PM_FLAT_DIVISION(U16);
    176         PM_FLAT_DIVISION(U32);
    177         PM_FLAT_DIVISION(U64);
    178         PM_FLAT_DIVISION(S8);
    179         PM_FLAT_DIVISION(S16);
    180         PM_FLAT_DIVISION(S32);
    181         PM_FLAT_DIVISION(S64);
    182         PM_FLAT_DIVISION(F32);
    183         PM_FLAT_DIVISION(F64);
     171        FLAT_DIVISION_CASE(U8);
     172        FLAT_DIVISION_CASE(U16);
     173        FLAT_DIVISION_CASE(U32);
     174        FLAT_DIVISION_CASE(U64);
     175        FLAT_DIVISION_CASE(S8);
     176        FLAT_DIVISION_CASE(S16);
     177        FLAT_DIVISION_CASE(S32);
     178        FLAT_DIVISION_CASE(S64);
     179        FLAT_DIVISION_CASE(F32);
     180        FLAT_DIVISION_CASE(F64);
    184181    default:
    185182        psError( PS_ERR_BAD_PARAMETER_TYPE, true,
Note: See TracChangeset for help on using the changeset viewer.