Class 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 given BufferedImage. In this class, a Box counting approach known as Minkowski–Bouligand Dimension is implemented. See M-B Dimension.
    Note: If null 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:
    1. divide the image into small patches,
    2. apply CannyEdgeDetector on each patch, to get a B & W image of edges,
    3. run the countBoxes method for each edge-detected patch, and get the number of boxes that intersect with a detected edge,
    4. for the line introduced by the boxSizes and counts, find the slope fo the regression, as the Fractal Dimension of that patch,
    5. finally, return a matrix of fractal dimensions of all patches.
    * The algorithm for the method countBoxes() is inspired from: FractalBoxCounter (Look for the method count(...)).
    * For Edge Detection, a class implemented by Tom Gibar is imported. see CannyEdgeDetector

    Author:
    Azim Ahmadzadeh, Data Mining Lab, Georgia State University
    • 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 argument binaryColors 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 interface IParamCalculator
        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 array image is a binary array containing only colors[0] as the background and colors[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 image
        imageH - The height of the image
        boxSize - 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()