Maven module :un.api : api-image :
Class : un.impl.image.process.detection.SymmetryDetector
Extends/Implements : -
Subclasses : -

An object that attempts to identify the reflectional symmetry in thresholded
image subject to the parameters set on it. A few notes:
This code is in the public domain.
Parameter changes must be externally synchronized, otherwise the object is
safe for multi-threaded use.
Better performance will be experienced by supplying pixel data in byte arrays
and not images.
The arrays of pixel data supplied to this object will not be modified by it.
Origin :
http://www.tomgibara.com/computer-vision/SymmetryDetector.java
TODO :


Variables : -
Functions : setBackgroundValue, getBackgroundValue, setObservation, getObservation, setValueThreshold, getValueThreshold, setResolution, getResolution, setRadiusCount, getRadiusCount, setMaximumRadius, getMaximumRadius, setScoreThreshold, getScoreThreshold, setAngularAliasing, getAngularAliasing, detectSymmetry, detectSymmetry




The value of background pixels. Any value that is not equal to this value
is treated as a pixel of the object. This object can automatically
identify pixels as background-pixels subject to a specified value
threshold. The default value is 0.
param  backgroundValue the value of background pixels
public void setBackgroundValue (byte backgroundValue)


return  the value of background pixels
public byte getBackgroundValue ()


If a non-null graphics context is supplied to this method. The object
will render its computations. It is expected (but not required) that the
supplied graphics context matches the dimensions of the image supplied to
detectSymmetry.
param  observation a graphics context through which the algorithm may be
observed
public void setObservation (Graphics2D observation)


return  the observing graphics context
public Graphics2D getObservation ()


This object can threshold the grayscale image as the algorithm executes.
This is slower than operating the algorithm on pre-thresholded data, but
probably faster than thresholding the data separately. The threshold
should be in the range 0-255. Supplying a threshold of -1 disables the
thresholding. The default value is -1.
param  threshold the threshold that separates background/foreground
pixels
public void setValueThreshold (int threshold)


return  the threshold that separates background/foreground pixels or -1
public int getValueThreshold ()


The number of angles examined for symmetry within an arc of PI radians.
Must be strictly positive. The default value is 64
param  resolution the angular resolution
public void setResolution (int resolution)


return  the angular resolution
public int getResolution ()


The number of radii used to test symmetry. Must be strictly positive. The
default value is 10.
param  radiusCount the number of radii tested
public void setRadiusCount (int radiusCount)


return  the number of radii tested
public int getRadiusCount ()


If an approximate object radius (distance from the centroid to the
furthest object pixel) is already known, it can be supplied to this
object, otherwise the object radius is calculated as part of the
algorithm. Supplying a value of -1 indicates that a very fast
approximation should be used. Supplying a value of -2 indicates that the
radius should be measured. The default value is -2.
param  maximumRadius the approximate object radius or -1 or -2
public void setMaximumRadius (int maximumRadius)


return  the approximate object radius or -1 or -2
public int getMaximumRadius ()


A value between 0 and 1 that controls the strictness with which axes of
symmetry are judged. The appropriate value for this parameter is entirely
dependent on the application of this algorithm. The default value is 0.9.
param  scoreThreshold a value between 0 and 1
public void setScoreThreshold (float scoreThreshold)


return  a value between 0 and 1
public float getScoreThreshold ()


To suppress the clustering of almost identical angles of symmetry, the
algorithm attempts to merge adjacent angles into one more accurate
response. This paramter specifies (an approximate) angle of separation
below which axes of symmetry are combined. The default value is Pi/18 (10
degrees).
param  angularAliasing the least angle between axes of symmetry in
radians
public void setAngularAliasing (double angularAliasing)


return  the least angle between axes of symmetry in radians
public double getAngularAliasing ()


Attempts to identify the axes of reflectional symmetry within the
supplied image. The image must have type BufferedImage.TYPE_BYTE_GRAY. If
the image has not already been thresholded to two values, a
valueThreshold must have been set on this object.
param  image the image containing the object
return  the identified symmetry
public Symmetry detectSymmetry (BufferedImage image)


Attempts to identify the axes of reflectional symmetry within the
supplied pixel data. If the data contains more than two values, a
valueThreshold must have been set on this object.
param  width the number of columns of pixel data
param  height the number of rows of pixel data
param  pixels an array containing the grayscale pixel data
return  the identified symmetry
public Symmetry detectSymmetry (int width, int height, byte[] pixels)