HoughLines implements 
	ImageAnalyser<FImage>, 
	Iterable<Line2d>,
	Iterator<Line2d> { public HoughLines() { this( 360 , 0f); } HoughLines();  HoughLines(float onValue);  HoughLines( int nSegments , float onValue); @Override void analyseImage(FImage image); FImage getAccumulator(); FImage calculateHorizontalProjection(); FImage calculateHorizontalProjection( FImage accum ); double calculatePrevailingAngle(); double calculatePrevailingAngle( FImage accum, int offset, double nDegrees ); double calculatePrevailingAngle( float minTheta, float maxTheta ); Line2d getBestLine(); Line2d getBestLine( FImage accumulatorSpace, int offset ); Line2d getBestLine( float minTheta, float maxTheta ); List<Line2d> getBestLines( int n, float minTheta, float maxTheta ); List<Line2d> getBestLines( int n ); List<Line2d> getBestLines( int n, FImage accumulatorSpace, int offset ); Line2d getLineFromParams( int theta, int dist, int x1, int x2 ); @Override Iterator<Line2d> iterator(); @Override boolean hasNext(); @Override Line2d next(); @Override void remove(); void clearIterator(); void setNumberOfSegments( int numberOfSegments ); int getNumberOfSegments();  }
@Test public void testHoughLines() { try { HoughLines hl = new HoughLines(); FImage i = ImageUtilities.readF( HoughLinesTest.class.getResource( "/hough.jpg" ) ); i.analyseWith( hl ); MBFImage m = new MBFImage( i.getWidth(), i.getHeight(), 3 ); MBFImageRenderer renderer = m.createRenderer(); renderer.drawImage( i, 0, 0 ); List<Line2d> lines = hl.getBestLines( 2 ); Assert.assertEquals( 2, lines.size() ); for( int j = 0; j < lines.size(); j++ ) { Line2d l = lines.get(j); Assert.assertEquals( -2000, l.begin.getX(), 1d ); Assert.assertEquals( 2000, l.end.getX(), 1d ); l = l.lineWithinSquare( new Rectangle( 0, 0, m.getWidth(), m.getHeight() ) ); renderer.drawLine( l, 2, new Float[]{1f,0f,0f} ); System.out.println( l ); Assert.assertEquals( 0d, l.begin.getX(), 5d ); } DisplayUtilities.display( m ); } catch( IOException e ) { e.printStackTrace(); } }