Index: trunk/magic/remove/src/streaksio.c
===================================================================
--- trunk/magic/remove/src/streaksio.c	(revision 27232)
+++ trunk/magic/remove/src/streaksio.c	(revision 27233)
@@ -1123,10 +1123,15 @@
 
         psImage *image = sfiles->outImage->image;
+        double exciseValue = sfiles->inImage->exciseValue;
+
         psImage *mask = sfiles->inMask->image;
         psImage *weight = NULL;
+        int weightType = 0;
+        double weightExciseValue = NAN;
         if (sfiles->outWeight) {
             weight = sfiles->outWeight->image;
-        }
-        double exciseValue = sfiles->inImage->exciseValue;
+            weightType = weight->type.type;
+            weightExciseValue = sfiles->inWeight->exciseValue;
+        }
 
         if (printCounts) {
@@ -1149,13 +1154,31 @@
                 if (maskVal & maskMask) {
                     ++maskedPixels;
-                    if (!isExciseValue(imageVal, sfiles->inImage->exciseValue)) {
+                    if (!isExciseValue(imageVal, exciseValue)) {
                         ++nandPixels;
                         image->data.F32[y][x] = exciseValue;
                     }
                     if (weight) {
-                        double weightVal = weight ? weight->data.F32[y][x] : 0;
-                        if (!isnan(weightVal)) {
-                            ++nandWeights;
-                            weight->data.F32[y][x] = NAN;
+                        if (weightType == PS_TYPE_F32) {
+                            double weightVal = weight->data.F32[y][x];
+                            if (!isnan(weightVal)) {
+                                ++nandWeights;
+                                weight->data.F32[y][x] = NAN;
+                            }
+                        } else if(weightType == PS_TYPE_S16) {
+                            double weightVal = weight->data.S16[y][x];
+                            if (!isExciseValue(weightVal, weightExciseValue)) {
+                                ++nandWeights;
+                                image->data.S16[y][x] = weightExciseValue;
+                            }
+                        } else if (weightType == PS_TYPE_U16) {
+                            double weightVal = weight->data.U16[y][x];
+                            if (!isExciseValue(weightVal, weightExciseValue)) {
+                                ++nandWeights;
+                                image->data.U16[y][x] = weightExciseValue;
+                            }
+                        } else {
+                            psError(PS_ERR_PROGRAMMING, true, "unexpected image type found: %d\n",
+                                    weightType);
+                                streaksExit("", PS_EXIT_PROG_ERROR);
                         }
                     }
@@ -1188,6 +1211,13 @@
         psMetadataAddU16(in->header, PS_LIST_TAIL, "BLANK", 0, "", 65535);
         psMetadataAddU16(in->header, PS_LIST_TAIL, "ZBLANK", 0, "", 65535);
-    } else {
+    } else if (in->image->type.type == PS_TYPE_S16) {
+        in->exciseValue = 32767;
+        psMetadataAddU16(in->header, PS_LIST_TAIL, "BLANK", 0, "", 32767);
+        psMetadataAddU16(in->header, PS_LIST_TAIL, "ZBLANK", 0, "", 32767);
+    } else if (in->image->type.type == PS_TYPE_F32) {
         in->exciseValue = NAN;
+    } else {
+        psError(PS_ERR_PROGRAMMING, true, "unexpected image type found: %d\n", in->image->type.type);
+        streaksExit("", PS_EXIT_PROG_ERROR);
     }
 }
