Ejemplo n.º 1
0
 void doIterations(ImageProcessor ip, String mode) {
   if (escapePressed) return;
   if (!previewing && iterations > 1) IJ.showStatus(arg + "... press ESC to cancel");
   for (int i = 0; i < iterations; i++) {
     if (Thread.currentThread().isInterrupted()) return;
     if (IJ.escapePressed()) {
       escapePressed = true;
       ip.reset();
       return;
     }
     if (mode.equals("erode")) ((ByteProcessor) ip).erode(count, background);
     else ((ByteProcessor) ip).dilate(count, background);
   }
 }
Ejemplo n.º 2
0
  public GrayLevelClass(ByteProcessor img, boolean first) {
    if (!probabilityHistogramDone) {
      int[] histogram = img.getHistogram();
      probabilityHistogram = new float[256];

      for (int i = 0; i < 256; i++) {
        probabilityHistogram[i] = ((float) histogram[i]) / ((float) N);
        // IJ.write(" "+probabilityHistogram[i]);
      }
      probabilityHistogramDone = true;
    }

    if (first) {
      index = 1;
      omega = probabilityHistogram[index - 1];
      if (omega == 0) mu = 0;
      else mu = 1 * probabilityHistogram[index - 1] / omega;
    } else {
      index = 2;
      omega = 0;
      mu = 0;
      for (int i = index; i < 256; i++) {
        omega += probabilityHistogram[i - 1];
        mu += probabilityHistogram[i - 1] * i;
      }
      if (omega == 0) mu = 0;
      else mu /= omega;
    }
  }
Ejemplo n.º 3
0
 void skeletonize(ImageProcessor ip) {
   if (Prefs.blackBackground) ip.invert();
   boolean edgePixels = hasEdgePixels(ip);
   ImageProcessor ip2 = expand(ip, edgePixels);
   ((ByteProcessor) ip2).skeletonize();
   ip = shrink(ip, ip2, edgePixels);
   if (Prefs.blackBackground) ip.invert();
 }
Ejemplo n.º 4
0
 void outline(ImageProcessor ip) {
   if (Prefs.blackBackground) ip.invert();
   ((ByteProcessor) ip).outline();
   if (Prefs.blackBackground) ip.invert();
 }