void calRefPixels() {
   int[] nRange = new int[2];
   CommonMethods.getDataRange(m_pnPixels, nRange);
   MeanSem0 ms = CommonStatisticsMethods.buildMeanSem(m_pnPixels);
   int nMin;
   switch (m_nRefType) {
     case export_AutoCorrelation.originalRef:
       m_pnPixelsLR = new int[h][w];
       CommonStatisticsMethods.copyArray(m_pnPixels, m_pnPixelsLR);
       break;
     case export_AutoCorrelation.globalMeanRef:
       m_pnPixelsLR = new int[h][w];
       CommonStatisticsMethods.copyArray(m_pnPixels, m_pnPixelsLR);
       CommonStatisticsMethods.shiftArray(m_pnPixelsLR, -(int) (ms.mean + 0.5));
       break;
     case export_AutoCorrelation.globalMedianRef:
       m_pnPixelsLR = new int[h][w];
       CommonStatisticsMethods.copyArray(m_pnPixels, m_pnPixelsLR);
       CommonStatisticsMethods.shiftArray(
           m_pnPixelsLR, -CommonStatisticsMethods.getQuantile(m_pnPixels, 0.5));
       break;
     case export_AutoCorrelation.localMeanRef:
       m_pnPixelsLR = CommonMethods.getPixelValus_LocalReference(impl, m_cRefRing, m_nRefType);
       break;
     case export_AutoCorrelation.localMedianRef:
       m_pnPixelsLR = CommonMethods.getPixelValus_LocalReference(impl, m_cRefRing, m_nRefType);
       break;
     default:
       m_pnPixelsLR = new int[h][w];
       CommonStatisticsMethods.copyArray(m_pnPixels, m_pnPixelsLR);
       break;
   }
   updateHistograms();
 }
 int calCompensatedPixels() {
   int numRings = m_cvRings.size();
   CommonStatisticsMethods.copyArray(m_pnPixels, m_pnPixelsCompensated);
   CommonMethods.displayPixels(m_pnPixelsCompensated, "before compensation", impl.getType());
   m_cIMSC.reset();
   Point pt;
   int index, step = 0, pixel, i, r0;
   double dm, dsur;
   ImageShape shape;
   while (true) {
     pt = m_cIMSC.getPosition();
     index = getPercentileIndex(step);
     dsur = m_pcRingMeanSems_Mean[index][m_nRMax].mean;
     r0 = m_pnAveRadius[index];
     //
     // m_pnPixelsCompensated[pt.y][pt.x]-=(int)(m_cPixelMeanSems_trail[index].mean-dsur);
     for (i = 0; i < numRings; i++) {
       pixel = (int) (m_pcRingMeanSems_Mean[index][i].mean - dsur);
       if (pixel < 1) break;
       shape = m_cvRings.get(i);
       shape.setCenter(pt);
       ImageShapeHandler.addValue(m_pnPixelsCompensated, shape, -pixel);
     }
     if (m_cIMSC.done()) break;
     m_cIMSC.move();
     step++;
   }
   CommonMethods.displayPixels(m_pnPixelsCompensated, "after compensation", impl.getType());
   return 1;
 }
 public void buildIPOGContourShapes(int[][] pixelsCompensated, int[][] pnScratch, int cutoff) {
   int h = pixelsCompensated.length, w = pixelsCompensated[0].length;
   intRange xRange3 = new intRange(), yRange3 = new intRange();
   IPOGaussianNodeHandler.getRanges3(IPOGNode.IPOGs, xRange, yRange);
   xRange.setCommonRange(new intRange(0, w - 1));
   yRange.setCommonRange(new intRange(0, h - 1));
   CommonStatisticsMethods.copyArray(
       pixelsCompensated,
       pnScratch,
       yRange.getMin(),
       yRange.getMax(),
       xRange.getMin(),
       xRange.getMax());
   IPOGaussianNodeHandler.getSuperImposition(pnScratch, IPOGNode.IPOGs);
   if (pnScratch[cy][cx] < cutoff) {
     cContourShape = new CircleImage(3);
     cContourShape.setCenter(new Point(cx, cy));
     cContourShape.setFrameRanges(new intRange(0, w - 1), new intRange(0, h - 1));
   } else {
     ArrayList<Point> contour =
         ContourFollower.getContour_Out(
             pnScratch, w, h, new Point(cx, cy), cutoff, Integer.MAX_VALUE, true);
     cContourShape = ImageShapeHandler.buildImageShape(contour);
   }
 }