IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 27233


Ignore:
Timestamp:
Mar 10, 2010, 2:37:51 PM (16 years ago)
Author:
bills
Message:

handle weight images with S16 and U16 types which can happen
if the input is heavily masked

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/magic/remove/src/streaksio.c

    r26983 r27233  
    11231123
    11241124        psImage *image = sfiles->outImage->image;
     1125        double exciseValue = sfiles->inImage->exciseValue;
     1126
    11251127        psImage *mask = sfiles->inMask->image;
    11261128        psImage *weight = NULL;
     1129        int weightType = 0;
     1130        double weightExciseValue = NAN;
    11271131        if (sfiles->outWeight) {
    11281132            weight = sfiles->outWeight->image;
    1129         }
    1130         double exciseValue = sfiles->inImage->exciseValue;
     1133            weightType = weight->type.type;
     1134            weightExciseValue = sfiles->inWeight->exciseValue;
     1135        }
    11311136
    11321137        if (printCounts) {
     
    11491154                if (maskVal & maskMask) {
    11501155                    ++maskedPixels;
    1151                     if (!isExciseValue(imageVal, sfiles->inImage->exciseValue)) {
     1156                    if (!isExciseValue(imageVal, exciseValue)) {
    11521157                        ++nandPixels;
    11531158                        image->data.F32[y][x] = exciseValue;
    11541159                    }
    11551160                    if (weight) {
    1156                         double weightVal = weight ? weight->data.F32[y][x] : 0;
    1157                         if (!isnan(weightVal)) {
    1158                             ++nandWeights;
    1159                             weight->data.F32[y][x] = NAN;
     1161                        if (weightType == PS_TYPE_F32) {
     1162                            double weightVal = weight->data.F32[y][x];
     1163                            if (!isnan(weightVal)) {
     1164                                ++nandWeights;
     1165                                weight->data.F32[y][x] = NAN;
     1166                            }
     1167                        } else if(weightType == PS_TYPE_S16) {
     1168                            double weightVal = weight->data.S16[y][x];
     1169                            if (!isExciseValue(weightVal, weightExciseValue)) {
     1170                                ++nandWeights;
     1171                                image->data.S16[y][x] = weightExciseValue;
     1172                            }
     1173                        } else if (weightType == PS_TYPE_U16) {
     1174                            double weightVal = weight->data.U16[y][x];
     1175                            if (!isExciseValue(weightVal, weightExciseValue)) {
     1176                                ++nandWeights;
     1177                                image->data.U16[y][x] = weightExciseValue;
     1178                            }
     1179                        } else {
     1180                            psError(PS_ERR_PROGRAMMING, true, "unexpected image type found: %d\n",
     1181                                    weightType);
     1182                                streaksExit("", PS_EXIT_PROG_ERROR);
    11601183                        }
    11611184                    }
     
    11881211        psMetadataAddU16(in->header, PS_LIST_TAIL, "BLANK", 0, "", 65535);
    11891212        psMetadataAddU16(in->header, PS_LIST_TAIL, "ZBLANK", 0, "", 65535);
    1190     } else {
     1213    } else if (in->image->type.type == PS_TYPE_S16) {
     1214        in->exciseValue = 32767;
     1215        psMetadataAddU16(in->header, PS_LIST_TAIL, "BLANK", 0, "", 32767);
     1216        psMetadataAddU16(in->header, PS_LIST_TAIL, "ZBLANK", 0, "", 32767);
     1217    } else if (in->image->type.type == PS_TYPE_F32) {
    11911218        in->exciseValue = NAN;
     1219    } else {
     1220        psError(PS_ERR_PROGRAMMING, true, "unexpected image type found: %d\n", in->image->type.type);
     1221        streaksExit("", PS_EXIT_PROG_ERROR);
    11921222    }
    11931223}
Note: See TracChangeset for help on using the changeset viewer.