public class TextureAnalysis extends Operation
setMatrix(net.sourceforge.jiu.color.data.CoOccurrenceMatrix)
.
Then process()
must be called.
After that, the various properties can be retrieved using the
corresponding get methods, e.g. getContrast()
,
getEnergy()
etc.
Static convenience methods compute(CoOccurrenceMatrix)
and
compute(IntegerImage, int)
exist for simplified usage.
You may need to cast your PixelImage
to
IntegerImage
first.
GrayIntegerImage img = ...; TextureAnalysis op = TextureAnalysis.compute(img); System.out.println("Entropy=" + op.getEntropy());Use the compute method that takes a
CoOccurrenceFrequencyMatrix
if you want to reuse a matrix object.
Will not work with 16 bit image objects because MemoryCoOccurrenceMatrix
is rather unsophisticated, trying to allocate 4 * 65536 * 65536 bytes (16 GB).
Solution is an implementation of CoOccurrenceMatrix
which creates element counters on demand.
The following resources were helpful when creating this class:
Modifier and Type | Field | Description |
---|---|---|
private int |
contrast |
|
private double |
correlation |
|
private int |
dissimilarity |
|
private int |
energy |
|
private double |
entropy |
|
private double |
homogeneity |
|
private CoOccurrenceMatrix |
matrix |
|
private int |
sum |
|
private boolean |
symmetry |
Constructor | Description |
---|---|
TextureAnalysis() |
Modifier and Type | Method | Description |
---|---|---|
static TextureAnalysis |
compute(CoOccurrenceMatrix matrix) |
Create a TextureAnalysis operation with the results computed from a
given matrix.
|
static TextureAnalysis |
compute(IntegerImage image,
int channelIndex) |
For one channel of the argument image,
create a TextureAnalysis operation with all attributes
|
int |
getContrast() |
Returns the contrast value determined in
process() . |
double |
getCorrelation() |
Returns the correlation determined in
process() . |
int |
getDissimilarity() |
Returns the dissimilarity value determined in
process() . |
int |
getEnergy() |
Returns the energy value determined in
process() . |
double |
getEntropy() |
Returns the entropy value determined in
process() . |
double |
getHomogeneity() |
Returns the homogeneity value determined in
process() . |
int |
getSum() |
Returns the sum of all entries in the matrix.
|
boolean |
isSymmetrical() |
|
void |
process() |
Run over the input matrix and determine contrast, energy, entropy and homogeneity
of that matrix.
|
void |
setMatrix(CoOccurrenceMatrix m) |
Sets the matrix to be used by this operation to the argument value.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addProgressListener, addProgressListeners, getAbort, removeProgressListener, setAbort, setProgress, setProgress
private CoOccurrenceMatrix matrix
private int contrast
private double correlation
private int dissimilarity
private int energy
private double entropy
private double homogeneity
private int sum
private boolean symmetry
public static TextureAnalysis compute(CoOccurrenceMatrix matrix) throws MissingParameterException
matrix
- co-occurrence matrix to use for texture analysisMissingParameterException
- if matrix is nullpublic static TextureAnalysis compute(IntegerImage image, int channelIndex) throws MissingParameterException
image
- the IntegerImage for which the texture analysis is being donechannelIndex
- zero-based index of channel to work onMissingParameterException
- if matrix is nullpublic int getContrast()
process()
.
Also called inertia.public double getCorrelation()
process()
.public int getDissimilarity()
process()
.public int getEnergy()
process()
.public double getEntropy()
process()
.public double getHomogeneity()
process()
.
Also called inverse difference moment.public int getSum()
public boolean isSymmetrical()
public void process() throws MissingParameterException
process
in class Operation
MissingParameterException
- if no co-occurrence matrix was provided using
setMatrix(net.sourceforge.jiu.color.data.CoOccurrenceMatrix)
public void setMatrix(CoOccurrenceMatrix m)
m
- the matrix for which the various properties will be computed