Esempio n. 1
0
 public StandardDeviation(FloatProcessor fp, int num) {
   result = (float[]) fp.getPixels();
   len = result.length;
   this.num = num;
   sum = new double[len];
   sum2 = new double[len];
 }
Esempio n. 2
0
  /** Generate output image whose type is same as input image. */
  private ImagePlus makeOutputImage(ImagePlus imp, FloatProcessor fp, int ptype) {
    int width = imp.getWidth();
    int height = imp.getHeight();
    float[] pixels = (float[]) fp.getPixels();
    ImageProcessor oip = null;

    // Create output image consistent w/ type of input image.
    int size = pixels.length;
    switch (ptype) {
      case BYTE_TYPE:
        oip = imp.getProcessor().createProcessor(width, height);
        byte[] pixels8 = (byte[]) oip.getPixels();
        for (int i = 0; i < size; i++) pixels8[i] = (byte) pixels[i];
        break;
      case SHORT_TYPE:
        oip = imp.getProcessor().createProcessor(width, height);
        short[] pixels16 = (short[]) oip.getPixels();
        for (int i = 0; i < size; i++) pixels16[i] = (short) pixels[i];
        break;
      case FLOAT_TYPE:
        oip = new FloatProcessor(width, height, pixels, null);
        break;
    }

    // Adjust for display.
    // Calling this on non-ByteProcessors ensures image
    // processor is set up to correctly display image.
    oip.resetMinAndMax();

    // Create new image plus object. Don't use
    // ImagePlus.createImagePlus here because there may be
    // attributes of input image that are not appropriate for
    // projection.
    return new ImagePlus(makeTitle(), oip);
  }
Esempio n. 3
0
 /** Simple constructor since no preprocessing is necessary. */
 public MinIntensity(FloatProcessor fp) {
   fpixels = (float[]) fp.getPixels();
   len = fpixels.length;
   for (int i = 0; i < len; i++) fpixels[i] = Float.MAX_VALUE;
 }
Esempio n. 4
0
 /**
  * Constructor requires number of slices to be projected. This is used to determine average at
  * each pixel.
  */
 public AverageIntensity(FloatProcessor fp, int num) {
   fpixels = (float[]) fp.getPixels();
   len = fpixels.length;
   this.num = num;
 }