vnt

Class VascularNetworkToolkit


(package private) class VascularNetworkToolkit
extends java.lang.Object

Holds a variety of commonly used methods for all plug-ins under this toolkit for ImageJ.

This class is meant to assist in the development of related plug-ins for the toolkit. Modification of this class will affect (and possibly break) all other plug-ins in the package.

Version:
1.0
Author:
Michael Miller - Truman State University
Since:
1.0

Field Summary

static int
BLACK
The integer value ImageJ associates with the color black.
static int
BLUE
The integer ARGB color value ImageJ associates with the color BLUE.
static int
CYAN
The integer ARGB color value ImageJ associates with the color CYAN.
static int
DARK
The a descriptive constant value that should be set to the same value as BLACK.
static int
GRAY
The integer value ImageJ associates with the middle grayscale color value gray.
static int
GREEN
The integer ARGB color value ImageJ associates with the color GREEN.
static int
LIGHT
The a descriptive constant value that should be set to the same value as WHITE.
static int
MAGENTA
The integer ARGB color value ImageJ associates with the color MAGENTA.
static int
MATCHING
The descriptive constant value that should be set to the same value as GRAY.
static int
RED
The integer ARGB color value ImageJ associates with the color RED.
static int
WALL
The a descriptive constant value that should be set to the same value as BLACK.
static int
WHITE
The integer value ImageJ associates with the color white.
static int
YELLOW
The integer ARGB color value ImageJ associates with the color YELLOW.
protected boolean
animatedDisplay
A toggle to draw and update renderings live while generating them.
protected String
directory
The folder information for the original image given to the plug-in.
protected boolean
displayDebugText
A toggle whether to display debug text to the console or not.
protected double
distanceInPixels
Used for calibration information.
protected double
distanceInUnits
Used for calibration information.
protected double
distanceInUnitsPerPixel
The units per pixel: distanceInUnits / distanceInPixels.
protected String
distanceUnitName
Used for calibration information.
protected boolean
generateEyeCandyWithOriginalImage
A toggle whether to include the original image in the eyecandy presentation image or not.
protected boolean
generateLightingCorrectionSurfaceEyeCandy
A toggle whether to include the lighting correction surface in the eye candy.
protected int
height
The dimensional information for the original image given to the plug-in.
protected double
imageAspectRatio
Used for calibration information.
protected Calibration
imageCalibration
The calibation information for the image.
protected ImagePlus
imp
The ImagePlus for the image.
protected boolean
keepGraphTextFiles
A toggle whether to keep graph text files (true) or delete them (false).
protected boolean
keepTemporaryImageFiles
A toggle whether to keep temporary image files (true) or delete them (false).
protected int
lightingCorrectionCutoff
Assuming lighting correction will be performed, this is the largest color value which will be treated as equal to black.
protected int
lightingCorrectionPolynomialOrder
Assuming lighting correction will be performed, this is the order of the polynomial that the lighting correction surface will be fitted to it.
protected int
maximumAreaToIgnoreMesh
If Find Edges/Variances segmentation is being used, then usually an image will contain holes.
protected String
name
The full title filename of the image given to the plug-in.
protected String
originalName
The filename of the original image for processing.
protected boolean
performEyeCandy
A toggle whether to perform the final "eye candy" process (true) or to skip it (false).
protected boolean
performPolynomialLightingCorrection
A toggle whether to perform the initial lighting correction process (true) or to skip it (false).
protected int[][]
pixel
A two-dimensional integer array storing the 8-bit grayscale pixel values of the image.
protected boolean
useHighLowSegmentation
A toggle whether to use High/Low Segmentation or to use Find Edges/Variance segmentation.
protected int
width
The dimensional information for the original image given to the plug-in.

Method Summary

static int[][]
LoadImage(ImageProcessor ip)
Receives an ImageProcessor for an image and returns the image in the form of a two dimensional integer array.
static int[][]
LoadImage(ImageProcessor ip, int[][] data, int xLeft, int xRight, int yTop, int yBottom)
A partial version of LoadImage(ImageProcessor).
static int
averageARGBcolor(int colorA, int colorB)
Breaks the given ARGB colors into four seperate channels and averages each channel, and returns the recombination of the average.
static double
convertPercentage(int amount, int total)
Linearly converts a given amount into a fractional total.
int
dark24Neighbors(Coordinate location)
Checks the 24-neighbors of the given pixel for colors darking than it.
int
dark8Neighbors(Coordinate location)
Checks the 8-neighbors of the given pixel for colors matching it or darker.
static void
drawCircle(ImageProcessor ip, int x, int y, int radius, int color)
Draws an outline of a circle on the image.
static void
drawCircle(ImageProcessor ip, int x, int y, int radius, int red, int green, int blue)
Draws an outline of a circle on the image.
static void
drawLine(ImageProcessor ip, int x1, int y1, int x2, int y2, int color)
Draws a line on the image.
static void
drawLine(ImageProcessor ip, int x1, int y1, int x2, int y2, int red, int green, int blue)
Draws a line on the image.
int
get5x5Components(int type, Coordinate location)
Looks at the 5x5 area centered on the given pixel.
int
get7x7Components(int type, Coordinate location)
Looks at the 7x7 area centered on the given pixel.
static int
getAlphaChannel(int color)
Extracts and returns the alpha transparency channel from a 4 byte ARGB color.
static int
getBlueChannel(int color)
Extracts and returns the blue color channel from a 4 byte ARGB color.
int
getColor(Coordinate location, int direction)
Returns the color of an 8-neighbor to the given coordinate pixel.
int
getColor(int x, int y)
Grabs the grayscale color of the pixel requested from the local member pixel array.
Coordinate
getDarkestPixel()
Searches the pixel[][] array for the darkest (smallest) non-BLACK (assumed 0) color.
void
getDimensions(ImageProcessor ip)
Gets the width and heigh information of the given image.
boolean
getFileInformation(ImagePlus imageplus)
Initializes the plug-in by storing it's imageplus information.
static int
getGreenChannel(int color)
Extracts and returns the green color channel from a 4 byte ARGB color.
int
getLightComponents(Coordinate location)
Looks at the 8-neighborhood of a pixel.
private boolean
getLocalSettings(String folder)
Attempts to load the local settings information from the text file 'settings.txt' in the given folder.
static int
getRedChannel(int color)
Extracts and returns the red color channel from a 4 byte ARGB color.
int
getWhiteComponents(Coordinate location)
Looks at the 8-neighborhood of a pixel.
boolean
isNeighborBranchingPoint(Coordinate location)
Looks at the 8-neighbors of a pixel.
int
light24Neighbors(Coordinate location)
Checks the 24-neighbors of the given pixel for colors lighter than it.
int
light8Neighbors(Coordinate location)
Checks the 8-neighbors of the given pixel for colors lighter than it.
int
matching24Neighbors(Coordinate location)
Checks the 24-neighbors of the given pixel for colors matching it.
int
matching8Neighborhood4Squares(Coordinate location)
Checks the 8-neighbors of the given pixel for colors numerically equal to it.
int
matching8Neighbors(Coordinate location)
Checks the 8-neighbors of the given pixel for colors numerically equal to it.
int
max8NeighborhoodDelta(Coordinate location)
Checks the 8-neighbors of the given pixel for colors numerically different from it.
static int
mergeARGBChannels(int alpha, int red, int green, int blue)
Merges the given four channels.
boolean
saveFile(String prefix)
Saves the currently active window.
protected boolean
setCalibrationInformation(double pixels, double units, double aspectRatio, String unitName)
Sets the calibration information from the given data.
void
setColor(int x, int y, int color)
Sets the grayscale color of the specified pixel.
void
showAbout(String title, String content)
Displays information about the plug-in through ImageJ Plug-in's "About" display.
int
skeletalNeighbors(int centerX, int centerY)
Checks the 8-neighbors of the given pixel for colors not matching WHITE (!=255).

Field Details

BLACK

public static int BLACK
The integer value ImageJ associates with the color black.

BLUE

public static int BLUE
The integer ARGB color value ImageJ associates with the color BLUE. Format is hexadecimal 0xWWXXYYZZ where WW is the one byte hex alpha channel, XX is the one byte hex red channel, YY is the one byte hex green channel, and ZZ is the one byte hex blue channel.

CYAN

public static int CYAN
The integer ARGB color value ImageJ associates with the color CYAN. Format is hexadecimal 0xWWXXYYZZ where WW is the one byte hex alpha channel, XX is the one byte hex red channel, YY is the one byte hex green channel, and ZZ is the one byte hex blue channel.

DARK

public static int DARK
The a descriptive constant value that should be set to the same value as BLACK.

GRAY

public static int GRAY
The integer value ImageJ associates with the middle grayscale color value gray.

GREEN

