vnt

Class Endpoint_Prune

Implemented Interfaces:
PlugInFilter

public class Endpoint_Prune
extends VascularNetworkToolkit
implements PlugInFilter

Plug-in for ImageJ that takes a grayscale distance map skeleton image and generates a pruned skeleton.

The pruning removes all endpoints shorter than a particular length. Due to the need to accomodate multiple zoom factors, this length is NOT hard coded.

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

Field Summary

private int[][]
backupPixel
A copy of the pixel[][] array that remembers before traversals.
private boolean
pruneIsolated
If true, isolated objects will be pruned.
private int
pruneLength
The longest length in which pruning will occur.

Method Summary

private boolean
createBackup()
Copies the pixel[][] array onto the backupPixel[][] array.
void
drawPrunedImage()
Draws the pruned skeleton onto a newly created image.
boolean
generatePruning()
Computes the pruned skeleton onto a newly created image.
private boolean
restoreBackup()
Restores the pixel[][] array from the copied backupPixel[][] array.
void
run(ImageProcessor bp)
Receives a grayscale image (specifically a thinned distance map skeletonization) and computes lengths of endpoints.
int
setMaxLengthToPrune(int length)
Sets the longest length of endpoint segments which will be pruned.
void
setPruneIsolated(boolean prune)
This param is a toggle on whether or not an endpoint segment should be deleted that isolated (degree 0, a component by itself).
int
setup(String arg, ImagePlus ip)
Specifies the preconditions for the plug-in.

Field Details

backupPixel

private int[][] backupPixel
A copy of the pixel[][] array that remembers before traversals.

pruneIsolated

private boolean pruneIsolated
If true, isolated objects will be pruned. This should generally be false (inhibited networks will be largely isolated structures).

pruneLength

private int pruneLength
The longest length in which pruning will occur. Any length longer will not be pruned.

Method Details

createBackup

private boolean createBackup()
Copies the pixel[][] array onto the backupPixel[][] array.
Returns:
Returns true if there were no problems. Returns false if no copying was performed. Pre: Assumes both arrays exist and are of identical size. Assumes the width and height variables are initialized properly.
Post: backupPixel[][] is overwritten by pixel[][].

drawPrunedImage

public void drawPrunedImage()
Draws the pruned skeleton onto a newly created image. Pre: The pruning operation has already been performed. The pixel data is loaded with the pruned, thinned distance map skeletonization.
Post: A new image is created and displayed.

generatePruning

public boolean generatePruning()
Computes the pruned skeleton onto a newly created image. (Ideally this method is meant to be called repeatedly until it returns true.) Pre: The pixel data is loaded with the pruned, thinned distance map skeletonization.
Post: A pruning is performed on the data in the pixel[] memory based on the pruneLength and pruneIsolated options.
Returns:
Returns false if any modifications were made to the data. When no further pruning is performed, the method returns true.

restoreBackup

private boolean restoreBackup()
Restores the pixel[][] array from the copied backupPixel[][] array.
Returns:
Returns true if there were no problems. Returns false if no copying was performed. Pre: Assumes both arrays exist and are of identical size. Assumes the width and height variables are initialized properly.
Post: pixel[][] is restored from the previously copied backupPixel[][].

run

public void run(ImageProcessor bp)
Receives a grayscale image (specifically a thinned distance map skeletonization) and computes lengths of endpoints. 1) Parses the image for possible node locations. 2) Identifies endpoints (node and their connected edge). 3) Estimates the total length. 4) Removes the end segment if the total length is less than or equal to a particular amount. Note: An additional parameter decides if isolated points should be deleted. Pre: The image was cleared to run by the setup() method.
Post: The image is processed by the distance map and ridge tracing routines. A new distance map skeleton image is drawn.
Parameters:
bp - Required by the interface. The access information to the original image.

setMaxLengthToPrune

public int setMaxLengthToPrune(int length)
Sets the longest length of endpoint segments which will be pruned. Pre: This should be set before pruning is requested.
Post: If no error occurs, the new prune length is set.
Parameters:
length - The desired maximal length of endpoint segments that will be pruned. All lengths equal to or less than this value will be pruned. Negative values are ignored and return an error.
Returns:
Returns -1 on error. Otherwise returns the new prune length.

setPruneIsolated

public void setPruneIsolated(boolean prune)
This param is a toggle on whether or not an endpoint segment should be deleted that isolated (degree 0, a component by itself). Pre: This should be set before pruning is requested.
Post: The toggle is set based on the given input.
Parameters:
prune - If true, then isolated components will be deleted. When false, isolated components will be preserved.

setup

public int setup(String arg,
                 ImagePlus ip)
Specifies the preconditions for the plug-in. If this method succeeds then run() is called. Pre: ImageJ is running and an 8-bit grayscale image is open. The plug-in was just activated.
Post: Either an argument was processed, the image was not saved to a local folder, or the plug-in is cleared to run on the image.
Parameters:
arg - Required by the interface. The argument list passed to the plug-in.
Returns:
If DONE is returned, ImageJ quits without run()'ing the plug-in. Otherwise, the plug-in signals to ImageJ that this plugin only handles 8-bit (256 grayscale) and will not change the original image.