Class AlgorithmCircleGeneration

  • All Implemented Interfaces:
    java.awt.event.ActionListener, java.awt.event.WindowListener, java.lang.Runnable, java.util.EventListener

    public class AlgorithmCircleGeneration
    extends AlgorithmBase
    This module draws uniformly randomly positioned circles with a specified radius. See http://www.indiana.edu/~statmath for skewness, kurtosis, and Jarque-Bera Test that uses skewness and kurtosis to test for normality. Tests for a Gaussian fit reveal nothing since RANDOM, AGGREGATED, UNIFORM, and CONSTRAINED patterns all fail Gaussian fit tests. From Computational Methods in Biophysics, Biomaterials, BioTechnology, and Medical Systems Algorithm Development, Mathematical Analysis, and Diagnostics Volume 2 Computational Methods edited by Cornelius T. Leondes, Chapter 2 Computer techniques for spatial analysis of objects in biomedical images by G. Cevenini, M. R. Massia, and P. Barbini, Kluwer Academic Publishers, 2003, pp. 39-90, information about randomly distributed circles. "Analysis of the distribution W**2 of squared NN distances between n randomly distributed circles shows that 2*lambda*PI*(W**2 - n*diameter**2) has a chi-squared distribution with 2*n degrees of freedom. diameter is the average diameter of the circular objects, lambda is the mean number per unit area. X is a point to NN object distance. W is an inter-object NN distance. Consider W as going from the center of one object to the center of the nearest object. The point-object squared NN distance distribution, X**2, is not affected by the reperesentation of objects as circles, thus 2*lambda*X**2 also has a chi-squared distribution with 2m degrees of freedom, where m is the number of selected points. It means that, under the assumption of circular objecs of equal size, all tests based on squared NN distances, like those of Hopkins, Brown, or others, can still be used. If m = n, and these results are combined, an estimate of the mean radius of the objects as circles can be obtained as rest = sqrt((W**2 - X**2)/n) Again, a Monte Carlo approach is sugested. If rest is significantly different from the value measured directly on the image by automatic procedures of digital image processing or a value nevertheless compatible with the average physical size of the objects, we can sustain that the statistical pattern is not random. If rest is high, it indicates regularity; if low, aggregation. Moreover, since the formula for rest is formally a function of NN distances, we can again inspect classes of distances to obtain scale-related indications about the statistical pattern. Best reference for nearest neighbor distribution for equally sized circles is: "Nearest Neighbor Assessments of Spatial Configurations of Circles rather Than Points" by Daniel Simberloff, Ecology, Vol. 60, No. 4, Aug. 1979, pp. 679-685. d = diameter lambda = mean number per unit area Dr. Daniel Simberloff writes: "In any event, you are probably correct that it would be more logical to caclulate rho for the points only in the interior, not the border region, remembering to leave out the border region when calculating area." mean nearest neighbor value = d + (exp(lambda * PI * d**2)/sqrt(lambda)*integral from t = d*sqrt(2*lambda*PI) to t = infinity of (1/sqrt(2*PI))*exp(-t**2/2)dt. The integral is simply the 1 - Gaussian probability integral. E(nearest neighbor distance squared) = d**2 + 1/(lambda * PI) variance = E(r**2) - [E(r)]**2 = d**2 + 1/(lambda * PI) - [E(r)]**2 standard error = sqrt(variance)/sqrt(N) Get percentile from Gaussian probability integral. If the measured mean is significantly greater than the analytical mean, the distribution is uniform or regular. If the measured mean is signficantly less than than the analytical mean, the distribution is clumped or aggregated. For larger circles these equations become increasingly inaccurate because an assumption of the Poisson distribution of rare events is violated: the mean number of circles per sampling unit is not small relative to the maximum possible number of circles per sampling unit. In fact for a given lambda there is a maximum E[r]= sqrt(2)/((3**0.25)*sqrt(lambda)), which obtains when all the points are perfectly arranged as vertices of a hexagonal lattice. Put another way, the maximum size circles that can be arranged with density lambda have diameter d = sqrt(2)/((3**0.25)*sqrt(lambda)), and are located at the centers of hexagons completely filling space. At d = sqrt(2)/((3**0.25)*sqrt(lambda)), the standard error of average r will be zero, since there is only one possible arrangement. The Poisson derived expresion for standard error does not vanish until d is somewhat greater than this maximum d. According to Simberloff for d = 0 and lambda = 0.005, E[r] = 7.0711. When I ran a random distribution for 10,000 by 1,000 with 50,000 circles requested and circle diameter = 0, I had observed mean = 7.09 and analytical mean = 7.0717. The analytic equation for E[r(d,lambda)] is quite accurate for d as large as E[r(0, lambda)]; it exceeds the simulated value by only 6.6%. The analytic equation for the standard error begins to go badly awry at approximately d = 0.75E[r(0,lambda)]. For example, for d = E[r(0,lambda)], whereas the equation for E[r] exceeds its true value by only 6.6%, the calculated standard error exceeds the correct value by 29.1%. For small circles either the analytic expressions or simulations for the expected mean nearest neighbor and its standard error can be used, but for larger circles simulations should be used. Let x2 = chi squared and v = degrees of freedom The probability density function p(x2,v) = (1/((2**(v/2))* gamma(v/2)))*(x2**((v-2)/2))*exp(-x2/2) The probability of observing a value of chi square that is larger than a particular value for a random sample of N observations with v degrees of freedom is the integral of this probability from chi square = x2 to chi square = infinity. I have used the formula from "Nearest-neighbor distribution functions in many-body systems" by S. Torquato, B. Lu. and J. Rubinstein, The American Physical Society Physical Review A, Volume 41, Number 4, February 15, 1990, pp. 2059-2075. Let the area fraction of the circles = af a2 = 4*af/((1 - af)**2) b2 = 4*af*(2 + af)/((1 - af)**2) mean nearest neighbor distance = diameter * (1 + 0.5*sqrt(PI/a2)*exp(b2*b2/(4*a2))*erfc[b2/(2*sqrt(a2))]) Torquato developed more accurate equations in 1995 superseding the 1990 equations. In "Nearest-neighbor statistics for packings of hard spheres and disks" by S. Torquato, Physical Review E, Volume 51, Number 4, April, 1995, pp. 3170 - 3182: af = area fraction of circles mean nearest neighbor distance = diameter * (1 + integral) integral = integral from x = 1 to x = infinity of exp{-af[4*a0*(x*x - 1) + 8*a1*(x - 1)]} For af
      • Field Detail

        • AGGREGATED_ELLIPSE_RANDOM_ORIENTATION

          public static final int AGGREGATED_ELLIPSE_RANDOM_ORIENTATION
          See Also:
          Constant Field Values
        • AGGREGATED_CIRCLES_DIFFERENT_SIZES

          public static final int AGGREGATED_CIRCLES_DIFFERENT_SIZES
          See Also:
          Constant Field Values
        • AGGREGATED_ELLIPSE_RANDOM_ORIENTATION_DIFFERENT_SIZES

          public static final int AGGREGATED_ELLIPSE_RANDOM_ORIENTATION_DIFFERENT_SIZES
          See Also:
          Constant Field Values
        • radius

          private int radius
        • numCircles

          private int numCircles
        • pattern

          private int pattern
        • initialRandomCircles

          private int initialRandomCircles
        • minimumNearestNeighborDistance

          private double minimumNearestNeighborDistance
        • maximumNearestNeighborDistance

          private double maximumNearestNeighborDistance
        • lowestForbiddenNNDistance

          private double lowestForbiddenNNDistance
        • highestForbiddenNNDistance

          private double highestForbiddenNNDistance
        • highestRegenerationNNDistance

          private double highestRegenerationNNDistance
        • semiMajorAxis

          private double semiMajorAxis
        • semiMinorAxis

          private double semiMinorAxis
        • phi

          private double phi
        • smallestToLargestMajorAxisRatio

          private double smallestToLargestMajorAxisRatio
      • Constructor Detail

        • AlgorithmCircleGeneration

          public AlgorithmCircleGeneration()
          AlgorithmCircleGeneration - default constructor.
        • AlgorithmCircleGeneration

          public AlgorithmCircleGeneration​(ModelImage srcImage,
                                           int radius,
                                           int numCircles,
                                           int pattern,
                                           int initialRandomCircles,
                                           double minimumNearestNeighborDistance,
                                           double maximumNearestNeighborDistance,
                                           double lowestForbiddenNNDistance,
                                           double highestForbiddenNNDistance,
                                           double highestRegenerationNNDistance,
                                           double semiMajorAxis,
                                           double semiMinorAxis,
                                           double phi,
                                           double smallestToLargestMajorAxisRatio)
          AlgorithmRandomCircleGeneration.
          Parameters:
          srcImg - Blank source image in which circles will be drawn
          radius - Circle radius
          numCircles - Number of circles to be drawn
          pattern - RANDOM, AGGREGATED, or REGULAR
          initialRandomCircles - Used in AGGREGATED. initialRandomCircles are drawn randomly. The rest are drawn with nearestNeighborDistance less than or equal ot maximumNearestNeighborDistance.
          minimumNearestNeighborDistance - Used in REGULAR
          maximumNearestNeighborDistance - Used in AGGREGATED and REGULAR
          lowestForbiddenNNDistance - Used in CONSTRAINED
          highestForbiddenNNDistance - Used in CONSTRAINED
          highestRegeneerationNNDistance - Used in CONSTRAINED
          semiMajorAxis - used in AGGREGATED_ELIPSE
          semiMinorAxis - used in AGGREGATED_ELLIPSE
          phi - used in AGGREGATED_ELLIPSE
          smallestToLargestMajorAxisRatio - used in AGGREGATED_CIRCLES_DIFFERENT_SIZES