public static int GREEN
The integer ARGB color value ImageJ associates with the color GREEN. Format is hexadecimal 0xWWXXYYZZ where WW is the one byte hex alpha channel, XX is the one byte hex red channel, YY is the one byte hex green channel, and ZZ is the one byte hex blue channel.

LIGHT

public static int LIGHT
The a descriptive constant value that should be set to the same value as WHITE.

MAGENTA

public static int MAGENTA
The integer ARGB color value ImageJ associates with the color MAGENTA. Format is hexadecimal 0xWWXXYYZZ where WW is the one byte hex alpha channel, XX is the one byte hex red channel, YY is the one byte hex green channel, and ZZ is the one byte hex blue channel.

MATCHING

public static int MATCHING
The descriptive constant value that should be set to the same value as GRAY.

RED

public static int RED
The integer ARGB color value ImageJ associates with the color RED. Format is hexadecimal 0xWWXXYYZZ where WW is the one byte hex alpha channel, XX is the one byte hex red channel, YY is the one byte hex green channel, and ZZ is the one byte hex blue channel.

WALL

public static int WALL
The a descriptive constant value that should be set to the same value as BLACK.

WHITE

public static int WHITE
The integer value ImageJ associates with the color white.

YELLOW

public static int YELLOW
The integer ARGB color value ImageJ associates with the color YELLOW. Format is hexadecimal 0xWWXXYYZZ where WW is the one byte hex alpha channel, XX is the one byte hex red channel, YY is the one byte hex green channel, and ZZ is the one byte hex blue channel.

animatedDisplay

protected boolean animatedDisplay
A toggle to draw and update renderings live while generating them. This generally creates an animated, more visually engaging display. Drastically slows down the processing time.

directory

protected String directory
The folder information for the original image given to the plug-in. Generally initialized by getFileInformation().

displayDebugText

protected boolean displayDebugText
A toggle whether to display debug text to the console or not.

distanceInPixels

protected double distanceInPixels
Used for calibration information. A measured distance in pixels.

distanceInUnits

protected double distanceInUnits
Used for calibration information. A measured distance in units.

distanceInUnitsPerPixel

protected double distanceInUnitsPerPixel
The units per pixel: distanceInUnits / distanceInPixels. Use this value when adjusting for real-world measurements.

distanceUnitName

protected String distanceUnitName
Used for calibration information. The real-world unit of measurement's string name.

generateEyeCandyWithOriginalImage

protected boolean generateEyeCandyWithOriginalImage
A toggle whether to include the original image in the eyecandy presentation image or not. The default value is true unless specified in a local settings.txt file.

generateLightingCorrectionSurfaceEyeCandy

protected boolean generateLightingCorrectionSurfaceEyeCandy
A toggle whether to include the lighting correction surface in the eye candy. This only occurs if lighting correction is performed and an eyecandy image is generated.

height

protected int height
The dimensional information for the original image given to the plug-in. Needed to be Generally initialized by getDimensions().

imageAspectRatio

protected double imageAspectRatio
Used for calibration information. The image's real-world aspect ratio. This is usually expressed as width divided by height or x:y.

imageCalibration

protected Calibration imageCalibration
The calibation information for the image. Holds pixels->real world units information. If the image already contains this information, it can be extracted from the ImagePlus. This is set once getFileInformation() is called. Priority is as follows: 1) If the existing image's calibration information exists, it is used. 2) ElseIf a global settings file exists, its calibration information is used. 3) Else imageCalibration is left null, and no special calibrations are saved.

imp

protected ImagePlus imp
The ImagePlus for the image. Holds, among other things, the filename and folder information. Generally initialized by getFileInformation().

keepGraphTextFiles

protected boolean keepGraphTextFiles
A toggle whether to keep graph text files (true) or delete them (false). The default value is true unless specified in a local settings.txt file.

keepTemporaryImageFiles

protected boolean keepTemporaryImageFiles
A toggle whether to keep temporary image files (true) or delete them (false). The default value is true unless specified in a local settings.txt file.

lightingCorrectionCutoff

protected int lightingCorrectionCutoff
Assuming lighting correction will be performed, this is the largest color value which will be treated as equal to black. The default value is -1. This means a variable cutoff will be calculated based off the histogram of the image (as specified in LightingCorrection.java). If a non-negative value is given, it is used as the maximum constant value associated with the color black.

lightingCorrectionPolynomialOrder

