Class IterateVoxelsAll

Object
IterateVoxelsAll

public class IterateVoxelsAll extends Object
Utilities for iterating over all voxels in one or more Voxels.

A processor is called on each voxel.

Author:
Owen Feehan
  • Method Details

    • withPoint

      public static void withPoint(Extent extent, ProcessPoint process)
      Iterate over each voxel in an Extent
      Parameters:
      extent - the extent to be iterated over
      process - process is called for each voxel inside the extent using the same coordinates as the extent.
    • withPointAndIndex

      public static void withPointAndIndex(Extent extent, ProcessPointAndIndex process)
      Iterate over each voxel in an Extent.
      Parameters:
      extent - the extent to be iterated over
      process - process is called for each voxel inside the extent using the same coordinates as the extent.
    • withCursor

      public static void withCursor(BinaryVoxels<UnsignedByteBuffer> voxels, KernelApplicationParameters parameters, ProcessKernelPointCursor process)
      Iterate over each voxel using a KernelPointCursor.
      Parameters:
      voxels - the voxels to iterator over
      parameters - to use when applying a kernel
      process - process is called for each voxel inside the extent using the same coordinates as the extent.
    • withBuffer

      public static <T> void withBuffer(Voxels<T> voxels, ProcessBufferUnary<T> process)
      Iterate over each voxel - with one associated buffer for each slice.
      Type Parameters:
      T - buffer-type for voxels
      Parameters:
      voxels - voxels to be iterated over (in their entirety)
      process - is called for each voxel within the bounding-box using global coordinates.
    • withTwoBuffersAndPoint

      public static <S, T> void withTwoBuffersAndPoint(Voxels<S> voxels1, Voxels<T> voxels2, ProcessBufferBinary<S,T> process)
      Iterate over each voxel - with two associated buffers for each slice

      The extent's of both voxels1 and voxels2 must be equal.

      Type Parameters:
      S - first buffer-type for voxels
      T - second buffer-type for voxels
      Parameters:
      voxels1 - first voxels provides the first buffer
      voxels2 - second voxels
      process - is called for each voxel using global coordinates.
    • withThreeBuffers

      public static <T> void withThreeBuffers(Voxels<T> voxels1, Voxels<T> voxels2, Voxels<T> voxels3, ProcessBufferTernary<T> process)
      Iterate over each voxel - with three associated buffers for each slice.

      The extent's of both voxels1 and voxels2 and voxels3 must be equal.

      Type Parameters:
      T - buffer-type for voxels
      Parameters:
      voxels1 - voxels in which which BoundingBox refers to a subregion, and which provides the first buffer
      voxels2 - voxels in which which BoundingBox refers to a subregion, and which provides the second buffer
      voxels3 - voxels in which which BoundingBox refers to a subregion, and which provides the third buffer
      process - is called for each voxel within the bounding-box using global coordinates.
    • withVoxelBuffer

      public static <T> void withVoxelBuffer(Voxels<T> voxels, ProcessVoxelBufferUnary<T> process)
      Iterate over each voxel - with one associated voxel-buffer for each slice.

      It is similar to withVoxelBuffer(Voxels, ProcessVoxelBufferUnaryWithPoint) but a Point3i is not exposed.

      Type Parameters:
      T - buffer-type for voxels
      Parameters:
      voxels - voxels to be iterated over (in their entirety)
      process - is called for each voxel within the bounding-box using global coordinates.
    • withVoxelBuffer

      public static <T, E extends Exception> void withVoxelBuffer(Voxels<T> voxels, ProcessVoxelBufferUnaryWithPoint<T,E> process) throws E
      Iterate over each voxel - with one associated voxel-buffer for each slice.

      It is similar to withVoxelBuffer(Voxels, ProcessVoxelBufferUnary) but a Point3i is also exposed.

      Type Parameters:
      T - buffer-type for voxels
      Parameters:
      voxels - voxels to be iterated over (in their entirety)
      process - is called for each voxel within the bounding-box using global coordinates.
      Throws:
      E - exception that may be thrown by the processor
    • withTwoVoxelBuffers

      public static <S, T> void withTwoVoxelBuffers(Voxels<S> voxels1, Voxels<T> voxels2, ProcessVoxelBufferBinary<S,T> process)
      Iterate over each voxel in a bounding-box - with two associated voxel-buffers for each slice

      The extent's of both voxels1 and voxels2 must be equal.

      Type Parameters:
      T - buffer-type for voxels
      Parameters:
      voxels1 - voxels that provide the first voxel-buffer
      voxels2 - voxels that provide the second buffer
      process - is called for each voxel using global coordinates.
    • withTwoMixedBuffers

      public static <S, T> void withTwoMixedBuffers(Voxels<S> voxels1, Voxels<T> voxels2, ProcessVoxelBufferBinaryMixed<S,T> process)
      Iterate over each voxel in a bounding-box - with one associated voxel-buffer and one associated buffer for each slice.

      The extent's of both voxels1 and voxels2 must be equal.

      Note that a new Point3i is created for each call to process.

      Type Parameters:
      T - buffer-type for voxels
      Parameters:
      voxels1 - voxels that provide the first element, the voxel-buffer.
      voxels2 - voxels that provide the second element, the buffer.
      process - is called for each voxel using global coordinates.
    • anyPredicateMatch

      public static <T> boolean anyPredicateMatch(Voxels<T> voxels, Predicate<T> predicate)
      Tries to apply a predicate to all the remaining buffer locations, returning true if the predicate matches.

      The predicate should test only the current element of the buffer, although the whole buffer (of type T is passed as an argument. It should also advance the position in the buffer (as automatically occurs if get() is called.

      Type Parameters:
      T - buffer-type
      Parameters:
      voxels - the voxels to iterate through
      predicate - the predicate on the current element of the buffer
      Returns:
      true if the predicate matches any voxel, false otherwise
    • changeIntensity

      public static void changeIntensity(Voxels<?> voxels, IntUnaryOperator operator)
      Changes each voxel, reading and writing the buffer as an int.

      Note this provides slower access than operating on the native-types.

      Parameters:
      voxels - the voxels, each of which is transformed by operator
      operator - determines a corresponding output value for each input voxel
    • intensityMin

      public static <T extends UnsignedBufferAsInt> int intensityMin(Voxels<T> voxels)
      Finds the minimum intensity-value (as an int) among all voxels.

      Note this provides slower access than operating on the native-types.

      Type Parameters:
      T - the buffer-type
      Parameters:
      voxels - the voxels
      Returns:
      whatever the minimum value is.
    • intensityMax

      public static <T extends UnsignedBufferAsInt> int intensityMax(Voxels<T> voxels)
      Finds the maximum intensity-value (as an int) among all voxels.

      Note this provides slower access than operating on the native-types.

      Type Parameters:
      T - the buffer-type
      Parameters:
      voxels - the voxels
      Returns:
      whatever the maximum value is.
    • intensityMinMax

      public static <T extends UnsignedBufferAsInt> MinMaxRange intensityMinMax(Voxels<T> voxels)
      Finds the maximum intensity-value (as an int) among all voxels.

      Note this provides slower access than operating on the native-types.

      Type Parameters:
      T - the buffer-type
      Parameters:
      voxels - the voxels.
      Returns:
      a newly created MinMaxRange containing the minimum and maximum voxel value.
    • assignEachMatchingPoint

      public static void assignEachMatchingPoint(Voxels<?> voxels, IntPredicate predicate, int valueToAssign)
      Assigns a value to any voxel whose intensity matches a predicate, reading and writing the buffer as an int.

      Note this provides slower access than operating on the native-types.

      Parameters:
      voxels - the voxels, each of which is tested by predicate and maybe assigned a new value
      predicate - determines if a voxel-value should be assigned or not
      valueToAssign - the value to assign
    • binaryOperation

      public static void binaryOperation(Voxels<UnsignedByteBuffer> voxelsIn1, Voxels<UnsignedByteBuffer> voxelsIn2, Voxels<UnsignedByteBuffer> voxelsOut, IntBinaryOperator operation)
      Iterate over each voxel in a bounding-box - applying a binary operation with values from two input Voxels<UnsignedByteBuffer> for each slice and writing it into an output Voxels<UnsignedByteBuffer>.

      The extent's of both voxelsIn1 and voxelsIn2 and voxelsOut must be equal.

      Parameters:
      voxelsIn1 - voxels in which which BoundingBox refers to a subregion, and which provides the first inwards buffer
      voxelsIn2 - voxels in which which BoundingBox refers to a subregion, and which provides the second inwards buffer
      voxelsOut - voxels in which which BoundingBox refers to a subregion, and which provides the outwards buffer
      operation - is called for each voxel within the bounding-box using global coordinates.