IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 2293


Ignore:
Timestamp:
Nov 5, 2004, 2:56:29 PM (22 years ago)
Author:
gusciora
Message:

Removed some redundant type checks.

Location:
trunk/psLib/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/dataManip/psConstants.h

    r2291 r2293  
    66 *  @author GLG, MHPCC
    77 *
    8  *  @version $Revision: 1.36 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2004-11-06 00:44:56 $
     8 *  @version $Revision: 1.37 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2004-11-06 00:56:28 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    318318}
    319319
     320#define PS_IMAGE_CHECK_SIZE_EQUAL(NAME1, NAME2, RVAL) \
     321if ((NAME1->numCols != NAME2->numCols) || \
     322        (NAME1->numRows != NAME2->numRows)) { \
     323    psError(PS_ERR_BAD_PARAMETER_SIZE, true, \
     324            "Unallowable operation: psImages %s and %s are not the same size.", \
     325            #NAME1, #NAME2); \
     326    return(RVAL); \
     327}
     328
    320329
    321330
  • trunk/psLib/src/image/psImageStats.c

    r2292 r2293  
    99 *  @author GLG, MHPCC
    1010 *
    11  *  @version $Revision: 1.52 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2004-11-06 00:45:13 $
     11 *  @version $Revision: 1.53 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2004-11-06 00:56:29 $
    1313 *
    1414 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    3434/// This routine must determine the various statistics for the image.
    3535/*****************************************************************************
    36 XXX: verify that image/mask have the correct types, and sizes.
     36psImageStats(stats, in, mask, maskVal): this routine simply calls the
     37psVectorStats() routine, which does the actual statistical calculation.  In
     38order to do so, we create dummy psVectors and set their "data" pointer to that
     39of the input psImages.
     40 
     41XXX: use static psVectors
    3742 *****************************************************************************/
    3843psStats* psImageStats(psStats* stats,
     
    4146                      psS32 maskVal)
    4247{
     48    psVector *junkData = NULL;
     49    psVector *junkMask = NULL;
     50
    4351    PS_PTR_CHECK_NULL(stats, NULL);
    4452    PS_INT_CHECK_ZERO(stats->options, NULL);
    4553    PS_IMAGE_CHECK_NULL(in, NULL)
    46     psVector* junkData = NULL;
    47     psVector* junkMask = NULL;
     54    if (mask != NULL) {
     55        PS_IMAGE_CHECK_TYPE(mask, PS_TYPE_U8, NULL);
     56        PS_IMAGE_CHECK_SIZE_EQUAL(in, mask, NULL);
     57    }
    4858
    4959    // stuff the image data into a psVector struct.
    50     junkData = psAlloc(sizeof(psVector));
     60    junkData = (psVector *) psAlloc(sizeof(psVector));
    5161    junkData->type = in->type;
    5262    junkData->nalloc = in->numRows * in->numCols;
     
    5565
    5666    if (mask != NULL) {
    57         if (mask->type.type != PS_TYPE_MASK) {
    58             char* typeStr;
    59             PS_TYPE_NAME(typeStr,mask->type.type);
    60             psError(PS_ERR_BAD_PARAMETER_TYPE, true,
    61                     PS_ERRORTEXT_psImage_IMAGE_MASK_TYPE,
    62                     typeStr, PS_TYPE_MASK_NAME);
    63             psFree(junkData);
    64             return NULL;
    65         }
    6667        // stuff the mask data into a psVector struct.
    6768        junkMask = psAlloc(sizeof(psVector));
     
    9293    if (mask != NULL) {
    9394        PS_IMAGE_CHECK_TYPE(mask, PS_TYPE_U8, NULL);
     95        PS_IMAGE_CHECK_SIZE_EQUAL(in, mask, NULL);
    9496    }
    9597    psVector* junkData = NULL;
     
    137139        tmp = (M_PI * (tmp - 0.5)) / ((double)n);
    138140        scalingFactors[i] = cos(tmp);
    139     }
    140 
    141     return (scalingFactors);
    142 }
    143 
    144 psVector *VeccalcScaleFactors(psVector *scalingFactors, psS32 n)
    145 {
    146     PS_VECTOR_CHECK_NULL(scalingFactors, NULL);
    147     PS_VECTOR_CHECK_TYPE(scalingFactors, PS_TYPE_F64, NULL);
    148     PS_INT_CHECK_NON_NEGATIVE(n, NULL);
    149     psS32 i = 0;
    150     double tmp = 0.0;
    151 
    152     for (i = 0; i < n; i++) {
    153         tmp = (double)(n - i);
    154         tmp = (M_PI * (tmp - 0.5)) / ((double)n);
    155         scalingFactors->data.F64[i] = cos(tmp);
    156141    }
    157142
  • trunk/psLib/src/imageops/psImageStats.c

    r2292 r2293  
    99 *  @author GLG, MHPCC
    1010 *
    11  *  @version $Revision: 1.52 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2004-11-06 00:45:13 $
     11 *  @version $Revision: 1.53 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2004-11-06 00:56:29 $
    1313 *
    1414 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    3434/// This routine must determine the various statistics for the image.
    3535/*****************************************************************************
    36 XXX: verify that image/mask have the correct types, and sizes.
     36psImageStats(stats, in, mask, maskVal): this routine simply calls the
     37psVectorStats() routine, which does the actual statistical calculation.  In
     38order to do so, we create dummy psVectors and set their "data" pointer to that
     39of the input psImages.
     40 
     41XXX: use static psVectors
    3742 *****************************************************************************/
    3843psStats* psImageStats(psStats* stats,
     
    4146                      psS32 maskVal)
    4247{
     48    psVector *junkData = NULL;
     49    psVector *junkMask = NULL;
     50
    4351    PS_PTR_CHECK_NULL(stats, NULL);
    4452    PS_INT_CHECK_ZERO(stats->options, NULL);
    4553    PS_IMAGE_CHECK_NULL(in, NULL)
    46     psVector* junkData = NULL;
    47     psVector* junkMask = NULL;
     54    if (mask != NULL) {
     55        PS_IMAGE_CHECK_TYPE(mask, PS_TYPE_U8, NULL);
     56        PS_IMAGE_CHECK_SIZE_EQUAL(in, mask, NULL);
     57    }
    4858
    4959    // stuff the image data into a psVector struct.
    50     junkData = psAlloc(sizeof(psVector));
     60    junkData = (psVector *) psAlloc(sizeof(psVector));
    5161    junkData->type = in->type;
    5262    junkData->nalloc = in->numRows * in->numCols;
     
    5565
    5666    if (mask != NULL) {
    57         if (mask->type.type != PS_TYPE_MASK) {
    58             char* typeStr;
    59             PS_TYPE_NAME(typeStr,mask->type.type);
    60             psError(PS_ERR_BAD_PARAMETER_TYPE, true,
    61                     PS_ERRORTEXT_psImage_IMAGE_MASK_TYPE,
    62                     typeStr, PS_TYPE_MASK_NAME);
    63             psFree(junkData);
    64             return NULL;
    65         }
    6667        // stuff the mask data into a psVector struct.
    6768        junkMask = psAlloc(sizeof(psVector));
     
    9293    if (mask != NULL) {
    9394        PS_IMAGE_CHECK_TYPE(mask, PS_TYPE_U8, NULL);
     95        PS_IMAGE_CHECK_SIZE_EQUAL(in, mask, NULL);
    9496    }
    9597    psVector* junkData = NULL;
     
    137139        tmp = (M_PI * (tmp - 0.5)) / ((double)n);
    138140        scalingFactors[i] = cos(tmp);
    139     }
    140 
    141     return (scalingFactors);
    142 }
    143 
    144 psVector *VeccalcScaleFactors(psVector *scalingFactors, psS32 n)
    145 {
    146     PS_VECTOR_CHECK_NULL(scalingFactors, NULL);
    147     PS_VECTOR_CHECK_TYPE(scalingFactors, PS_TYPE_F64, NULL);
    148     PS_INT_CHECK_NON_NEGATIVE(n, NULL);
    149     psS32 i = 0;
    150     double tmp = 0.0;
    151 
    152     for (i = 0; i < n; i++) {
    153         tmp = (double)(n - i);
    154         tmp = (M_PI * (tmp - 0.5)) / ((double)n);
    155         scalingFactors->data.F64[i] = cos(tmp);
    156141    }
    157142
  • trunk/psLib/src/math/psConstants.h

    r2291 r2293  
    66 *  @author GLG, MHPCC
    77 *
    8  *  @version $Revision: 1.36 $ $Name: not supported by cvs2svn $
    9  *  @date $Date: 2004-11-06 00:44:56 $
     8 *  @version $Revision: 1.37 $ $Name: not supported by cvs2svn $
     9 *  @date $Date: 2004-11-06 00:56:28 $
    1010 *
    1111 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    318318}
    319319
     320#define PS_IMAGE_CHECK_SIZE_EQUAL(NAME1, NAME2, RVAL) \
     321if ((NAME1->numCols != NAME2->numCols) || \
     322        (NAME1->numRows != NAME2->numRows)) { \
     323    psError(PS_ERR_BAD_PARAMETER_SIZE, true, \
     324            "Unallowable operation: psImages %s and %s are not the same size.", \
     325            #NAME1, #NAME2); \
     326    return(RVAL); \
     327}
     328
    320329
    321330
Note: See TracChangeset for help on using the changeset viewer.