protected int lightingCorrectionPolynomialOrder
Assuming lighting correction will be performed, this is the order of the polynomial that the lighting correction surface will be fitted to it.

maximumAreaToIgnoreMesh

protected int maximumAreaToIgnoreMesh
If Find Edges/Variances segmentation is being used, then usually an image will contain holes. An algorithm has been created to close these artifacts up to a certain limit. Specify the maximum area of the holes to fill here.

name

protected String name
The full title filename of the image given to the plug-in. Generally initialized by getFileInformation().

originalName

protected String originalName
The filename of the original image for processing. Identifying prefixes are removed. Generally initialized by getFileInformation().

performEyeCandy

protected boolean performEyeCandy
A toggle whether to perform the final "eye candy" process (true) or to skip it (false). The default value is true unless specified in a local settings.txt file.

performPolynomialLightingCorrection

protected boolean performPolynomialLightingCorrection
A toggle whether to perform the initial lighting correction process (true) or to skip it (false). The default value is true unless specified in a local settings.txt file.

pixel

protected int[][] pixel
A two-dimensional integer array storing the 8-bit grayscale pixel values of the image. Expected values are between 0 and 255. A pixel is described by pixel[x][y] == color.

useHighLowSegmentation

protected boolean useHighLowSegmentation
A toggle whether to use High/Low Segmentation or to use Find Edges/Variance segmentation. The default value is true unless specified in local settings.txt file.

width

protected int width
The dimensional information for the original image given to the plug-in. Needed to be Generally initialized by getDimensions().

Method Details

LoadImage

public static int[][] LoadImage(ImageProcessor ip)
Receives an ImageProcessor for an image and returns the image in the form of a two dimensional integer array.

Pre: Accepts a valid ImageProcessor to an image given by ImageJ.
Post: The image is loaded into a double integer array. If the given ImageProcessor is null, the array is null.

Parameters:
ip - The ImageProcessor for the image to load.
Returns:
A new int [][] array that holds a copy of the image given.

LoadImage

public static int[][] LoadImage(ImageProcessor ip,
                                int[][] data,
                                int xLeft,
                                int xRight,
                                int yTop,
                                int yBottom)
A partial version of LoadImage(ImageProcessor). Receives a two dimensional integer array, an ImageProcessor for a valid ImageJ image, and rectangle boundary information, and returns the two dimensional integer array with the rectangular region replaced by the corresponding parts of the image.

Pre: Accepts a valid ImageProcessor to an image given by ImageJ. The array must be instantiated and the same size as the given image.
Post: The image within the boundaries is copied into a double integer array. If the given ImageProcessor is null, the array is null. If the given array is not the same dimensions as the image, the returned array is null.

Parameters:
ip - The ImageProcessor for the image to load. Contains the region which will be copied over the array.
data - The two dimensional integer array. (The existing picture.) Must be the same size as the given ImageProcessor. Null will also be returned if any of the given coordinates are out of bounds or malformed (left>right, etc.)
Returns:
A new int [][] array that holds a copy of the image given. Null if an error occured.

averageARGBcolor

public static int averageARGBcolor(int colorA,
                                   int colorB)
Breaks the given ARGB colors into four seperate channels and averages each channel, and returns the recombination of the average.

Pre: None.
Post: No changes to the outside class are made.

Parameters:
colorA - The first ARGB color.
colorB - The second ARGB color.
Returns:
The recombination of the averages of the four channels of the given colors.

convertPercentage

public static double convertPercentage(int amount,
                                       int total)
Linearly converts a given amount into a fractional total. Useful for coordinate transforms.

Pre: Assumes total != 0. If it is, this function returns 0.
Post: Returns amount/total.

Parameters:
amount - The amount to convert.
total - The total possible amount.
Returns:
Returns amount/total, meant for converting coordinates from very large values to basically a percentage% between [0,1].

dark24Neighbors

public int dark24Neighbors(Coordinate location)
Checks the 24-neighbors of the given pixel for colors darking than it.

Pre: Requires the local member pixel array to be properly loaded with an image. The width and height dimension data must be initialized.
Post: No changes to the class outside this method are made.

Parameters:
location - A Coordinate class that holds an X, Y, and color position.
Returns:
Returns the number of 24-neighbors that are as dark or darker than the color of the given pixel.

dark8Neighbors

public int dark8Neighbors(Coordinate location)
Checks the 8-neighbors of the given pixel for colors matching it or darker.

