Class ElementUtil

java.lang.Object
org.bonej.utilities.ElementUtil

public final class ElementUtil extends Object
Various utility methods for inspecting image element properties
Author:
Richard Domander, Michael Doube
  • Method Details

    • calibratedSpatialElementSize

      public static <T extends net.imagej.space.AnnotatedSpace<net.imagej.axis.CalibratedAxis>> double calibratedSpatialElementSize(T space, net.imagej.units.UnitService unitService)
      Returns the calibrated size of a single spatial element in the given space, e.g. the volume of an element in a 3D space, or area in 2D.

      Spatial axes do not have to have the same unit in calibration, but you must be able to convert between them.

      Type Parameters:
      T - type of the space.
      Parameters:
      space - an N-dimensional space.
      unitService - needed to convert between units of different calibrations.
      Returns:
      Calibrated size of a spatial element, or Double.NaN if space has nonlinear axes, or calibration units cannot be converted.
    • isBinary

      public static <T extends net.imglib2.type.numeric.RealType<T> & net.imglib2.type.NativeType<T>> boolean isBinary(net.imglib2.IterableInterval<T> interval)
      Checks whether the interval contains only two distinct values. Use for BitType images, not ImageJ1 8-bit (0,255) images.
      Type Parameters:
      T - type of the elements in the interval.
      Parameters:
      interval - an iterable interval.
      Returns:
      true if only two distinct values, false if interval is empty or has more values.
    • isIJ1Binary

      public static boolean isIJ1Binary(net.imagej.Dataset ds, long n)
      Check whether a Dataset's pixels conform to the IJ1 binary definition, 8-bit and only 0,255. Do not use for BitType inputs. If the image has fewer pixels than n, it scans ALL pixels. Otherwise, it randomly samples n pixels.
      Parameters:
      ds - The dataset to check.
      n - The maximum number of pixels to check.
      Returns:
      true if all checked pixels are 0 or 255.