Class FractalDimParamCalculator
- java.lang.Object
-
- edu.gsu.cs.dmlab.imageproc.imageparam.FractalDimParamCalculator
-
- All Implemented Interfaces:
IParamCalculator
public class FractalDimParamCalculator extends Object implements IParamCalculator
This class is designed to compute the Fractal Dimension parameter for each patch of the givenBufferedImage
. In this class, a Box counting approach known as Minkowski–Bouligand Dimension is implemented. See M-B Dimension.
Note: Ifnull
is passed as the edge-detector interface, the given image will be considered binary with only two values: 0 (black:background) and 255 (white:foreground).
The general steps are as follows:- divide the image into small patches,
- apply
CannyEdgeDetector
on each patch, to get a B & W image of edges, - run the
countBoxes
method for each edge-detected patch, and get the number of boxes that intersect with a detected edge, - for the line introduced by the
boxSizes
andcounts
, find the slope fo the regression, as the Fractal Dimension of that patch, - finally, return a matrix of fractal dimensions of all patches.
countBoxes()
is inspired from: FractalBoxCounter (Look for the methodcount(...)
).
* For Edge Detection, a class implemented by Tom Gibar is imported. seeCannyEdgeDetector
- Author:
- Azim Ahmadzadeh, Data Mining Lab, Georgia State University
-
-
Constructor Summary
Constructors Constructor Description FractalDimParamCalculator(IMeasures.PatchSize patchSize, double[] binaryColors)
This constructor should be used when the edge detection step is not needed.FractalDimParamCalculator(IMeasures.PatchSize patchSize, IEdgeDetector edgeDetector)
This constructor should be used when the edge detection step is needed and the input image is not in the binary mode.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description double[][]
calculateParameter(double[][] image)
This polymorphic method is designed to compute any of the 10 parameters at a time.int
countBoxes(double[] image, int imageW, int imageH, int boxSize, double[] colors)
This method counts the number of boxes which intersect with at least one pixel of the foreground (i.e., detected edges)
Note: This method assumes that the given image (represented by the 1D matrix) is already edge-detected, meaning that the arrayimage
is a binary array containing onlycolors[0]
as the background andcolors[1]
as the foreground.int[]
getBoxSizes()
int
getMaxBoxSize()
-
-
-
Constructor Detail
-
FractalDimParamCalculator
public FractalDimParamCalculator(IMeasures.PatchSize patchSize, IEdgeDetector edgeDetector)
This constructor should be used when the edge detection step is needed and the input image is not in the binary mode.
This constructor only initializes the class fields.- Parameters:
patchSize
- the size of the boxes by which the image will be processed.edgeDetector
- the algorithm to be used to extract the binary image of edges from the input image.
-
FractalDimParamCalculator
public FractalDimParamCalculator(IMeasures.PatchSize patchSize, double[] binaryColors)
This constructor should be used when the edge detection step is not needed. In this case, the input image is assumed to be binary with edges separated from the background. The argumentbinaryColors
represents the background (binaryColors[0]
) and the foreground (binaryColors[1]
) of the image.
This constructor only initializes the class fields.- Parameters:
patchSize
- the size of the boxes by which the image will be processed.binaryColors
- represents the background (binaryColors[0]
) and the foreground (binaryColors[1]
) of the image.
-
-
Method Detail
-
calculateParameter
public double[][] calculateParameter(double[][] image)
Description copied from interface:IParamCalculator
This polymorphic method is designed to compute any of the 10 parameters at a time. It iterates over the given image, patch by patch, and then in every patch, pixel by pixel, to compute the parameter value for each patch.
Note: In all the classes, matrices are read and write, row by row.
Note: It is required that each class works independently, meaning that they must rely on their own computations. Therefore, some calculations (e.g. mean intensity value) might be calculated several times for different parameters (e.g. once for skewness and another time for std. deviation).
Note: No fixed range for the color intensity values of the given images is assumed. (colors do not have to be within the range [0,255].)- 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.
-
countBoxes
public int countBoxes(double[] image, int imageW, int imageH, int boxSize, double[] colors)
This method counts the number of boxes which intersect with at least one pixel of the foreground (i.e., detected edges)
Note: This method assumes that the given image (represented by the 1D matrix) is already edge-detected, meaning that the arrayimage
is a binary array containing onlycolors[0]
as the background andcolors[1]
as the foreground.
Note: The box counting algorithm is inspired from: FractalBoxCounter- Parameters:
image
- The given image in the form of a 1D matrix of binary values; background and foreground.imageW
- The width of the imageimageH
- The height of the imageboxSize
- The size of the box using for applying the box-counting method on the edges.colors
- An array of length two.colors[0]
represents the background color (0:black) and color[1] the foreground color (255: white).- Returns:
- The number of boxes needed to cover all the edges on the given image.
-
getBoxSizes
public int[] getBoxSizes()
-
getMaxBoxSize
public int getMaxBoxSize()
-
-