Pre: Requires the local member pixel array to be properly loaded with an image. The width and height dimension data must be initialized.
Post: No changes to the class outside this method are made.

Parameters:
location - A Coordinate class that holds an X, Y, and color position.
Returns:
Returns the number of 8-neighbors that are as dark or darker than the color of the pixel.

drawCircle

public static void drawCircle(ImageProcessor ip,
                              int x,
                              int y,
                              int radius,
                              int color)
Draws an outline of a circle on the image. The circle is centered on coordinates (x,y), with radius. The color of the circle is specified as a single integer value.

Pre: Assumes a valid ImageProcessor from an image given from ImageJ is provided. Assumes the given color value is appropriate for the type of image.
Post: A circle centered at (x,y) with radius is drawn on the specified image.

Parameters:
ip - The image processor for the image on which to draw.
x - The x coordinate of the center of the circle.
y - The y coordinate of the center of the circle.
radius - The radius for the circle.
color - The integer color value for the circle.

drawCircle

public static void drawCircle(ImageProcessor ip,
                              int x,
                              int y,
                              int radius,
                              int red,
                              int green,
                              int blue)
Draws an outline of a circle on the image. The circle is centered on coordinates (x,y), with radius. The color of the circle is specified as a single integer value.

Pre: Assumes a valid ImageProcessor from an image given from ImageJ is provided. Assumes the given color value is appropriate for the type of image.
Post: A circle centered at (x,y) with radius is drawn on the specified image.

Parameters:
ip - The image processor for the image on which to draw.
x - The x coordinate of the center of the circle.
y - The y coordinate of the center of the circle.
radius - The radius for the circle.
red - The integer color value for the red channel. Must be between 0 and 255.
green - The integer color value for the green channel. Must be between 0 and 255.
blue - The integer color value for the blue channel. Must be between 0 and 255.

drawLine

public static void drawLine(ImageProcessor ip,
                            int x1,
                            int y1,
                            int x2,
                            int y2,
                            int color)
Draws a line on the image. The line is drawn from (x1,y1) to (x2,y2). The color specified for the line is a single integer value.

Pre: Assumes a valid ImageProcessor from an image given from ImageJ is provided. Assumes the integer color is correct for the given image.
Post: A line is drawn from (x1,y1) to (x2,y2) on the given image..

Parameters:
ip - The image processor for the image on which to draw.
x1 - The x coordinate of the first endpoint of the line.
y1 - The y coordinate of the first endpoint of the line.
x2 - The x coordinate of the second endpoint of the line.
y2 - The y coordinate of the second endpoint of the line.
color - The integer color value for the line.

drawLine

public static void drawLine(ImageProcessor ip,
                            int x1,
                            int y1,
                            int x2,
                            int y2,
                            int red,
                            int green,
                            int blue)
Draws a line on the image. The line is drawn from (x1,y1) to (x2,y2). The color specified for the line is supplied in red, green, and blue channels.

Pre: Assumes a valid ImageProcessor from an image given from ImageJ is provided. Assumes the integer color is correct for the given image.
Post: A line is drawn from (x1,y1) to (x2,y2) on the given image..

Parameters:
ip - The image processor for the image on which to draw.
x1 - The x coordinate of the first endpoint of the line.
y1 - The y coordinate of the first endpoint of the line.
x2 - The x coordinate of the second endpoint of the line.
y2 - The y coordinate of the second endpoint of the line.
red - The integer color value for the red channel. Must be between 0 and 255.
green - The integer color value for the green channel. Must be between 0 and 255.
blue - The integer color value for the blue channel. Must be between 0 and 255.

get5x5Components

public int get5x5Components(int type,
                            Coordinate location)
Looks at the 5x5 area centered on the given pixel. Finds the number of 4-connected components that are lighter/darker/matching the given pixel.

Pre: Requires the local member pixel array to be properly loaded with an image. The width and height dimension data must be initialized.
Post: No changes to the class outside this method are made.

Parameters:
type - Must be LIGHT, MATCHING, or DARK for lighter, equal, or strictly darker components. This changes what this method returns.
location - A Coordinate class that holds an X, Y, and color position.
Returns:
The number of relevant 4-connected components in the 5x5 area centerred at the given pixel. Returns -1 if the type given was invalid or if the preconditions were not satisfied.

get7x7Components

public int get7x7Components(int type,
                            Coordinate location)
Looks at the 7x7 area centered on the given pixel. Finds the number of 4-connected components that are lighter/darker/matching the given pixel.

