Class Util

java.lang.Object
net.imglib2.util.Util

public class Util extends Object
TODO
Author:
Stephan Preibisch, Stephan Saalfeld
  • Constructor Details

    • Util

      public Util()
  • Method Details

    • genericArray

      public static <T> T[] genericArray(int length)
    • log2

      public static double log2(double value)
    • getArrayFromValue

      public static double[] getArrayFromValue(double value, int numDimensions)
    • getArrayFromValue

      public static float[] getArrayFromValue(float value, int numDimensions)
    • getArrayFromValue

      public static int[] getArrayFromValue(int value, int numDimensions)
    • getArrayFromValue

      public static long[] getArrayFromValue(long value, int numDimensions)
    • distance

      public static final double distance(RealLocalizable position1, RealLocalizable position2)
    • distance

      public static final double distance(long[] position1, long[] position2)
    • percentile

      public static double percentile(double[] values, double percentile)
      Computes the percentile of a collection of doubles (percentile 0.5 roughly corresponds to median)
      Parameters:
      values - - the values
      percentile - - the percentile [0...1]
      Returns:
      the corresponding value
    • averageDouble

      public static double averageDouble(List<Double> values)
    • averageFloat

      public static float averageFloat(List<Float> values)
    • min

      public static float min(List<Float> values)
    • max

      public static float max(List<Float> values)
    • average

      public static float average(float[] values)
    • average

      public static double average(double[] values)
    • min

      public static double min(double[] values)
    • max

      public static double max(double[] values)
    • median

      public static long median(long[] values)
    • median

      public static double median(double[] values)
    • median

      public static float median(float[] values)
    • quicksort

      public static void quicksort(long[] data, int left, int right)
    • quicksort

      public static void quicksort(double[] data)
    • quicksort

      public static void quicksort(double[] data, int left, int right)
    • quicksort

      public static void quicksort(float[] data)
    • quicksort

      public static void quicksort(float[] data, int left, int right)
    • quicksort

      public static void quicksort(double[] data, int[] sortAlso, int left, int right)
    • gLog

      public static double gLog(double z, double c)
    • gLog

      public static float gLog(float z, float c)
    • gLogInv

      public static double gLogInv(double w, double c)
    • gLogInv

      public static double gLogInv(float w, float c)
    • isApproxEqual

      public static boolean isApproxEqual(float a, float b, float threshold)
    • isApproxEqual

      public static boolean isApproxEqual(double a, double b, double threshold)
    • round

      public static int round(float value)
    • round

      public static long round(double value)
    • createGaussianKernel1DDouble

      public static double[] createGaussianKernel1DDouble(double sigma, boolean normalize)
      This method creates a gaussian kernel
      Parameters:
      sigma - Standard Derivation of the gaussian function
      normalize - Normalize integral of gaussian function to 1 or not...
      Returns:
      double[] The gaussian kernel
    • getSuggestedKernelDiameter

      public static int getSuggestedKernelDiameter(double sigma)
    • printCoordinates

      public static String printCoordinates(float[] value)
    • printCoordinates

      public static String printCoordinates(double[] value)
    • printCoordinates

      public static String printCoordinates(RealLocalizable localizable)
    • printInterval

      public static String printInterval(Interval interval)
    • printCoordinates

      public static String printCoordinates(int[] value)
    • printCoordinates

      public static String printCoordinates(long[] value)
    • printCoordinates

      public static String printCoordinates(boolean[] value)
    • pow

      public static int pow(int a, int b)
    • max

      public static <T extends Type<T> & Comparable<T>> T max(T value1, T value2)
    • min

      public static <T extends Type<T> & Comparable<T>> T min(T value1, T value2)
    • long2int

      public static final int[] long2int(long[] a)
    • int2long

      public static final long[] int2long(int[] i)
    • getTypeFromInterval

      public static final <T, F extends Interval & RandomAccessible<T>> T getTypeFromInterval(F rai)
      Gets an instance of T from the RandomAccessibleInterval by querying the value at the min coordinate
      Type Parameters:
      T - - the T
      Parameters:
      rai - - the RandomAccessibleInterval
      Returns:
      - an instance of T
    • getTypeFromRealInterval

      public static final <T, F extends RealInterval & RealRandomAccessible<T>> T getTypeFromRealInterval(F rai)
      Gets an instance of T from the RandomAccessibleInterval by querying the value at the min coordinate
      Type Parameters:
      T - - the T
      Parameters:
      rai - - the RandomAccessibleInterval
      Returns:
      - an instance of T
    • getArrayOrCellImgFactory

      public static <T extends NativeType<T>> ImgFactory<T> getArrayOrCellImgFactory(Dimensions targetSize, T type)
      Create an ArrayImgFactory if an image of the requested targetSize could be held in an ArrayImg. Otherwise return a CellImgFactory with as large as possible cell size.
      Parameters:
      targetSize - size of image that the factory should be able to create.
      type - type of the factory.
      Returns:
      an ArrayImgFactory or a CellImgFactory.
    • getArrayOrCellImgFactory

      public static <T extends NativeType<T>> ImgFactory<T> getArrayOrCellImgFactory(Dimensions targetSize, int targetCellSize, T type)
      Create an ArrayImgFactory if an image of the requested targetSize could be held in an ArrayImg. Otherwise return a CellImgFactory with cell size targetCellSize (or as large as possible if targetCellSize is too large).
      Parameters:
      targetSize - size of image that the factory should be able to create.
      targetCellSize - if a CellImgFactory is created, what should be the cell size.
      type - type of the factory.
      Returns:
      an ArrayImgFactory or a CellImgFactory.
    • ldu

      public static final int ldu(int v)
      (Hopefully) fast floor log2 of an unsigned(!) integer value.
      Parameters:
      v - unsigned integer
      Returns:
      floor log2
    • equalIterationOrder

      public static boolean equalIterationOrder(IterableInterval<?>... intervals)
      Checks whether n IterableInterval have the same iteration order.
    • min

      public static final void min(double[] a, double[] b)
      Writes min(a,b) into a
      Parameters:
      a -
      b -
    • max

      public static final void max(double[] a, double[] b)
      Writes max(a,b) into a
      Parameters:
      a -
      b -