|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectio.loader.shared.SkeletonParser
io.loader.load2D.SkeletonParser2D
public class SkeletonParser2D
Given the path to a binary image containing the skeleton, and the path to a
binary image containing the object's shape, SkeletonParser2D creates
a SkeletonObject from this given input data.
Tested input image types are by now .png and .gif. Example usage:
SkeletonParser parser = new SkeletonParser ("/path/to/skeleton.png", "/path/to/object.png");
SkeletonObject object = parser.getSkeleton();
Warning: The assumption is we have unit pixels here.
| Field Summary | |
|---|---|
private java.util.List<java.awt.Point> |
allContourPoints
list containing all contour points (outer contours as well as inner contours |
private org.apache.log4j.Logger |
logger
logger instance |
private java.lang.String |
objectfilename
the path to the image containing the object shape |
private ij.ImagePlus |
objectImage
image containing the object shape |
private ij.io.Opener |
opener
imagej opener instance, offers more possibilites than ImageIO |
private java.lang.String |
skeletonfilename
the path to the image containing the skeleton |
private ij.ImagePlus |
skeletonImage
image containing the skeleton |
| Fields inherited from class io.loader.shared.SkeletonParser |
|---|
allEndnodes, allJunctionNodes, config, skeletonObject |
| Constructor Summary | |
|---|---|
SkeletonParser2D(java.lang.String skeletonfilename,
java.lang.String objectfilename)
Constructor. |
|
SkeletonParser2D(java.lang.String skeletonfilename,
java.lang.String objectfilename,
boolean flipped)
|
|
SkeletonParser2D(java.lang.String skeletonfilename,
java.lang.String objectfilename,
Config config)
|
|
SkeletonParser2D(java.lang.String skeletonfilename,
java.lang.String objectfilename,
Config config,
boolean flipped)
Constructor. |
|
| Method Summary | |
|---|---|
private SkeletonNode |
checkNeighborHood(java.awt.Point cp)
check if a skeleton end node is in the 3x3 neighbor hood of the specified contour point. |
private void |
cleanJunctionNodes(java.util.List<SkeletonNode> junctionnodes)
In some constellations, directly adjacent nodes are recognized as junction nodes. |
private void |
getContour()
set the object's inner and outer contours. |
protected void |
getCriticalNodes()
extract all critical nodes, that is, end nodes and junction nodes |
protected void |
getDistanceTransform()
compute and set the shape's distance transform |
private boolean |
isNeighborOf(java.awt.Point cp,
SkeletonNode n)
check if the specified skeleton node is in the 3x3 neighborhood of the specified contour point. |
private boolean |
isSkeleton(int argb)
check if the specified color code is encoding a skeleton node |
private void |
load(java.lang.String skeletonfilename,
java.lang.String objectfilename,
boolean flipped)
load the skeleton image and shape image, specified by the parameters. |
private void |
loadObjectImage(boolean flipped)
load the object image |
private void |
loadSkeletonImage(boolean flipped)
load the skeleton image |
private void |
prepareImage(ij.ImagePlus objectImage)
Prepare the image to make sure some conditions are fullfilled: all pixel values are 0 or 255 tell imagej that this is a binary image invert the image in case the foreground seems to be black, the background seems to be white (by now, this is estimated on the pixel in the upper left corner) |
protected java.util.Map<SkeletonNode,java.util.List<SkeletonBranch>> |
sampleParts()
sample all SkeletonBranches emanating from each critical node. |
private void |
setAllContourPoints()
extract all contour points from the object's contour and save them to a list. |
private void |
setSize()
set skeleton object's width and height, based on the input image's size. |
private void |
sortEndPoints()
sort a list of end nodes by traversing an object's contour in clockwise direction and checking for each contour point if there is a skeleton node in the 3x3 neighborhood. |
| Methods inherited from class io.loader.shared.SkeletonParser |
|---|
deleteUnconnectedComponents, deleteUnnecessaryBranches, extractPaths, getSkeleton, parse, preprocessGraph |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private java.util.List<java.awt.Point> allContourPoints
private final org.apache.log4j.Logger logger
private java.lang.String objectfilename
private ij.ImagePlus objectImage
private final ij.io.Opener opener
private java.lang.String skeletonfilename
private ij.ImagePlus skeletonImage
| Constructor Detail |
|---|
public SkeletonParser2D(java.lang.String skeletonfilename,
java.lang.String objectfilename)
throws java.io.IOException,
InvalidConfigParameterException
Both images should be binary images, with black background and white foreground.
skeletonfilename - the path to the binary image containing the skeletonobjectfilename - the path to the binary image containing the object.
java.io.IOException - if one of the images was not found.
InvalidConfigParameterException
public SkeletonParser2D(java.lang.String skeletonfilename,
java.lang.String objectfilename,
boolean flipped)
throws java.io.IOException,
InvalidConfigParameterException
java.io.IOException
InvalidConfigParameterException
public SkeletonParser2D(java.lang.String skeletonfilename,
java.lang.String objectfilename,
Config config)
throws java.io.IOException,
InvalidConfigParameterException
java.io.IOException
InvalidConfigParameterException
public SkeletonParser2D(java.lang.String skeletonfilename,
java.lang.String objectfilename,
Config config,
boolean flipped)
throws java.io.IOException
skeletonfilename - - the path to the binary image containing the skeletonobjectfilename - - the path to the binary image containing the object.flipped - - if true, both images will be flipped horizontally before the
skeleton is parsed
java.io.IOException - - if one if the images could not be found| Method Detail |
|---|
private void load(java.lang.String skeletonfilename,
java.lang.String objectfilename,
boolean flipped)
throws java.io.IOException
skeletonfilename - - path to skeleton imageobjectfilename - - path to object imageflipped - - true if the image has to be flipped, false if not
java.io.IOException - - if one of the files could not be foundprivate SkeletonNode checkNeighborHood(java.awt.Point cp)
cp - the contour point whose neighborhood will be search for
skeleton points
private void getContour()
protected void getDistanceTransform()
SkeletonParser
getDistanceTransform in class SkeletonParser
protected java.util.Map<SkeletonNode,java.util.List<SkeletonBranch>> sampleParts()
throws InvalidSkeletonException
SkeletonParserSkeletonBranches emanating from each critical node.
For each critical node, a list of all emanating parts is stored. The key
in the map is the critical node, the value is the list of all skeleton
branches emanating from the node that is the key.
sampleParts in class SkeletonParserInvalidSkeletonException
protected void getCriticalNodes()
throws InvalidSkeletonException
SkeletonParser
getCriticalNodes in class SkeletonParserInvalidSkeletonException
private void cleanJunctionNodes(java.util.List<SkeletonNode> junctionnodes)
throws InvalidSkeletonException
NodeArea"s
junctionnodes - - list of all found junction nodes (that is, nodes with more
than two neighbors)
InvalidSkeletonException - - if the skeleton seems to be broken
private boolean isNeighborOf(java.awt.Point cp,
SkeletonNode n)
cp - the contour pointn - the skeleton node
private boolean isSkeleton(int argb)
argb -
private void loadObjectImage(boolean flipped)
throws java.io.IOException
flipped -
java.io.IOException - if the image was not foundprivate void prepareImage(ij.ImagePlus objectImage)
objectImage - the image to be prepared
private void loadSkeletonImage(boolean flipped)
throws java.io.IOException
flipped - true if the image shall be flipped horizontally, false if not
java.io.IOException - if the image was not foundprivate void setAllContourPoints()
private void setSize()
private void sortEndPoints()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||