Pre: Requires the local member pixel array to be properly loaded with an image. The width and height dimension data must be initialized.
Post: No changes to the class outside this method are made.

Parameters:
type - Must be LIGHT, MATCHING, or DARK for lighter, equal, or strictly darker components. This changes what this method returns.
location - A Coordinate class that holds an X, Y, and color position.
Returns:
The number of relevant 4-connected components in the 7x7 area centerred at the given pixel. Returns -1 if the type given was invalid or if the preconditions were not satisfied.

getAlphaChannel

public static int getAlphaChannel(int color)
Extracts and returns the alpha transparency channel from a 4 byte ARGB color.

Pre: None.
Post: The 1-byte transparency channel is returned.

Parameters:
color - The ARGB 4 byte color value.
Returns:
The 1-byte alpha channel is returned. The value will be [0, 255].

getBlueChannel

public static int getBlueChannel(int color)
Extracts and returns the blue color channel from a 4 byte ARGB color.

Pre: None.
Post: The 1-byte color channel is returned.

Parameters:
color - The ARGB 4 byte color value.
Returns:
The 1-byte blue color channel is returned. The value will be [0, 255].

getColor

public int getColor(Coordinate location,
                    int direction)
Returns the color of an 8-neighbor to the given coordinate pixel. The specified pixel is the coordinate data given with the direction modification. The direction corresponds to the 8 directions around a pixel. Please keep in mind the upper-left coordinate of the image is (0, 0) and the lower-right coordinate of the image is (width, height). The pixels .., p-8, p0, p8, etc. are all the same. (the right x+1 neighbor) The pixels .., p-7, p1, p9, etc. are all the same. (the upper-right x+1 y-1 neighbor) This continues in a counter-clockwise fashion. If the pixel coordinates are out of bounds, returns WHITE (255).

Pre: Requires the local member pixel array to be properly loaded with an image. The width and height dimension data must be initialized.
Post: No changes to the outside class are made.

Parameters:
location - The x and y coordinate of the center pixel.
direction - The 8-neighborhood direction of the target color pixel to return.
Returns:
Either the color of the pixel requested, or WHITE (255) if the bounds are invalid.

getColor

public int getColor(int x,
                    int y)
Grabs the grayscale color of the pixel requested from the local member pixel array. Has built in checks to make sure it is not out of bounds.

Pre: The given values are within bounds of the image. Requires that the pixel array is loaded with an image.
Post: No changes to the outside class are made.

Parameters:
x - The x coordinate of the requested pixel.
y - The y coordinate of the requested pixel.
Returns:
The color of the requested pixel if the coordinates given fall within the images boundaries. If the coordinates do not, WHITE is returned.

getDarkestPixel

public Coordinate getDarkestPixel()
Searches the pixel[][] array for the darkest (smallest) non-BLACK (assumed 0) color.

Pre: Assumes that the image is not all WHITE (255). Assumes BLACK is the numerically smallest color. Searches the local member pixel for the darkest pixel. Consequently the pixel array must be initialized appropriately. Width and height dimension information must also be specified.
Post: No changes to the outside class are made.

Returns:
A Coordinate class which contains the location and color of the darkest pixel in the image. Returns null if there was an error processing the image (width, height, or pixel[][] not setup appropriately).

getDimensions

public void getDimensions(ImageProcessor ip)
Gets the width and heigh information of the given image.

Pre: A valid ImageProcessor from an image given from ImageJ is provided.
Post: The width and height of the image are stored in local members.

Parameters:
ip - The ImageProcessor for the given image.

getFileInformation

public boolean getFileInformation(ImagePlus imageplus)
Initializes the plug-in by storing it's imageplus information. Attempts to access and store the given images filename and local directory information.

Pre: Assumes imageplus is not null. Expects this to be called directly from a properly run plug-in's setup() routine.
Post: The image data is parsed for filename and local directory information. If this was obtainable, the method returns true. Otherwise false.

Parameters:
imageplus - The ImagePlus object for the image given.
Returns:
Returns true if filename and directory were accessed properly. Returns false if there was any problem.

getGreenChannel

public static int getGreenChannel(int color)
Extracts and returns the green color channel from a 4 byte ARGB color.

Pre: None.
Post: The 1-byte color channel is returned.

Parameters:
color - The ARGB 4 byte color value.
Returns:
The 1-byte green color channel is returned. The value will be [0, 255].

getLightComponents

