Package net.imglib2.util
Class Util
java.lang.Object
net.imglib2.util.Util
TODO
- Author:
- Stephan Preibisch, Stephan Saalfeld
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic doubleaverage(double[] values) static floataverage(float[] values) static doubleaverageDouble(List<Double> values) static floataverageFloat(List<Float> values) static double[]createGaussianKernel1DDouble(double sigma, boolean normalize) This method creates a gaussian kernelstatic final doubledistance(long[] position1, long[] position2) static final doubledistance(RealLocalizable position1, RealLocalizable position2) static booleanequalIterationOrder(IterableInterval<?>... intervals) Checks whether nIterableIntervalhave 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 intgetSuggestedKernelDiameter(double sigma) static final <T,F extends Interval & RandomAccessible<T>>
TgetTypeFromInterval(F rai) Gets an instance of T from theRandomAccessibleIntervalby querying the value at the min coordinatestatic final <T,F extends RealInterval & RealRandomAccessible<T>>
TgetTypeFromRealInterval(F rai) Gets an instance of T from theRandomAccessibleIntervalby querying the value at the min coordinatestatic doublegLog(double z, double c) static floatgLog(float z, float c) static doublegLogInv(double w, double c) static doublegLogInv(float w, float c) static final long[]int2long(int[] i) static booleanisApproxEqual(double a, double b, double threshold) static booleanisApproxEqual(float a, float b, float threshold) static final intldu(int v) (Hopefully) fast floor log2 of an unsigned(!) integer value.static doublelog2(double value) static final int[]long2int(long[] a) static doublemax(double[] values) static final voidmax(double[] a, double[] b) Writes max(a,b) into astatic floatstatic <T extends Type<T> & Comparable<T>>
Tmax(T value1, T value2) static doublemedian(double[] values) static floatmedian(float[] values) static longmedian(long[] values) static doublemin(double[] values) static final voidmin(double[] a, double[] b) Writes min(a,b) into astatic floatstatic <T extends Type<T> & Comparable<T>>
Tmin(T value1, T value2) static doublepercentile(double[] values, double percentile) Computes the percentile of a collection of doubles (percentile 0.5 roughly corresponds to median)static intpow(int a, int b) static StringprintCoordinates(boolean[] value) static StringprintCoordinates(double[] value) static StringprintCoordinates(float[] value) static StringprintCoordinates(int[] value) static StringprintCoordinates(long[] value) static StringprintCoordinates(RealLocalizable localizable) static StringprintInterval(Interval interval) static voidquicksort(double[] data) static voidquicksort(double[] data, int[] sortAlso, int left, int right) static voidquicksort(double[] data, int left, int right) static voidquicksort(float[] data) static voidquicksort(float[] data, int left, int right) static voidquicksort(long[] data, int left, int right) static longround(double value) static intround(float value)
-
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
-
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
-
averageFloat
-
min
-
max
-
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
-
printCoordinates
-
printCoordinates
-
printInterval
-
printCoordinates
-
printCoordinates
-
printCoordinates
-
pow
public static int pow(int a, int b) -
max
-
min
-
long2int
public static final int[] long2int(long[] a) -
int2long
public static final long[] int2long(int[] i) -
getTypeFromInterval
Gets an instance of T from theRandomAccessibleIntervalby 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 theRandomAccessibleIntervalby 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 anArrayImgFactoryif an image of the requestedtargetSizecould be held in anArrayImg. Otherwise return aCellImgFactorywith 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
ArrayImgFactoryor aCellImgFactory.
-
getArrayOrCellImgFactory
public static <T extends NativeType<T>> ImgFactory<T> getArrayOrCellImgFactory(Dimensions targetSize, int targetCellSize, T type) Create anArrayImgFactoryif an image of the requestedtargetSizecould be held in anArrayImg. Otherwise return aCellImgFactorywith cell sizetargetCellSize(or as large as possible iftargetCellSizeis too large).- Parameters:
targetSize- size of image that the factory should be able to create.targetCellSize- if aCellImgFactoryis created, what should be the cell size.type- type of the factory.- Returns:
- an
ArrayImgFactoryor 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
Checks whether nIterableIntervalhave 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-
-