registration
Class HoughTransform

java.lang.Object
  extended by registration.HoughTransform

public class HoughTransform
extends java.lang.Object

This class implements a Hough transformer. For the Hough circle transform, parts based on work by Hemerson Pistori (pistori@ec.ucdb.br), Eduardo Rocha Costa (eduardo.rocha@poli.usp.br) and Mark A. Schulze (http://www.markschulze.net/) Copyright (c) 1999-2004, Michael Abramoff. All rights reserved.


Field Summary
 double threshold
          The edge threshold.
 
Constructor Summary
HoughTransform(int width, int height, double threshold)
          New Hough transform.
HoughTransform(java.awt.Rectangle roi, double threshold)
          New Hough transform for a ROI.
 
Method Summary
 void circleTransform(float[] image, int imagewidth, double radius)
          Hough transform the image for a circle with radius.
 float[] getCenter()
          Get the center of the first Hough transform circle.
 LocatedCircle getCircle(float[] image, int imagewidth, int imageheight, float radius)
          Find the circle in the image of radius.
 java.util.Vector getCircles(int maxc, double scale)
          Find the centers of the circles corresponding to radius by analyzing, but not within scale pixels of each other, the Hough transform for its maxima.
 ij.process.ImageProcessor getImageProcessor()
          Make an ImageJ ImageProcessor from this transform.
 LocatedCircle getLargestCircle(float[] image, int imagewidth, int imageheight)
          Find the largest circle in the image that has a 'good' fit.
 float[] getValues()
          Get the Hough transform value vector.
static float[] line(float[] image, int width, int distanceBins, int thetaBins)
          Hough transform image for lines with angle theta and distance from center.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

threshold

public double threshold
The edge threshold. Only pixels over threshold are used for the Hough transform

Constructor Detail

HoughTransform

public HoughTransform(int width,
                      int height,
                      double threshold)
New Hough transform.


HoughTransform

public HoughTransform(java.awt.Rectangle roi,
                      double threshold)
New Hough transform for a ROI.

Method Detail

circleTransform

public void circleTransform(float[] image,
                            int imagewidth,
                            double radius)
Hough transform the image for a circle with radius.

Parameters:
image - a float[] the image
imagewidth - the width in pixels of the image
radius - a double with the radius of the circle.

line

public static float[] line(float[] image,
                           int width,
                           int distanceBins,
                           int thetaBins)
Hough transform image for lines with angle theta and distance from center. The number of accumulator bins for theta (in degrees) and distance is given (in other words, the height and width of the resulting image). Good values are 360 and 100 for general applications.

Parameters:
image - a float[] the image
width - the width in pixels of the image
thetaBins - number of bins for angle. The more bins, the more precision in the angle, but the slower.
distanceBins - number of bins for distance. The more bins, the more precision in the distance from center, does not have an effect on processing speed.

getValues

public float[] getValues()
Get the Hough transform value vector.

Parameters:
the - values as a float[]

getCenter

public float[] getCenter()
Get the center of the first Hough transform circle.

Returns:
a float[] with the x-coordinate in [0] and the y coordinate in [1].

getCircles

public java.util.Vector getCircles(int maxc,
                                   double scale)
Find the centers of the circles corresponding to radius by analyzing, but not within scale pixels of each other, the Hough transform for its maxima. The exclusion of nearby centers is very brutal by setting the Hough values for a small square area to 0. The confidence is computed by taking the value at the maximum, divided by the maximum value the Hough transform might have at any point (based on the radius).

Parameters:
maxc - the maximum number of circle centers to look for.
scale - the scale at which you are looking. Determines the area around a center around which other circles are not found.
Returns:
a Vector of HoughCircle s containing the circle parameters, and also its confidence.

getLargestCircle

public LocatedCircle getLargestCircle(float[] image,
                                      int imagewidth,
                                      int imageheight)
Find the largest circle in the image that has a 'good' fit. Start with a circle twice as large as the image, iterate through ever smaller diameters, as long as the confidence goes up. Looks for only a single circle. Simple steepest descent.

Parameters:
image - the image
imagewidth - the width of the image in pixels.
imageheight - the height of the image in pixels.
Returns:
a HoughCircle s containing the circle parameters, and also its confidence.

getCircle

public LocatedCircle getCircle(float[] image,
                               int imagewidth,
                               int imageheight,
                               float radius)
Find the circle in the image of radius.

Parameters:
image - the image
imagewidth - the width of the image in pixels.
imageheight - the height of the image in pixels.
radius - the radius of the circle.
Returns:
a HoughCircle s containing the circle parameters, and also its confidence.

getImageProcessor

public ij.process.ImageProcessor getImageProcessor()
Make an ImageJ ImageProcessor from this transform. For debugging purposes only.