public int getLightComponents(Coordinate location)
Looks at the 8-neighborhood of a pixel. Finds the number of 4-connected components that are lighter than the given pixel. Suppose p is part of a \ ---p--- ridge. p3 and p7 will be darker or matching. This means (p0,p1,p2) and (p4,p5,p6) will be white 4-connected components. In this case the method will return 2. (sorry of this looks really weird with a different font) _____________ | p3 | p2 | p1 | |------|------|-----| | p4 | p | p0 | |------|------|-----| | p5 | p6 | p7 | ---------------------

Pre: Requires the local member pixel array to be properly loaded with an image. The width and height dimension data must be initialized.
Post: No changes to the class outside this method are made.

Parameters:
location - A Coordinate class that holds an X, Y, and color position.
Returns:
The number of 4-connected lighter components in the 8-neighborhood.

getLocalSettings

private boolean getLocalSettings(String folder)
Attempts to load the local settings information from the text file 'settings.txt' in the given folder.

Pre: This method should generally only be called from getFileInformation.
Post: If a settings file is found, the settings are loaded into the VNT (and any inherited plugins can use this information to act accordingly).

Parameters:
folder - The directory containing this image (and consequently the settings file for it).
Returns:
True on successful read, false on failure to read the file.

getRedChannel

public static int getRedChannel(int color)
Extracts and returns the red color channel from a 4 byte ARGB color.

Pre: None.
Post: The 1-byte color channel is returned.

Parameters:
color - The ARGB 4 byte color value.
Returns:
The 1-byte red color channel is returned. The value will be [0, 255].

getWhiteComponents

public int getWhiteComponents(Coordinate location)
Looks at the 8-neighborhood of a pixel. Finds the number of 4-connected components that are white. Suppose p is part of a forward-slash ---p--- ridge. Here p3 and p7 will be black. This means (p0,p1,p2) and (p4,p5,p6) will be white 4-connected components. In this case the method will return 2. (sorry of this looks really weird with a different font) _____________ | p3 | p2 | p1 | |------|------|-----| | p4 | p | p0 | |------|------|-----| | p5 | p6 | p7 | ---------------------

Pre: Requires the local member pixel array to be properly loaded with an image. The width and height dimension data must be initialized.
Post: No changes to the outside class are made.

Parameters:
location - A Coordinate class that holds an X, Y, and color position.
Returns:
The number of 4-connected lighter components in the 8-neighborhood.

isNeighborBranchingPoint

public boolean isNeighborBranchingPoint(Coordinate location)
Looks at the 8-neighbors of a pixel. Determines if any of these pixels are branching points (3 or more 4-connected white components).

Pre: Requires the local member pixel array to be properly loaded with an image. The width and height dimension data must be initialized.
Post: No changes to the class outside this method are made.

Parameters:
location - A Coordinate class that holds an X, Y, and color position.
Returns:
True if there is an 8-neighbor of the given pixel that is a branching point. False if there are none.

light24Neighbors

public int light24Neighbors(Coordinate location)
Checks the 24-neighbors of the given pixel for colors lighter than it.

Pre: Requires the local member pixel array to be properly loaded with an image. The width and height dimension data must be initialized.
Post: No changes to the class outside this method are made.

Parameters:
location - A Coordinate class that holds an X, Y, and color position.
Returns:
Returns the number of 24-neighbors that are lighter than the color of the given pixel.

light8Neighbors

public int light8Neighbors(Coordinate location)
Checks the 8-neighbors of the given pixel for colors lighter than it.

Pre: Requires the local member pixel array to be properly loaded with an image. The width and height dimension data must be initialized.
Post: No changes to the class outside this method are made.

Parameters:
location - A Coordinate class that holds an X, Y, and color position.
Returns:
Returns the number of 8-neighbors that are lighter than the color of the pixel.

matching24Neighbors

public int matching24Neighbors(Coordinate location)
Checks the 24-neighbors of the given pixel for colors matching it.

Pre: Requires the local member pixel array to be properly loaded with an image. The width and height dimension data must be initialized.
Post: No changes to the class outside this method are made.

Parameters:
location - A Coordinate class that holds an X, Y, and color position.
Returns:
Returns the number of 24-neighbors that are the same color as the given pixel.

matching8Neighborhood4Squares

public int matching8Neighborhood4Squares(Coordinate location)
Checks the 8-neighbors of the given pixel for colors numerically equal to it. Returns the number of corners which match the color. Example: ABC DEF GHI The count is incremented if E matches BCF, BAD, DGH, or HIF. If count is every gre

