protected void computeRect(Raster[] sources,
                               WritableRaster dest,
                               Rectangle destRect) {

	Raster source = sources[0];

	Rectangle srcRect = mapDestRect(destRect,0);

        // Hack: derive the source format tag as if it was writing to
        // a destination with the same layout as itself.
        int sourceFormatTag =
            MediaLibAccessor.findCompatibleTag(sources, source);

        // Hard-code the destination format tag as we know that the image
        // has a binary layout.
        int destFormatTag =
            dest.getSampleModel().getDataType() |
            MediaLibAccessor.BINARY |
            MediaLibAccessor.UNCOPIED;

        MediaLibAccessor srcAccessor =
            new MediaLibAccessor(source, srcRect, sourceFormatTag, false);
        MediaLibAccessor dstAccessor =
            new MediaLibAccessor(dest, destRect, destFormatTag, true);

	mediaLibImage srcML[], dstML[];

        switch (srcAccessor.getDataType()) {
        case DataBuffer.TYPE_BYTE:
        case DataBuffer.TYPE_USHORT:
        case DataBuffer.TYPE_SHORT:
        case DataBuffer.TYPE_INT:
            srcML = srcAccessor.getMediaLibImages();
            dstML = dstAccessor.getMediaLibImages();
            for (int i = 0 ; i < dstML.length; i++) {
              //XXX
              //medialib version is not inclusive
              //pure java version is inclusive
              //thus medialib version is the same
              //as the java version with thresh value decremented by 1
                Image.Thresh1(dstML[i],
			      srcML[i],
			      new int[]{(int)thresh-1},   // decrease by 1
			      new int[]{1},
			      new int[]{0});
            }
            break;
        case DataBuffer.TYPE_FLOAT:
        case DataBuffer.TYPE_DOUBLE:
            srcML = srcAccessor.getMediaLibImages();
            dstML = dstAccessor.getMediaLibImages();
            for (int i = 0 ; i < dstML.length; i++) {
                Image.Thresh1_Fp(dstML[i],
					       srcML[i],
					       new double[]{thresh},
					       new double[]{1.0D},
					       new double[]{0.0D});
            }
 	    break;
        default:
            String className = this.getClass().getName();
            throw new RuntimeException(JaiI18N.getString("Generic2"));
        }

        if (dstAccessor.isDataCopy()) {
            dstAccessor.clampDataArrays();
            dstAccessor.copyDataToRaster();
        }
    }