IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 28, 2009, 11:21:56 AM (17 years ago)
Author:
eugene
Message:

always handle psVectorStats false return status (is an error); check for NAN results and handle as possible

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/imageops/psImageMap.c

    r21183 r23989  
    211211            // XXX need to supply a mask and skip the masked pixels when calculating the centroid
    212212            // this will not in general be properly weighted...
    213             if (psVectorStats (map->stats, fCell, dfCell, NULL, 0)) {
     213            if (!psVectorStats (map->stats, fCell, dfCell, NULL, 0)) {
     214                psError(PS_ERR_UNKNOWN, false, "failure to measure stats");
     215                return false;
     216            }
     217
     218            // XXX ensure only one option is selected, or save both position and width
     219            map->map->data.F32[iy][ix] = psStatsGetValue (map->stats, map->stats->options);
     220
     221            if (isnan(map->map->data.F32[iy][ix])) {
     222                mask->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix] = 1;
     223            } else {
    214224                mask->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix] = 0;
    215                 // XXX ensure only one option is selected, or save both position and width
    216                 map->map->data.F32[iy][ix] = psStatsGetValue (map->stats, map->stats->options);
    217225
    218226                // calculate the mean position and save:
    219227                psStatsInit (meanStat);
    220                 psVectorStats (meanStat, xCell, NULL, NULL, 0);
     228                if (!psVectorStats (meanStat, xCell, NULL, NULL, 0)) {
     229                    psError(PS_ERR_UNKNOWN, false, "failure to measure stats");
     230                    return false;
     231                }
    221232                xCoord->data.F32[iy][ix] = psStatsGetValue (meanStat, meanStat->options);
    222233                psStatsInit (meanStat);
    223                 psVectorStats (meanStat, yCell, NULL, NULL, 0);
     234                if (!psVectorStats (meanStat, yCell, NULL, NULL, 0)) {
     235                    psError(PS_ERR_UNKNOWN, false, "failure to measure stats");
     236                    return false;
     237                }
    224238                yCoord->data.F32[iy][ix] = psStatsGetValue (meanStat, meanStat->options);
    225             } else {
    226                 mask->data.PS_TYPE_IMAGE_MASK_DATA[iy][ix] = 1;
    227239            }
    228240
Note: See TracChangeset for help on using the changeset viewer.