public class TagTreeEncoder extends Object
The tag tree saves encoded information to a BitOutputBuffer.
A particular and useful property of tag trees is that it is possible to change a value of the matrix, provided both new and old values of the element are both greater than or equal to the largest threshold which has yet been supplied to the coding procedure 'encode()'. This property can be exploited through the 'setValue()' method.
This class allows saving the state of the tree at any point and restoring it at a later time, by calling save() and restore().
A tag tree can also be reused, or restarted, if one of the reset() methods is called.
The TagTreeDecoder class implements the tag tree decoder.
Tag trees that have one dimension, or both, as 0 are allowed for convenience. Of course no values can be set or coded in such cases.
BitOutputBuffer
,
TagTreeDecoder
Modifier and Type | Field and Description |
---|---|
protected int |
h
The vertical dimensions of the base level
|
protected int |
lvls
The number of levels in the tag tree
|
protected boolean |
saved
The saved state.
|
protected int[][] |
treeS
The tag tree state.
|
protected int[][] |
treeSbak
The saved tag tree state.
|
protected int[][] |
treeV
The tag tree values.
|
protected int[][] |
treeVbak
The saved tag tree values.
|
protected int |
w
The horizontal dimension of the base level
|
Constructor and Description |
---|
TagTreeEncoder(int h,
int w)
Creates a tag tree encoder with 'w' elements along the
horizontal dimension and 'h' elements along the vertical
direction.
|
TagTreeEncoder(int h,
int w,
int[] val)
Creates a tag tree encoder with 'w' elements along the
horizontal dimension and 'h' elements along the vertical
direction.
|
Modifier and Type | Method and Description |
---|---|
void |
encode(int m,
int n,
int t,
BitOutputBuffer out)
Encodes information for the specified element of the tree,
given the threshold and sends it to the 'out' stream.
|
int |
getHeight()
Returns the number of leafs along the vertical direction.
|
int |
getWidth()
Returns the number of leafs along the horizontal direction.
|
private void |
init(int w,
int h)
Initializes the variables of this class, given the dimensions
at the base level (leaf level).
|
private void |
recalcTreeV()
Recalculates the values of the elements in the tag tree, in
levels 1 and up, based on the values of the leafs (level 0).
|
void |
reset()
Resets the tree values and state.
|
void |
reset(int[] val)
Resets the tree values and state.
|
void |
restore()
Restores the saved values and state of the tree.
|
void |
save()
Saves the current values and state of the tree.
|
void |
setValue(int m,
int n,
int v)
Changes the value of a leaf in the tag tree.
|
void |
setValues(int[] val)
Sets the values of the leafs to the new set of values and
updates the tag tree accordingly.
|
protected int w
protected int h
protected int lvls
protected int[][] treeV
protected int[][] treeS
protected int[][] treeVbak
protected int[][] treeSbak
protected boolean saved
public TagTreeEncoder(int h, int w)
The values of all elements are initialized to Integer.MAX_VALUE.
h
- The number of elements along the horizontal direction.w
- The number of elements along the vertical direction.public TagTreeEncoder(int h, int w, int[] val)
The values in the 'val' array are supposed to appear in lexicographical order, starting at index 0.
h
- The number of elements along the horizontal direction.w
- The number of elements along the vertical direction.val
- The values with which initialize the leafs of the
tag tree.public final int getWidth()
public final int getHeight()
private void init(int w, int h)
w
- The number of elements along the vertical direction.h
- The number of elements along the horizontal direction.private void recalcTreeV()
public void setValue(int m, int n, int v)
m
- The vertical index of the element.n
- The horizontal index of the element.v
- The new value of the element.public void setValues(int[] val)
This method is more efficient than the setValue() method if a large proportion of the leafs change their value. Note that for leafs which don't have their value defined yet the value should be Integer.MAX_VALUE (which is the default initialization value).
val
- The new values for the leafs, in lexicographical order.setValue(int, int, int)
public void encode(int m, int n, int t, BitOutputBuffer out)
m
- The vertical index of the element.n
- The horizontal index of the element.t
- The threshold to use for encoding. It must be non-negative.out
- The stream where to write the coded information.public void save()
restore()
public void restore()
save()
public void reset()
public void reset(int[] val)
val
- The new values for the leafs, in lexicographical order.Copyright © 2017 Open Microscopy Environment