vnt

Class DistanceMap_Skeleton

Implemented Interfaces:
PlugInFilter

public class DistanceMap_Skeleton
extends VascularNetworkToolkit
implements PlugInFilter

Uses ImageJ to generate a Distance Map for a segmented image. Attempts to trace the darkest ridges of the distance map, providing a closer approximation to the Blum Medial Axis Transform than the Binary -> Skeletonization method (a thinning algorithm) given by ImageJ.

The computed skeleton is not binary, it retains the distance map information along the skeleton. This is (in theory) a one-to-one invertible transform from the binary segmented image to the skeleton.

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

Method Summary

static double
calculateAngleDistance(double angleA, double angleB)
Calculates the distance between two radian angles.
ImageProcessor
generateBitangentSkeletonWithEDM(ImageProcessor dm)
Performs a search for the BMAT by testing for maximal radius bitangent circles that have no part outside of the object.
ImageProcessor
generateDistanceMap(ImageProcessor ip)
Copies the given image into a new image, and performs the distance map operation on the new image.
ImageProcessor
generateRidgeTrace(ImageProcessor dm)
Traces the ridges of a given distance map.
ImageProcessor
generateThinnedSkeleton(ImageProcessor rt)
Performs the Skeletonization (thinning) algorithm on the distance map ridge skeleton.
ImageProcessor
generateThinningSkeletonWithEDM(ImageProcessor dm)
Performs the thinning algorithm on the segmented image.
ImageProcessor
generateVoronoiSkeletonWithEDM(ImageProcessor dm, int searchMax)
Performs the fancy pants Voronoi/Delaunay algorithm stuff that Paul Chew, chew@cs.cornell.edu wrote.
void
run(ImageProcessor bp)
Receives a binary image and computes an approximation of the Blum Medial Axis Transform on it.
int
setup(String arg, ImagePlus ip)
Specifies the preconditions for the plug-in.

Method Details

calculateAngleDistance

public static double calculateAngleDistance(double angleA,
                                            double angleB)
Calculates the distance between two radian angles. Only slightly trickier than it sounds!

Pre: None.
Post: None. Static method, after all..

Parameters:
angleA - The first angle. Must be in radians.
angleB - The second angle. Must be in radians.
Returns:
Returns the radian distance between the two angles.

generateBitangentSkeletonWithEDM

public ImageProcessor generateBitangentSkeletonWithEDM(ImageProcessor dm)
Performs a search for the BMAT by testing for maximal radius bitangent circles that have no part outside of the object. The envelope of the centers of these circles is the ridge.

Pre: The dimensions width and height must have been loaded prior to calling this method. The given ImageProcessor must be for the EDM and must be valid.
Post: On success, a new image of the thinned distance map ridge trace is drawn. On failure, no change is made.

Parameters:
dm - The Image Processor is required for the EDM image data.
Returns:
The ImageProcessor for the newly created image representing the thinned distance map ridge trace.

generateDistanceMap

public ImageProcessor generateDistanceMap(ImageProcessor ip)
Copies the given image into a new image, and performs the distance map operation on the new image.

Pre: The dimensions width and height must have been loaded prior to calling this method. The given ImageProcessor must be for the original image and must be valid. It is assumed that the given image is binary.
Post: On success, a new image of the distance map of the original segmented image is drawn. Also, the local member pixel array is loaded with the original image. On failure, no change is made.

Parameters:
ip - The Image Processor is required for the original image data.
Returns:
The ImageProcessor for the newly created image representing the distance map of the original segmented image.

generateRidgeTrace

public ImageProcessor generateRidgeTrace(ImageProcessor dm)
Traces the ridges of a given distance map.

Pre: The dimensions width and height must have been loaded prior to calling this method. The given ImageProcessor must be for a distance map and must be valid.
Post: On success, a new image of the ridge trace of the distance map of the original segmented image is drawn. Also, the local member pixel array is loaded with the original image. On failure, no change is made.

Parameters:
dm - The Image Processor is required for the original image data.
Returns:
The ImageProcessor for the newly created image representing the ridge trace of the distance map of the original segmented image.

generateThinnedSkeleton

public ImageProcessor generateThinnedSkeleton(ImageProcessor rt)
Performs the Skeletonization (thinning) algorithm on the distance map ridge skeleton. Sometimes the distance map ridge can be two pixels wide instead of just 1 (imagine a circle with even pixel radius). Once we have the ridge, thinning will only shift the final solution by 0.5 pixels, so the thinned ridge is still topologically and quantitatively correct, within reasons of error due to the discretization process. 1) Converts the distance map ridge trace into binary. 2) Performs thinning on the binary image. 3) Uses the thinned binary image as a mask to create a final thinned skeleton.

Pre: The dimensions width and height must have been loaded prior to calling this method. The given ImageProcessor must be for the ridge skeleton and must be valid. In addition, the local member pixel array must be loaded with the distance map.
Post: On success, a new image of the thinned distance map ridge trace is drawn. On failure, no change is made.

Parameters:
rt - The Image Processor is required for the original image data.
Returns:
The ImageProcessor for the newly created image representing the thinned distance map ridge trace.

generateThinningSkeletonWithEDM

public ImageProcessor generateThinningSkeletonWithEDM(ImageProcessor dm)
Performs the thinning algorithm on the segmented image. The distance map information is used on the skeleton. This is a cheap hack way to get a 100% continuous skeleton that does not require any pruning, while preserving many of the advantages of the BMAT approach to the problem. 1) Converts the distance map into binary. 2) Performs thinning on the binary image. 3) Uses the thinned binary image as a mask over the EDM to create a final thinned skeleton that retains EDM information. (The skeleton itself is NOT a true BMAT.)

Pre: The dimensions width and height must have been loaded prior to calling this method. The given ImageProcessor must be for the ridge skeleton and must be valid. In addition, the local member pixel array must be loaded with the distance map.
Post: On success, a new image of the thinned distance map ridge trace is drawn. On failure, no change is made.

Parameters:
Returns:
The ImageProcessor for the newly created image representing the thinned distance map ridge trace.

generateVoronoiSkeletonWithEDM

public ImageProcessor generateVoronoiSkeletonWithEDM(ImageProcessor dm,
                                                     int searchMax)
Performs the fancy pants Voronoi/Delaunay algorithm stuff that Paul Chew, chew@cs.cornell.edu wrote. I got his code from http://www.cs.cornell.edu/Info/People/chew/Delaunay.html 1) Finds the edges of the distance map and inputs them into the Voronoi algorithm. 2) Draws the Voronoi region boundaries. 3) Uses the boundaries as a mask over the EDM to create a final thinned skeleton that retains EDM information. (The skeleton itself may NOT be a true BMAT.)

Pre: The dimensions width and height must have been loaded prior to calling this method. The given ImageProcessor must be for the ridge skeleton and must be valid. In addition, the local member pixel array must be loaded with the distance map.
Post: On success, a new image of the thinned distance map ridge trace is drawn. On failure, no change is made.

Parameters:
Returns:
The ImageProcessor for the newly created image representing the thinned distance map ridge trace.

run

public void run(ImageProcessor bp)
Receives a binary image and computes an approximation of the Blum Medial Axis Transform on it. 1) Performs distance map operation on the segementation image. 2) Trace the ridges of the distance map. 3) Generates a skeleton of the ridges of the distance map (which retain the color information from the distance map).

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.

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.