|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--FracLac_2003AugustC
Plugin for ImageJ returns an ImageJ results window showing fractal dimensions, lacunarity, and other measures for binary images.
Operates on single or multiple image files. Popups ask the user for parameters. Shows regression lines for the box counting dimension at the original location, an average box counting dimension, a minimum cover dimension (from the minimum count at each box size over multiple origins), and a slope corrected version.
The user can choose to use one series of grids, where each smaller sized grid is always positioned at the top left corner of the image. Or the user can choose to use several such series, where each smaller size within a series always starts at the same position but the absolute position of the series is randomly chosen from between the top left corner and the edge of the screen (a border is added to images to ensure there is space to do this).
If the subareas option is selected, calculates a distribution of local fractal dimensions over smaller subareas of the image then delivers a colour-coded graphic as well as text values of these local dimensions. This function only works on single images and the option to open multiple images is not allowed in this mode. Alternatively, contact the author for an algorithm to calculate data for the multifractal spectrum of entropies; this is a great deal of data that clutters the results file so is not automatically included.
Delivers information about variability in the image. Calculates the coefficient of variation in the fractal dimension over multiple locations and two lacunarity values, the average coefficient of variation in the pixel distribution and the probability density lacunarity.
Calculates the horizontal and vertical axes of the rectangle and oval enclosing the image, and the perimeter and area of the convex hull enclosing the image. Delivers circularity based on the convex hull. This program is free software distributed in the same way that ImageJ is. A. Karperien, Charles Sturt University, August 2003 Copyright (C) 2003 Audrey Karperien For futher information or to send comments, bugs, and feature requests contact the author or see FracLac page .
file: FracLac_2003August__1.java
IDE: Sun ONE Studio 4, Community Edition
Nested Class Summary | |
class |
FracLac_2003AugustC.ColourRule
Class specifies colours to use for colour coding local fractal dimensions calculated over many subareas. |
Field Summary | |
int |
actualx
Coordinates marking where a grid started. |
int |
actualy
Coordinates marking where a grid started. |
float |
alpha
Specifies the transparency of the graphic for subareas in drawit method . |
double |
AREA
Area of convex hull. |
double[] |
AveragePix
Holds average number of pixels per box size. |
int |
border
Size of border to add around images. |
double |
centrex
Centre coordinate of pixelated area. |
double |
centrey
Centre coordinate of pixelated area. |
double |
circularity
Circularity of convex hull. |
double[] |
colourarray
Holds values for each colour for each square for doing sub areas. |
java.lang.String |
countstring
Holds values for box count data. |
int |
docircul
If set to 1, runs circularity calculations. |
boolean |
doglobal
True does entire image area. |
boolean |
dosomethreshes
True runs automatic thresholding. |
boolean |
dosubs
True finds fractal dimension over several subareas of the image. |
boolean |
fill
True fills coloured squares if subareas are being done. |
int |
foreground
Value of pixels that will be assessed. |
int[][] |
HadPixAllLocAllSize
Integer array of arrays for keeping track of the boxes that had pixels over all locations. |
ij.ImagePlus |
img
Is reused for each image processed. |
int |
incs
Maximum number of box sizes to use in a series. |
ij.process.ImageProcessor |
ip
Is reused for each image processed. |
int |
limit
Integer for limit on number of boxes. |
double |
maxAcross
Stores maximum of pixelated area's width or height |
double |
maxpercent
Maximum percent of image area to use as box size. |
double[] |
mprob
Holds probability density data. |
int |
newNumSizes
Working variable for number of box sizes that is used. |
int |
numlocations
Number of times to do an entire series of grids (i.e., if multiple origins are being used). |
double |
perimeter
Perimeter of convex hull. |
int[] |
PixPerBox
Holds count of number of pixels per box size. |
java.lang.String |
printsummary
"Y" prints summary data. |
boolean |
randomsquares
True checks a random sample of subareas over the image. |
java.awt.Rectangle |
rec
Current rectangle enclosing image. |
double |
roundness
Variable for roundness of convex hull. |
java.lang.String |
sdir
Directory where files to be opened are. |
boolean |
showcolours
True shows a graphic colour coded for the fractal dimension of each subarea. |
java.lang.String |
sizestring
Holds values for box count data. |
double[] |
StdDev
Holds standard deviations of number of pixels per box size. |
int |
subboxsize
Size of boxes to use if doing subareas. |
int |
subsamples
Number of subareas to analyze if doing a random sample. |
boolean |
userNumber
True if the user wants to set the number of boxes rather than use a value optimized for each image size. |
double |
vDiameter
Vertical axis of oval enclosing pixelated area. |
boolean |
viewplots
True shows graphs of regression lines. |
ij.gui.ImageWindow |
win
Is reused for each image. |
int[] |
xarray
Coordinates of each origin for coloured squared for doing sub areas. |
int[] |
yarray
Coordinates of each origin for coloured squared for doing sub areas. |
Constructor Summary | |
FracLac_2003AugustC()
|
Method Summary | |
ij.process.ImageProcessor |
addborder(ij.process.ImageProcessor ip)
Adds a border to the image. |
double |
count(boolean asub,
int boxnumber,
int sze,
ij.process.ImageProcessor ip,
int x,
int y)
Sets up and calls method . |
void |
doBoxCounts(boolean wassub,
ij.process.ImageProcessor ipc,
int x,
int y)
Counts pixels at each box size by calling method
for each size. |
void |
drawit(int w,
int h,
int numShapes,
java.awt.Graphics2D g2,
int s,
int[] x,
int[] y,
double[] colours)
Draws differently coloured squares as specified over an image. |
ij.process.ImageProcessor |
drawNewImage(ij.ImagePlus imp,
int numShapes,
int subboxsize,
int[] x,
int[] y,
double[] colours)
Makes a new BufferedImage using width and height of passed image, and draws that passed image and colours on it by calling drawit method . |
ij.process.ImageProcessor |
expandImage(ij.process.ImageProcessor ipOld,
double wNew,
double hNew,
double xOff,
double yOff)
Adds a border around an image using ImageProcessor functions. |
boolean |
FindMargins(ij.process.ImageProcessor ip)
Finds margins of pixelated part of binary image and sets meassurements for height, width, and span. |
int[] |
findMinCover(int[][] TestArray,
int numLocs,
int numBoxes)
Returns an array holding the minimum value for each position in an array of arrays. |
void |
finishdata(int thisiteration,
java.lang.String origins,
ij.process.ImageProcessor ipk,
FracLac_2003AugustC.StoreAvgs avs,
boolean circ,
boolean issub,
java.lang.String suborglobal)
Calls functions to findMinCover and findAvgCover fractal dimensions. |
java.lang.String |
fnum(double sum,
int decimals)
Formats numbers. |
void |
getCircularityOfConvexHull(ij.process.ImageProcessor ip)
Gets circularity of convex hull for passed ImageProcessor. |
void |
GetDimensions(ij.process.ImageProcessor ip)
Determines the dimensions of the image, and sets some of the important variables. |
boolean |
getInputs()
Gets user inputs from popups to set global variables. |
ij.gui.PolygonRoi |
getPolygon(ij.process.ImageProcessor ip)
This long-winded method determines the vertices of a polygon which forms a convex hull around the image. |
java.lang.String |
makeheadings()
Lists the headings for the results file. |
int[][] |
makerandset(int x,
int y)
Makes a set of random x and y values within bounds x and y. |
int |
moveGridalloverCountPixels(int boxnum,
int xstart,
int ystart,
int sz,
int bot,
int rt,
ij.process.ImageProcessor ipr)
Reinitializes PixPerBox array
then goes over part of the ip using
a series of smaller boxes recording number of pixels in
each box and number of boxes that had pixels. |
void |
openAndrun(boolean DoRandomSquares)
Opens and processes selected files. |
double[] |
probmass(int epsilon)
Returns a double array holding a probability density distribution for the passed array, using as many elements as the passed number; since it is usually called after each box size is scanned, it is usually for a particular epsilon (box size) at a particular location. |
ij.process.ImageProcessor |
ready(ij.process.ImageProcessor ip)
Thresholds, finds margins, and sets foreground value on image to be analyzed. |
void |
run(java.lang.String arg)
Runs FracLac. |
void |
runFL(int thisiteration,
boolean circ,
boolean issub,
ij.process.ImageProcessor ipk,
int x,
int y)
C |
void |
runSubs(boolean DoRandomSquares)
Finds local fractal dimensions over portions of an image. |
void |
savecolour(double dddf,
int iter)
Saves the colour in colourarray
to use at each square for which a local
dimension was calculated. |
int |
stdboxsizes(double Across)
Calculates the array of box sizes. |
double |
writeFinal(FracStats avgstat,
FracStats min,
ij.process.ImageProcessor ipk,
FracLac_2003AugustC.StoreAvgs avs,
boolean circ,
boolean issub,
java.lang.String suborglobal,
int thisiteration,
java.lang.String origins)
Writes the final values to the IJ window. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public int[] PixPerBox
public double[] AveragePix
public double[] StdDev
public int[][] HadPixAllLocAllSize
public double[] mprob
public java.awt.Rectangle rec
public int actualx
public int actualy
public int border
public float alpha
drawit method
.
public double maxAcross
public int newNumSizes
public int limit
public double[] colourarray
public int[] xarray
drawNewImage(ij.ImagePlus, int, int, int[], int[], double[])
public int[] yarray
drawNewImage(ij.ImagePlus, int, int, int[], int[], double[])
public java.lang.String sdir
openAndrun(boolean)
.
public java.lang.String sizestring
public java.lang.String countstring
public int foreground
ready(ij.process.ImageProcessor)
.
public ij.ImagePlus img
openAndrun(boolean)
.
getCircularityOfConvexHull(ij.process.ImageProcessor)
,
dosubs
public ij.process.ImageProcessor ip
openAndrun(boolean)
.
getCircularityOfConvexHull(ij.process.ImageProcessor)
,
dosubs
public ij.gui.ImageWindow win
openAndrun(boolean)
.
public int numlocations
getInputs()
.
public int incs
getInputs()
. Default is 500.
public int subboxsize
getInputs()
.
public boolean viewplots
getInputs()
.
public double maxpercent
getInputs()
.
public boolean dosubs
getInputs()
.
public boolean dosomethreshes
getInputs()
.
public int subsamples
getInputs()
.
public java.lang.String printsummary
getInputs()
.
public int docircul
getInputs()
.
public boolean fill
getInputs()
.
public boolean randomsquares
getInputs()
.
public boolean showcolours
getInputs()
.
public boolean userNumber
getInputs()
.
public boolean doglobal
getInputs()
.
public double perimeter
public double AREA
public double circularity
public double roundness
public double centrex
public double centrey
public double vDiameter
Constructor Detail |
public FracLac_2003AugustC()
Method Detail |
public void run(java.lang.String arg)
getInputs
method.
If this returns true, initializes
column headings for IJ results window
and calls openAndrun(boolean)
method, which
depends on the value in randomsquares
. Otherwise terminates.
Calls IJ.register on this class.
run
in interface ij.plugin.PlugIn
arg
- string not yet usedpublic void getCircularityOfConvexHull(ij.process.ImageProcessor ip)
writeFinal
method.
Calls GetDimensions
method to find image coordinates,
then calls getPolygon
method to make an IJ polygon roi and
sets this as the current roi. Uses IJ analyzer and ResultsTable
to change variables for
roundness
, circularity
, area
,
and perimeter
.
circularity = (perimeter*perimeter)/area
If perimeter is 0 roundness = 0; otherwise roundness = 4.0*pi*(area/(perimeter*perimeter));
ip
- ImageProcessor of binary image to make convex hull forpublic void openAndrun(boolean DoRandomSquares)
img
variable for each opened image. Stores
file directory as sdir
. Calls ready method
and sets
win
to current image. Makes a new colourarray
,
xarray
, and yarray
for the image's data,
and when done closes win
if no colour-coding is being shown.
Calls runFL
on ip
if doglobal
is true,
and runSubs
if dosubs
is true.
DoRandomSquares
- boolean true to do random sample
instead of entire grid of subareaspublic void runSubs(boolean DoRandomSquares)
stdboxsizes
to make a series of sizes starting
at subboxsize
*2. If doing a random sample, resets
the roi to a random location once for each subsamples
,
otherwise covers the whole image using
rec
for the margins. In both cases, calls runFL(int, boolean, boolean, ij.process.ImageProcessor, int, int)
at each
starting origin over the image. Calls drawnewimage
if showcolours
is true.
DoRandomSquares
- boolean True does a random sample; false does the
entire imagepublic ij.process.ImageProcessor drawNewImage(ij.ImagePlus imp, int numShapes, int subboxsize, int[] x, int[] y, double[] colours)
drawit method
.
imp
- the ImagePlus to draw onnumShapes
- the number of squares to drawsubboxsize
- the size of each squarex
- array of integers for x coordinate of each squarey
- array of integers for y coordinate of each squarecolours
- array of doubles specifying colours
public void drawit(int w, int h, int numShapes, java.awt.Graphics2D g2, int s, int[] x, int[] y, double[] colours)
alpha
to determine transparency of coloured squares. Adds
a legend bar telling what each colour represents.
s
- integer for size of drawing squaresnumShapes
- the number of squares to drawx
- array of integers for x coordinate of each squarey
- array of integers for y coordinate of each squarecolours
- array of doubles specifying coloursw
- integer for width of imageh
- integer for height of imageg2
- Graphics2D on which to drawpublic ij.process.ImageProcessor ready(ij.process.ImageProcessor ip)
img
's current
title and reinitializes sizestring
and
countstring
before getting new stats on
img
. If the image is not binary and dosomethreshes
is true,
calls IJ's thresholding function. Gets stats again then
sets foreground
to 255 or 0, whichever is lesser
in the image.
Kills any lefover roi then sets
ip
to img's current processor. Calls
FindMargins(ij.process.ImageProcessor)
and resets newNumSizes
to
value returned by stdboxsizes(double)
using value in
maxAcross
. Resets border
to the
greater of 50 or half numlocations
.
Makes a new ImageProcessor by calling addborder(ij.process.ImageProcessor)
on ip
, then calls FindMargins(ij.process.ImageProcessor)
to reset
values.
ip
- ImageProcessor on which to act
public int[][] makerandset(int x, int y)
numlocations
X 2.
x
- integer for maximum xy
- integer for maximum y
public void runFL(int thisiteration, boolean circ, boolean issub, ij.process.ImageProcessor ipk, int x, int y)
thisiteration
- integer for the location currently being donecirc
- boolean true calculates convex hull parametersissub
- boolean true does local fractal dimensionsipk
- ImageProcessor ipk is analyzedx
- integer for x coordinate to start aty
- integer for y coordinate to start atpublic void finishdata(int thisiteration, java.lang.String origins, ij.process.ImageProcessor ipk, FracLac_2003AugustC.StoreAvgs avs, boolean circ, boolean issub, java.lang.String suborglobal)
writeFinal(FracStats, FracStats, ij.process.ImageProcessor, FracLac_2003AugustC.StoreAvgs, boolean, boolean, java.lang.String, int, java.lang.String)
method to finish writing data.
Calls internal logplotter function if appropriate
to view regression line plots.
thisiteration
- integer for keeping track of scansorigins
- String of x and y where grid startedipk
- ImageProcessor on which to workavs
- StoreAvgs instancecirc
- boolean true means do convex hull statsissub
- boolean true means this is a subareasuborglobal
- string for denoting subarea of globalpublic int[] findMinCover(int[][] TestArray, int numLocs, int numBoxes)
TestArray
- integer array of arraysnumLocs
- integer for number of arrays to usenumBoxes
- integer for number of values in arrays to use
public double writeFinal(FracStats avgstat, FracStats min, ij.process.ImageProcessor ipk, FracLac_2003AugustC.StoreAvgs avs, boolean circ, boolean issub, java.lang.String suborglobal, int thisiteration, java.lang.String origins)
avgstat
- FracStats instance holding all original datamin
- Fracstats instance holding all data for minimum coveripk
- ImageProcessor on which to workavs
- StoreAvgs instance holding average valuescirc
- boolean true includes circularity and other convex hull dataissub
- boolean true includes subarea datasuborglobal
- string specifies data typethisiteration
- int for subareas or globalorigins
- String of x and y coordinates
public ij.process.ImageProcessor expandImage(ij.process.ImageProcessor ipOld, double wNew, double hNew, double xOff, double yOff)
ipOld
- THe ImageProcessor to act onwNew
- double for new widthhNew
- double for new heightxOff
- double for offset from x coordinateyOff
- double for offset from y coordinate
public void savecolour(double dddf, int iter)
colourarray
to use at each square for which a local
dimension was calculated. Uses previously stored values
in actualx
and
actualy
to change xarray
and yarray
.
dddf
- double for the fractal dimensioniter
- integer for the number in the listpublic int stdboxsizes(double Across)
limit
is first set to
a percentage
of
the passed value. The minimum is 15 boxes. If the user wants to
choose the number of boxes (if userNumber
is true),
number of boxes is set to the lesser of limit
or
the number the user set in the setup
. The increment
between box sizes is set as limit
divided by number of boxes.
Also reinitializes arrays: AveragePix, StdDev, problac, MeanOfProbDistributionAtEpsilon, and StdDevOfProbDistributionAtEpsilon.
Across
- double for distance across image
public boolean FindMargins(ij.process.ImageProcessor ip)
foreground
to search for pixels of that colour.
ip
- ImageProcessor to work on
public ij.process.ImageProcessor addborder(ij.process.ImageProcessor ip)
border
.
Calls expandImage
to do the work.
ip
- ImageProcessor
public double count(boolean asub, int boxnumber, int sze, ij.process.ImageProcessor ip, int x, int y)
method
.
In doing this, changes global variable for boxes and global arrays
for number of pixels and density. Is called by method
.
Changes x and y for main, not sub, checks, for placing
the starting grad at
systematic multiple origins around the start. For subs,
makes the area to check into
a smaller rectangle but for mains just leaves the area
to check as the whole image.
asub
- boolean true if doing subareasboxnumber
- integer for keeping tracksze
- integer for size of boxip
- ImageProcessor to work onx
- integer for starting x coordinatey
- integer for starting y coordinate
public java.lang.String fnum(double sum, int decimals)
sum
- number to formatdecimals
- number of decimal places
public double[] probmass(int epsilon)
epsilon
- integer for the box size; is only used to store final value
public void doBoxCounts(boolean wassub, ij.process.ImageProcessor ipc, int x, int y)
method
for each size.
Calls method
also. Sums values stored by
these calls in PixPerBox
array and stores average and standard deviation of pixels per box
in StdDev
and AveragePix
arrays. Finally,
stores the number of boxes that had pixels at this location in a
global storage array (HadPixAllLocAllSize
).
Will be rewritten to use FracStats class only.
wassub
- boolean true if this was a subareaipc
- ImageProcessor to work onx
- integer for starting x coordinatey
- integer for startign y coordinatepublic ij.gui.PolygonRoi getPolygon(ij.process.ImageProcessor ip)
written by Thomas Roy, University of Alberta, Canada
ip
- ImageProcessor to work on
public void GetDimensions(ij.process.ImageProcessor ip)
img
to current window;
sets width and height as well as left, right, top,
bottom, centrex, and centrey values.
ip
- ImageProcessor to work onpublic boolean getInputs()
run(java.lang.String)
when plugin is
first invoked.
dosomethreshes
,
incs
,
userNumber
,
maxpercent
,
numlocations
,
doglobal
,
printsummary
,
dosubs
,
fill
,
randomsquares
,
dosubs
,
subboxsize
,
viewplots
,
subsamples
,
docircul
public java.lang.String makeheadings()
public int moveGridalloverCountPixels(int boxnum, int xstart, int ystart, int sz, int bot, int rt, ij.process.ImageProcessor ipr)
PixPerBox
array
then goes over part of the ip using
a series of smaller boxes recording number of pixels in
each box and number of boxes that had pixels. Is called by
method
. Changes variables for actualx and
actualy each time.
ystart
- integer for y coordinate to start atsz
- integer for size of boxbot
- integer for bottom edge limitrt
- integer for right edge limitboxnum
- integer for later implementation of grid densityxstart
- integer for starting x coordinateipr
- ImageProcessor to analyze
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |