Class EntropyParamCalculator
- java.lang.Object
-
- edu.gsu.cs.dmlab.imageproc.imageparam.EntropyParamCalculator
-
- All Implemented Interfaces:
IParamCalculator
public class EntropyParamCalculator extends Object implements IParamCalculator
This class is designed to compute the entropy of each patch of the givenBufferedImage
, based on the following formula:
E = - SUM{p(z_i)* log_2(p(z_i))}
where:- p: the histogram of this patch.
- z_i: the intensity value of the i-th pixel in this patch.
- p(z_i): The frequency of the intensity z_i in the histogram of this patch whose entropy parameter is being calculated.
This formula was given in several other literature such as:
- Digital Image processing, 3rd Ed, Addison Wesley, {page 513}
- http://math.ucr.edu/home/baez/information_loss.pdf
Note: For each patch, the histogram of that particular patch is used in the formula, and not the histogram of the entire image.
Note: For comparison of results, Entropy can be computed using the following script inR
:
library(CulturalAnalytics)
library(jpeg)
img <- readJPEG('CODES/DMLab_git/dmlablib/sdo.jpg')
histogram <- hist(imageToIntensity(img), breaks=90, plot=FALSE)
entropy <- imageEntropy(histogram)
- Author:
- Azim Ahmadzadeh, Data Mining Lab, Georgia State University
-
-
Constructor Summary
Constructors Constructor Description EntropyParamCalculator(IMeasures.PatchSize patchSize, int numberOfBins, double minPixelValue, double maxPixelValue)
EntropyParamCalculator(IMeasures.PatchSize patchSize, int indexOfNumberOfBins, int factor)
The second constructor to be used when instead of the actual nOfBins, their index is provided.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description double[][]
calculateParameter(double[][] image)
This method computes the entropy for each patch of the given image in the form of a 2D array.void
setMaxPixelVal(double maxPixelVal)
void
setMinPixelVal(double minPixelVal)
-
-
-
Constructor Detail
-
EntropyParamCalculator
public EntropyParamCalculator(IMeasures.PatchSize patchSize, int numberOfBins, double minPixelValue, double maxPixelValue)
- Parameters:
patchSize
- size of each patch of the image the parameter should be calculated on.numberOfBins
- is used to get the histogram of colors based on which the probability should be calculated. A good choice could be one tenth of the sample size (i.e., 0.01*(maxPixelVal - minPixelVal).minPixelValue
- is the minimum intensity value of a pixel. For JPEG formats, it is 0, and for FITS files it is also 0, given that the data is cleaned and negative noises are removed.maxPixelValue
- is the maximum intensity value of a pixel. For JPEG formats, it is 255, and for FITS files it is 16383 (2^14).
Note: In case different mins and maxes are needed for different wavebands, use the provided setters where the methodcalculateParameter
is called. If this is the case, Use the other constructor which uses the index of nOfBins instead of nOfBins.
-
EntropyParamCalculator
public EntropyParamCalculator(IMeasures.PatchSize patchSize, int indexOfNumberOfBins, int factor)
The second constructor to be used when instead of the actual nOfBins, their index is provided. This is needed for the cases when generic nOfBins are needed.- Parameters:
patchSize
- size of each patch of the image the parameter should be calculated on.indexOfNumberOfBins
- For the cases where the number of bins depends on the waveband, this argument allows to assign the number of bins in a generic way. This requires a prior knowledge about the minPixelVal and maxPixelVal. This can be achieved by calling the provided setters where the methodcalculateParameter
should be called.factor
- is a scalar by which the bin width of the color histogram will be divided. This is done by multiplying the max color intensity when nOfBins is to be generated (see,findNOfBinsForIndex_Bounded
in this method). In other words, with factor = 1 for min=0 and max=44, the number of bins that will be tried are {2,4,6, ..., 44} while for factor=10, for the same range, the set will be changed to {20, 41, ..., 440}. Set this to 1, if it should be ineffective.
-
-
Method Detail
-
calculateParameter
public double[][] calculateParameter(double[][] image)
This method computes the entropy for each patch of the given image in the form of a 2D array.
Note: See the definition of entropyEntropyParamCalculator
- Specified by:
calculateParameter
in interfaceIParamCalculator
- Parameters:
image
- a 2D array representing the input image for which the parameter should be computed.- Returns:
- a 2D matrix whose each entry corresponds to the calculated parameter for one particular patch of the image.
-
setMinPixelVal
public void setMinPixelVal(double minPixelVal)
-
setMaxPixelVal
public void setMaxPixelVal(double maxPixelVal)
-
-