void constructRings() {
    m_dvRs = new ArrayList();
    m_cvRings = new ArrayList();
    m_cvRings.add(new CircleImage(0));
    m_dvRs.add(0.);
    double r = 1., dr = 0.001;
    double ri = r - dr, ro = r + dr;
    m_cvRings.add(new Ring(ri, ro));
    m_dvRs.add(r);

    r = Math.sqrt(2);
    ri = r - dr;
    ro = r + dr;
    m_cvRings.add(new Ring(ri, ro));
    m_dvRs.add(r);

    int nr;
    for (nr = 2; nr <= m_nRMax; nr++) {
      m_cvRings.add(new Ring(nr - 1, nr));
      m_dvRs.add((double) nr);
    }

    m_cRefRing = new Ring(m_nRRefI, m_nRRefO);
    m_cvRings.add(m_cRefRing);
    m_dvRs.add((double) m_nRMax + 1);
    ImageShapeHandler.setFrameRanges(m_cvRings, new intRange(0, w - 1), new intRange(0, h - 1));
  }
  public void calAutoCorrelation(
      int
          nRefType) { // computing the cross correlation coefficient between pixel values of points
                      // separated by the radius of rings
    m_nRefType = nRefType;
    int numRings = m_cvRings.size();
    calRefPixels();
    m_cPixelMeanSems = CommonStatisticsMethods.buildMeanSem(m_pnPixelsLR);
    int len;

    double mean = m_cPixelMeanSems.mean, sem2 = m_cPixelMeanSems.sem2;
    double medianMean[] = new double[numRings - 1];
    double medianSem2[] = new double[numRings - 1];

    double crossProduct[] = new double[numRings - 1];
    double numCrossPairs[] = new double[numRings - 1];
    double crossProduct_median[] = new double[numRings - 1];
    double numCrossPairs_median[] = new double[numRings - 1];

    ArrayList<Double> medians[] = new ArrayList[numRings - 1];
    int i, j, pixel0;

    for (i = 0; i < numRings - 1; i++) {
      crossProduct[i] = 0;
      numCrossPairs[i] = 0;
      crossProduct_median[i] = 0;
      numCrossPairs_median[i] = 0;
      medianMean[i] = 0;
      medianSem2[i] = 0;
      medians[i] = new ArrayList();
    }

    int[][] pixels_LMC = new int[h][w];

    ImageShape shape;
    ArrayList<Point> points = new ArrayList();
    ArrayList<Point> scanningTrace = new ArrayList();

    double dp, median;
    Point p0, p;
    int index = 0, y0 = 0, y;
    Histogram hist;
    int nRef, mean1;
    while (true) {
      p0 = new Point(m_cIMSC.getPosition());
      y = p0.y;
      scanningTrace.add(p0);
      pixel0 = m_pnPixelsLR[p0.y][p0.x];
      nRef = getRefPixel(p0);
      dp = pixel0 - mean;
      CommonMethods.fillHistograms(m_pnPixels, nRef, m_cvRings, p0, m_cvHists);
      for (i = 0; i < numRings - 1; i++) {
        shape = m_cvRings.get(i);
        shape.setCenter(p0);
        shape.setFrameRanges(
            new intRange(p0.x, w - 1),
            new intRange(
                p0.y,
                h - 1)); // this is to avoid double counting the pair of points with given distance
        shape.getInnerPoints(points);
        shape.setFrameRanges(new intRange(0, w - 1), new intRange(0, h - 1));
        len = points.size();
        for (j = 0; j < len; j++) {
          p = points.get(j);
          crossProduct[i] += dp * (m_pnPixels[p.y][p.x] - nRef - mean);
        }
        numCrossPairs[i] += len;

        numCrossPairs_median[i] += 1;

        hist = m_cvHists.get(i);
        median = hist.getPercentileValue();
        medianMean[i] += median;
        medianSem2[i] += median * median;
        medians[i].add(median);
        if (y > y0) {
          IJ.showStatus("computing autocorrelation: " + PrintAssist.ToString(y) + "-th line");
          IJ.showProgress(y / h);
          y0 = y;
        }
      }
      if (m_cIMSC.done()) break;
      m_cIMSC.move();
      index++;
    }
    double dAutoCorr_mean, meanMedian, cp;
    MeanSem0 ms = new MeanSem0();
    int num;
    for (i = 0; i < numRings - 1; i++) {
      m_pdAutoCorr_mean[i] = crossProduct[i] / (Math.sqrt(sem2 * sem2) * (numCrossPairs[i]));
      num = medians[i].size();
      medianMean[i] /= num;
      medianSem2[i] /= num;
      ms.updateMeanSquareSum(num, medianMean[i], medianSem2[i]);
      meanMedian = ms.mean;
      cp = 0;
      for (j = 0; j < num; j++) {
        p = scanningTrace.get(j);
        cp += (m_pnPixelsLR[p.y][p.x] - mean) * (medians[i].get(j) - meanMedian);
      }
      m_pdAutoCorr_median[i] = cp / (Math.sqrt(sem2 * ms.sem2) * (num));
    }
  }
 public double dist(IntensityPeakObject_GaussianNodeGroup ipo) {
   double dx = (IPOGNode.xcr - ipo.IPOGNode.xcr);
   double dy = (IPOGNode.ycr - ipo.IPOGNode.ycr);
   double dist = Math.sqrt(dx * dx + dy * dy);
   return dist;
 }