Esempio n. 1
0
    void apply(ImagePlus imp, ImageProcessor ip) {
      // this.setCursor(wait);
      // IJ.showStatus("Bandpassing slice "+previousSlice);
      java.awt.Color col;

      if (invert.getState()) col = Toolbar.getForegroundColor();
      else col = Toolbar.getBackgroundColor();

      ip.setColor(col);

      int fill = ip.BLACK;
      int keep = 0;

      if (bandPassH.getState() && bandPassS.getState() && bandPassB.getState()) { // PPP All pass
        for (int j = 0; j < numPixels; j++) {
          int hue = hSource[j] & 0xff;
          int sat = sSource[j] & 0xff;
          int bri = bSource[j] & 0xff;
          if (((hue < minHue) || (hue > maxHue))
              || ((sat < minSat) || (sat > maxSat))
              || ((bri < minBri) || (bri > maxBri))) fillMask[j] = fill;
          else fillMask[j] = keep;
        }
      } else if (!bandPassH.getState()
          && !bandPassS.getState()
          && !bandPassB.getState()) { // SSS All stop
        for (int j = 0; j < numPixels; j++) {
          int hue = hSource[j] & 0xff;
          int sat = sSource[j] & 0xff;
          int bri = bSource[j] & 0xff;
          if (((hue >= minHue) && (hue <= maxHue))
              || ((sat >= minSat) && (sat <= maxSat))
              || ((bri >= minBri) && (bri <= maxBri))) fillMask[j] = fill;
          else fillMask[j] = keep;
        }
      } else if (bandPassH.getState() && bandPassS.getState() && !bandPassB.getState()) { // PPS
        for (int j = 0; j < numPixels; j++) {
          int hue = hSource[j] & 0xff;
          int sat = sSource[j] & 0xff;
          int bri = bSource[j] & 0xff;
          if (((hue < minHue) || (hue > maxHue))
              || ((sat < minSat) || (sat > maxSat))
              || ((bri >= minBri) && (bri <= maxBri))) fillMask[j] = fill;
          else fillMask[j] = keep;
        }
      } else if (!bandPassH.getState() && !bandPassS.getState() && bandPassB.getState()) { // SSP
        for (int j = 0; j < numPixels; j++) {
          int hue = hSource[j] & 0xff;
          int sat = sSource[j] & 0xff;
          int bri = bSource[j] & 0xff;
          if (((hue >= minHue) && (hue <= maxHue))
              || ((sat >= minSat) && (sat <= maxSat))
              || ((bri < minBri) || (bri > maxBri))) fillMask[j] = fill;
          else fillMask[j] = keep;
        }
      } else if (bandPassH.getState() && !bandPassS.getState() && !bandPassB.getState()) { // PSS
        for (int j = 0; j < numPixels; j++) {
          int hue = hSource[j] & 0xff;
          int sat = sSource[j] & 0xff;
          int bri = bSource[j] & 0xff;
          if (((hue < minHue) || (hue > maxHue))
              || ((sat >= minSat) && (sat <= maxSat))
              || ((bri >= minBri) && (bri <= maxBri))) fillMask[j] = fill;
          else fillMask[j] = keep;
        }
      } else if (!bandPassH.getState() && bandPassS.getState() && bandPassB.getState()) { // SPP
        for (int j = 0; j < numPixels; j++) {
          int hue = hSource[j] & 0xff;
          int sat = sSource[j] & 0xff;
          int bri = bSource[j] & 0xff;
          if (((hue >= minHue) && (hue <= maxHue))
              || ((sat < minSat) || (sat > maxSat))
              || ((bri < minBri) || (bri > maxBri))) fillMask[j] = fill;
          else fillMask[j] = keep;
        }
      } else if (!bandPassH.getState() && bandPassS.getState() && !bandPassB.getState()) { // SPS
        for (int j = 0; j < numPixels; j++) {
          int hue = hSource[j] & 0xff;
          int sat = sSource[j] & 0xff;
          int bri = bSource[j] & 0xff;
          if (((hue >= minHue) && (hue <= maxHue))
              || ((sat < minSat) || (sat > maxSat))
              || ((bri >= minBri) && (bri <= maxBri))) fillMask[j] = fill;
          else fillMask[j] = keep;
        }
      } else if (bandPassH.getState() && !bandPassS.getState() && bandPassB.getState()) { // PSP
        for (int j = 0; j < numPixels; j++) {
          int hue = hSource[j] & 0xff;
          int sat = sSource[j] & 0xff;
          int bri = bSource[j] & 0xff;
          if (((hue < minHue) || (hue > maxHue))
              || ((sat >= minSat) && (sat <= maxSat))
              || ((bri < minBri) || (bri > maxBri))) fillMask[j] = fill;
          else fillMask[j] = keep;
        }
      }

      ip.fill(fillMask);

      if (threshold.getState()) {
        ip.invert();
        for (int j = 0; j < numPixels; j++) {
          if (fillMask[j] == fill) fillMask[j] = keep;
          else fillMask[j] = fill;
        }
        ip.fill(fillMask);
        ip.invert();
      }
    }