Class ErodingSkeleton

java.lang.Object
net.algart.arrays.AbstractIterativeArrayProcessor<Matrix<? extends UpdatableBitArray>>
net.algart.matrices.skeletons.ErodingSkeleton
All Implemented Interfaces:
ArrayProcessor, IterativeArrayProcessor<Matrix<? extends UpdatableBitArray>>

public class ErodingSkeleton extends AbstractIterativeArrayProcessor<Matrix<? extends UpdatableBitArray>> implements IterativeArrayProcessor<Matrix<? extends UpdatableBitArray>>

The simplest algorithm of multidimensional skeletonization of binary matrices, based on sequential erosions of the matrix by some small pattern.

More precisely, this class is an implementation of IterativeArrayProcessor interface, iteratively processing some bit matrix (Matrix(UpdatableBitArray)), named result and passed to the getInstance method. In this implementation:

  • performIteration(ArrayContext) method calculates erosion(result,P) of the current result matrix by some small pattern P (usually little circle or square, in 2-dimensional case) and opening(result,Q,Morphology.SubtractionMode.NONE) of this matrix by some other pattern Q, usually equal to P or little greater than P. The opening is subtracted (in the set-theoretical sense) from the source result matrix and the difference (i.e. "thin" areas in the bit image) is united with the erosion (also in the set-theoretical sense). Then the result matrix is replaced with this union.
  • done() method returns true if the last iteration was unable to change the matrix: all "objects" are already "thin" (removed after the erosion).
  • result() method always returns the reference to the source matrix, passed to getInstance method.

The algorithm, implemented by this class, does not guarantee that connected "objects" (areas filled by 1 elements) stay connected and does not guarantee that the resulting "skeleton" will be "thin" enough. But it guarantees that resulting "skeleton" does not contain areas "larger" than the pattern Q used for opening operation.

This class is based on Matrices.asShifted method with some elementwise logical operations (AND, OR, NOT). So, the matrix is supposed to be infinitely pseudo-cyclically continued, as well Matrices.asShifted method supposes it. You can change this behavior by appending the source matrix with zero elements by calling Matrix.subMatrix(long[], long[], Matrix.ContinuationMode) method, where the dimensions of the "submatrix" are greater than dimensions of the source one by 1 and the continuationMode argument is Matrix.ContinuationMode.ZERO_CONSTANT.

This class can process a matrix with any number of dimensions.

This class is not thread-safe, but is thread-compatible and can be synchronized manually, if multithread access is necessary.

Author:
Daniel Alievsky