HoughCircles implements ImageAnalyser<FImage> { public List<WeightedCircle> getBest(int n) { final BoundedPriorityQueue<WeightedCircle> bpq = new BoundedPriorityQueue<WeightedCircle>(n); this.radmap.forEachEntry(new TIntObjectProcedure<TIntObjectHashMap<TIntFloatHashMap>>() { @Override public boolean execute(final int radius, TIntObjectHashMap<TIntFloatHashMap> b) { b.forEachEntry(new TIntObjectProcedure<TIntFloatHashMap>() { @Override public boolean execute(final int x, TIntFloatHashMap b) { b.forEachEntry(new TIntFloatProcedure() { @Override public boolean execute(int y, float weightedCount) { bpq.offer(new WeightedCircle(x, y, radius, weightedCount)); return true; } }); return true; } }); return true; } }); return bpq.toOrderedList(); } HoughCircles(int minRad, int maxRad, int radIncrement, int nDegree); @Override void analyseImage(FImage image); List<WeightedCircle> getBest(int n);  }
@Test public void testCircle() { final int imgWidthHeight = 200; final FImage circleImage = new FImage(imgWidthHeight, imgWidthHeight); final Circle c = new Circle(imgWidthHeight / 2 + 3, imgWidthHeight / 2 + 1, imgWidthHeight / 4); circleImage.drawShapeFilled(c, 1f); final CannyEdgeDetector det = new CannyEdgeDetector(); final FImage edgeImage = circleImage.process(det); final HoughCircles circ = new HoughCircles(5, imgWidthHeight, 5, 360); edgeImage.analyseWith(circ); final List<WeightedCircle> best = circ.getBest(1); final WeightedCircle b = best.get(0); assertTrue(b.equals(c)); }