Class Ntree<T extends Comparable<T>>
java.lang.Object
net.imglib2.img.sparse.Ntree<T>
N-dimensional equivalent of a quad/oct-tree.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescription(package private) final long[]dimensions of tree(package private) final intnumber of dimensions.(package private) final inthow many children (if any) each node has.(package private) final intmaximum depth of the tree.(package private) Ntree.NtreeNode<T> Root of the tree -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate Ntree.NtreeNode<T> copyRecursively(Ntree.NtreeNode<T> node, Ntree.NtreeNode<T> newParent) helper method for the copy constructorNtree(Ntree)to create a deep copy of the tree.(package private) Ntree.NtreeNode<T> createNode(long[] position) Create a node containing only position (if it does not exist already).(package private) Ntree.NtreeNode<T> createNodeWithValue(long[] position, T value) Set the value at position and get the lowest-level node containing position.(package private) Ntree.NtreeNode<T> getNode(long[] position) Get the lowest-level node containing position.Returns the root node of the ntree(package private) Ntree.NtreeNode<T> mergeUpwards(Ntree.NtreeNode<T> node) If all the children of our parent have the same value remove them all.
-
Field Details
-
n
final int nnumber of dimensions. -
numTreeLevels
final int numTreeLevelsmaximum depth of the tree. -
numChildren
final int numChildrenhow many children (if any) each node has. -
root
Ntree.NtreeNode<T extends Comparable<T>> rootRoot of the tree -
dimensions
final long[] dimensionsdimensions of tree
-
-
Constructor Details
-
Ntree
Create a ntree structure capable of representing an array of the given dimensions. Initially, the tree contains only a root node and represents an array of uniform values.- Parameters:
dimensions- of the arrayvalue- uniform value of all pixels in the array
-
Ntree
-
-
Method Details
-
copyRecursively
helper method for the copy constructorNtree(Ntree)to create a deep copy of the tree. -
getNode
Get the lowest-level node containing position. Note that position is not necessarily the only pixel inside the node. So use this for read-access to pixel values only.- Parameters:
position- a position inside the image.- Returns:
- the lowest-level node containing position.
-
createNode
Create a node containing only position (if it does not exist already). This may insert nodes at several levels in the tree.- Parameters:
position- a position inside the image.- Returns:
- node containing exactly position.
-
createNodeWithValue
Set the value at position and get the lowest-level node containing position. Note that position is not necessarily the only pixel inside the node, if the value matches neighboring values. If necessary, new nodes will be created. If possible, nodes will be merged.- Parameters:
position- a position inside the image.value- value to store at position.- Returns:
- node containing position.
-
mergeUpwards
If all the children of our parent have the same value remove them all. Call recursively for parent.- Parameters:
node- the starting node (whose parents should be tested recursively).- Returns:
- node that the starting node was ultimately merged into.
-
getRootNode
-