コード例 #1
0
ファイル: Binary.java プロジェクト: kkkkxu/BioImage
 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);
   }
 }
コード例 #2
0
  // Particle finding routine based on spots enhancement with
  // 2D PSF Gaussian approximated convolution/backgrounds subtraction, thresholding
  // and particle filtering
  void detectParticles(
      ImageProcessor ip, SMLDialog fdg, int nFrame, Overlay SpotsPositions_, Roi RoiActive_) {
    int nThreshold;
    FloatProcessor dupip = null; // duplicate of image
    ImageProcessor dushort; // duplicate of image
    ByteProcessor dubyte = null; // tresholded image
    TypeConverter tc;

    dupip = (FloatProcessor) ip.duplicate().convertToFloat();

    SMLblur1Direction(
        dupip, fdg.dPSFsigma * 0.5, 0.0002, true, (int) Math.ceil(5 * fdg.dPSFsigma * 0.5));
    SMLblur1Direction(dupip, fdg.dPSFsigma * 0.5, 0.0002, false, 0);

    // new ImagePlus("gassconvoluted", dupip.convertToFloat().duplicate()).show();
    // low-pass filtering by gaussian blurring
    // lowpassGauss.blurGaussian(dupip, fdg.dPSFsigma*0.5, fdg.dPSFsigma*0.5, 0.0002);

    // convolution with gaussian PSF kernel
    SMLconvolveFloat(dupip, fConKernel, fdg.nKernelSize, fdg.nKernelSize);

    // new ImagePlus("convoluted", dupip.duplicate()).show();
    tc = new TypeConverter(dupip, true);
    dushort = tc.convertToShort();
    // new ImagePlus("convoluted", dushort.duplicate()).show();

    // thresholding

    // old straightforward thresholding
    // imgstat = ImageStatistics.getStatistics(dupip, 22, null); //6 means MEAN + STD_DEV, look at
    // ij.measure.Measurements
    // nThreshold = (int)(imgstat.mean + 3.0*imgstat.stdDev);

    // new smart thresholding
    nThreshold = getThreshold(dushort);

    dushort.threshold(nThreshold);
    // convert to byte
    dubyte = (ByteProcessor) dushort.convertToByte(false);
    // new ImagePlus("threshold", dubyte.duplicate()).show();

    // morphological operations on thresholded image
    // dubyte.dilate(2, 0);
    // dubyte.erode(2, 0);

    // cleaning up image a bit
    if (fdg.nKernelSize > 3) {
      dubyte.dilate();
      // new ImagePlus("dilated", dubyte.duplicate()).show();
      dubyte.erode();
      // new ImagePlus("erosion", dubyte.duplicate()).show();
    }
    // dupip.invert();

    labelParticles(
        dubyte,
        ip,
        nFrame,
        fdg.dPixelSize,
        fdg.nAreaCut,
        fdg.dPSFsigma,
        SpotsPositions_,
        fdg.bShowParticles,
        RoiActive_); // , fdg.bIgnoreFP);//, fdg.dSymmetry/100);
  }