Pre: Requires the local member pixel array to be properly loaded with an image. The width and height dimension data must be initialized.
Post: No changes to the outside class are made.

Parameters:
location - A Coordinate class that holds an X, Y, and color position.
Returns:
Returns the number of 4-squares in the 8-neighborhood that match the color of the pixel.

matching8Neighbors

public int matching8Neighbors(Coordinate location)
Checks the 8-neighbors of the given pixel for colors numerically equal to it.

Pre: Requires the local member pixel array to be properly loaded with an image. The width and height dimension data must be initialized.
Post: No changes to the outside class are made.

Parameters:
location - A Coordinate class that holds an X, Y, and color position.
Returns:
Returns the number of 8-neighbors that match the color of the pixel.

max8NeighborhoodDelta

public int max8NeighborhoodDelta(Coordinate location)
Checks the 8-neighbors of the given pixel for colors numerically different from it. Returns the maximum difference.

Pre: Requires the local member pixel array to be properly loaded with an image. The width and height dimension data must be initialized.
Post: No changes to the outside class are made.

Parameters:
location - A Coordinate class that holds an X, Y, and color position.
Returns:
Returns the maximum color value difference in the 8-neighborhood.

mergeARGBChannels

public static int mergeARGBChannels(int alpha,
                                    int red,
                                    int green,
                                    int blue)
Merges the given four channels.

Pre: Assumes alpha, red, green, and blue are all [0, 255].
Post: Returns the channel combination: ARGB in one int.

Parameters:
alpha - The one byte [0, 255] alpha channel.
red - The one byte [0, 255] red channel.
green - The one byte [0, 255] green channel.
blue - The one byte [0, 255] blue channel.
Returns:
Returns the ARGB integer.

saveFile

public boolean saveFile(String prefix)
Saves the currently active window. An underscore ('_') is inserted between the prefix and the original filename.

Pre: Assumes the desired file to be saved is active. Assumes getFileInformation has already been called and completed successfully.
Post: The active window is saved with the folder, prefix, and original filename. The full path is directory_path+prefix+"_"+original_file_name.

Parameters:
prefix - The prefix to save before the beginning of the file. Examples include "lightcorrected" - "segmented" - "skeletonized" - "pruned".
Returns:
True on successful save. False if information was missing.

setCalibrationInformation

protected boolean setCalibrationInformation(double pixels,
                                            double units,
                                            double aspectRatio,
                                            String unitName)
Sets the calibration information from the given data. Note: Invalid input will result in the default calibration setting (ImageJ interprets this as no calibration information).

Pre: This method should generally only be called from getLocalSettings.
Post: On success, the variable imageCalibration will be filled with a new Calibration. On failure, imageCalibration will be unchanged.

Parameters:
pixels - The distance in pixels.
units - The same distance, but in # of units.
aspectRatio - The aspect ratio of real-world units. Negative values are automatically made positive. An aspect ratio of 0 is interpretted as 1.
unitName - The string containing the name of the unit. Ex: "cm", "microns" etc.
Returns:
True on success, false on failure. On true, imageCalibration should have a valid new Calibration.

setColor

public void setColor(int x,
                     int y,
                     int color)
Sets the grayscale color of the specified pixel. Allowable color values are in the range [0, 255]. If the pixel coordinates are out of bounds, no change is made.

Pre: Requires the local member pixel array to be properly loaded with an image. The width and height dimension data must be initialized.
Post: If no error is encountered, the target pixel is changed to the specified color.

Parameters:
x - The x-coordinate of the pixel specified for color change.
y - The y-coordinate of the pixel specified for color change.
color - The new color for the specified pixel.

showAbout

public void showAbout(String title,
                      String content)
Displays information about the plug-in through ImageJ Plug-in's "About" display.

Pre: None.
Post: No changes.

Parameters:
title - The title of the About display.
content - The message body of the About display.

skeletalNeighbors

public int skeletalNeighbors(int centerX,
                             int centerY)
Checks the 8-neighbors of the given pixel for colors not matching WHITE (!=255).

Pre: Requires the local member pixel array to be properly loaded with an image. The width and height dimension data must be initialized.
Post: No changes to the outside class are made.

Parameters:
centerX - The center x-coordinate whos neihbors need checked.
centerY - The center y-coordinate whos neihbors need checked.
Returns:
Returns the number of 8-neighbors that are non-white (!= 255).