Package net.imglib2.util
Class Util
- java.lang.Object
-
- net.imglib2.util.Util
-
public class Util extends java.lang.Object
TODO- Author:
- Stephan Preibisch, Stephan Saalfeld
-
-
Constructor Summary
Constructors Constructor Description Util()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static double
average(double[] values)
static float
average(float[] values)
static double
averageDouble(java.util.List<java.lang.Double> values)
static float
averageFloat(java.util.List<java.lang.Float> values)
static double[]
createGaussianKernel1DDouble(double sigma, boolean normalize)
This method creates a gaussian kernelstatic double
distance(long[] position1, long[] position2)
static double
distance(RealLocalizable position1, RealLocalizable position2)
static boolean
equalIterationOrder(IterableInterval<?>... intervals)
Checks whether nIterableInterval
have the same iteration order.static <T> T[]
genericArray(int length)
static double[]
getArrayFromValue(double value, int numDimensions)
static float[]
getArrayFromValue(float value, int numDimensions)
static int[]
getArrayFromValue(int value, int numDimensions)
static long[]
getArrayFromValue(long value, int numDimensions)
static <T extends NativeType<T>>
ImgFactory<T>getArrayOrCellImgFactory(Dimensions targetSize, int targetCellSize, T type)
static <T extends NativeType<T>>
ImgFactory<T>getArrayOrCellImgFactory(Dimensions targetSize, T type)
static int
getSuggestedKernelDiameter(double sigma)
static <T,F extends Interval & RandomAccessible<T>>
TgetTypeFromInterval(F rai)
Gets an instance of T from theRandomAccessibleInterval
by querying the value at the min coordinatestatic <T,F extends RealInterval & RealRandomAccessible<T>>
TgetTypeFromRealInterval(F rai)
Gets an instance of T from theRandomAccessibleInterval
by querying the value at the min coordinatestatic double
gLog(double z, double c)
static float
gLog(float z, float c)
static double
gLogInv(double w, double c)
static double
gLogInv(float w, float c)
static long[]
int2long(int[] i)
static boolean
isApproxEqual(double a, double b, double threshold)
static boolean
isApproxEqual(float a, float b, float threshold)
static int
ldu(int v)
(Hopefully) fast floor log2 of an unsigned(!) integer value.static double
log2(double value)
static int[]
long2int(long[] a)
static double
max(double[] values)
static void
max(double[] a, double[] b)
Writes max(a,b) into astatic float
max(java.util.List<java.lang.Float> values)
static <T extends Type<T> & java.lang.Comparable<T>>
Tmax(T value1, T value2)
static double
median(double[] values)
static float
median(float[] values)
static long
median(long[] values)
static double
min(double[] values)
static void
min(double[] a, double[] b)
Writes min(a,b) into astatic float
min(java.util.List<java.lang.Float> values)
static <T extends Type<T> & java.lang.Comparable<T>>
Tmin(T value1, T value2)
static double
percentile(double[] values, double percentile)
Computes the percentile of a collection of doubles (percentile 0.5 roughly corresponds to median)static int
pow(int a, int b)
static java.lang.String
printCoordinates(boolean[] value)
static java.lang.String
printCoordinates(double[] value)
static java.lang.String
printCoordinates(float[] value)
static java.lang.String
printCoordinates(int[] value)
static java.lang.String
printCoordinates(long[] value)
static java.lang.String
printCoordinates(RealLocalizable localizable)
static java.lang.String
printInterval(Interval interval)
static void
quicksort(double[] data)
static void
quicksort(double[] data, int[] sortAlso, int left, int right)
static void
quicksort(double[] data, int left, int right)
static void
quicksort(float[] data)
static void
quicksort(float[] data, int left, int right)
static void
quicksort(long[] data, int left, int right)
static long
round(double value)
static int
round(float value)
-
-
-
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(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 valuespercentile
- - 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 functionnormalize
- 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)
-
getTypeFromInterval
public static final <T,F extends Interval & RandomAccessible<T>> T getTypeFromInterval(F rai)
Gets an instance of T from theRandomAccessibleInterval
by querying the value at the min coordinate- Type Parameters:
T
- - the T- Parameters:
rai
- - theRandomAccessibleInterval
- 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 theRandomAccessibleInterval
by querying the value at the min coordinate- Type Parameters:
T
- - the T- Parameters:
rai
- - theRandomAccessibleInterval
- Returns:
- - an instance of T
-
getArrayOrCellImgFactory
public static <T extends NativeType<T>> ImgFactory<T> getArrayOrCellImgFactory(Dimensions targetSize, T type)
Create anArrayImgFactory
if an image of the requestedtargetSize
could be held in anArrayImg
. Otherwise return aCellImgFactory
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 aCellImgFactory
.
-
getArrayOrCellImgFactory
public static <T extends NativeType<T>> ImgFactory<T> getArrayOrCellImgFactory(Dimensions targetSize, int targetCellSize, T type)
Create anArrayImgFactory
if an image of the requestedtargetSize
could be held in anArrayImg
. Otherwise return aCellImgFactory
with cell sizetargetCellSize
(or as large as possible iftargetCellSize
is too large).- Parameters:
targetSize
- size of image that the factory should be able to create.targetCellSize
- if aCellImgFactory
is created, what should be the cell size.type
- type of the factory.- Returns:
- an
ArrayImgFactory
or aCellImgFactory
.
-
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 nIterableInterval
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
-
-
-