Class Util


  • public class Util
    extends java.lang.Object
    TODO
    Author:
    Stephan Preibisch, Stephan Saalfeld
    • Constructor Detail

      • Util

        public Util()
    • Method Detail

      • 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​(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​(java.util.List<java.lang.Double> values)
      • averageFloat

        public static float averageFloat​(java.util.List<java.lang.Float> values)
      • min

        public static float min​(java.util.List<java.lang.Float> values)
      • max

        public static float max​(java.util.List<java.lang.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 java.lang.String printCoordinates​(float[] value)
      • printCoordinates

        public static java.lang.String printCoordinates​(double[] value)
      • printCoordinates

        public static java.lang.String printCoordinates​(RealLocalizable localizable)
      • printInterval

        public static java.lang.String printInterval​(Interval interval)
      • printCoordinates

        public static java.lang.String printCoordinates​(int[] value)
      • printCoordinates

        public static java.lang.String printCoordinates​(long[] value)
      • printCoordinates

        public static java.lang.String printCoordinates​(boolean[] value)
      • pow

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

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

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

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

        public static final long[] int2long​(int[] i)
      • 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 -