net.sourceforge.jiu.color.analysis

Class TextureAnalysis


public class TextureAnalysis
extends Operation

This class determines a number of properties for a given co-occurrence matrix. The only input parameter is a mandatory co-occurrence matrix object to be specified using setMatrix(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.

Usage example

Use like that:
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.

Caveat: memory consumption

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:

Author:
Marco Schmidt
Since:
0.7.0

Field Summary

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

Fields inherited from class net.sourceforge.jiu.ops.Operation

abort, progressListeners

Method Summary

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.

Methods inherited from class net.sourceforge.jiu.ops.Operation

addProgressListener, addProgressListeners, getAbort, process, removeProgressListener, setAbort, setProgress, setProgress

Field Details

contrast

private int contrast

correlation

private double correlation

dissimilarity

private int dissimilarity

energy

private int energy

entropy

private double entropy

homogeneity

private double homogeneity

matrix

private CoOccurrenceMatrix matrix

sum

private int sum

symmetry

private boolean symmetry

Method Details

compute

public static TextureAnalysis compute(CoOccurrenceMatrix matrix)
            throws MissingParameterException
Create a TextureAnalysis operation with the results computed from a given matrix.
Parameters:
matrix - co-occurrence matrix to use for texture analysis
Returns:
TextureAnalysis object with all attributes computed
Throws:
MissingParameterException - if matrix is null
Since:
0.14.2

compute

public static TextureAnalysis compute(IntegerImage image,
                                      int channelIndex)
            throws MissingParameterException
For one channel of the argument image, create a TextureAnalysis operation with all attributes
Parameters:
image - the IntegerImage for which the texture analysis is being done
channelIndex - zero-based index of channel to work on
Returns:
TextureAnalysis object with all attributes computed
Throws:
MissingParameterException - if matrix is null
Since:
0.14.2

getContrast

public int getContrast()

getCorrelation

public double getCorrelation()

getDissimilarity

public int getDissimilarity()

getEnergy

public int getEnergy()

getEntropy

public double getEntropy()

getHomogeneity

public double getHomogeneity()
Returns the homogeneity value determined in process(). Also called inverse difference moment.

getSum

public int getSum()
Returns the sum of all entries in the matrix.

isSymmetrical

public boolean isSymmetrical()

process

public void process()
            throws MissingParameterException
Run over the input matrix and determine contrast, energy, entropy and homogeneity of that matrix.
Overrides:
process in interface Operation
Throws:
MissingParameterException - if no co-occurrence matrix was provided using setMatrix(CoOccurrenceMatrix)

setMatrix

public void setMatrix(CoOccurrenceMatrix m)
Sets the matrix to be used by this operation to the argument value.
Parameters:
m - the matrix for which the various properties will be computed