public class Util extends Object
Constructor and Description |
---|
Util() |
Modifier and Type | Method and Description |
---|---|
static double[] |
asDoubleArray(Img<? extends RealType<?>> image)
Returns the pixels of an image of RealType as array of doubles.
|
static double[] |
asDoubleArray(Iterable<? extends RealType<?>> iterable)
Returns the content of
Iterable<RealType> as array of doubles. |
static double[] |
asDoubleArray(RandomAccessibleInterval<? extends RealType<?>> rai)
Returns the pixels of an RandomAccessibleInterval of RealType as array of doubles.
|
static double |
average(double[] values) |
static float |
average(float[] values) |
static double |
averageDouble(List<Double> values) |
static float |
averageFloat(List<Float> values) |
static int |
combineHash(int hash1,
int hash2) |
static double[] |
createGaussianKernel1DDouble(double sigma,
boolean normalize)
This method creates a gaussian kernel
|
static double |
distance(long[] position1,
long[] position2) |
static double |
distance(RealLocalizable position1,
RealLocalizable position2) |
static boolean |
equalIterationOrder(IterableInterval<?>... intervals)
Checks whether n
IterableInterval have the same iteration order. |
static <T> T[] |
genericArray(int length)
Deprecated.
|
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>> |
getArrayOrCellImgFactory(Dimensions targetSize,
int targetCellSize,
T type)
|
static <T extends NativeType<T>> |
getArrayOrCellImgFactory(Dimensions targetSize,
T type)
|
static int |
getSuggestedKernelDiameter(double sigma) |
static <T> ImgFactory<T> |
getSuitableImgFactory(Dimensions targetSize,
T type)
|
static <T,F extends Interval & RandomAccessible<T>> |
getTypeFromInterval(F rai)
Gets an instance of T from the
RandomAccessibleInterval by
querying the value at the min coordinate |
static <T,F extends RealInterval & RealRandomAccessible<T>> |
getTypeFromRealInterval(F rai)
Gets an instance of T from the
RandomAccessibleInterval by
querying the value at the min coordinate |
static 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 <T extends ValueEquals<U>,U> |
imagesEqual(RandomAccessibleInterval<? extends T> a,
RandomAccessibleInterval<? extends U> b)
Checks if both images have equal intervals and content.
|
static <T,U> boolean |
imagesEqual(RandomAccessibleInterval<? extends T> a,
RandomAccessibleInterval<? extends U> b,
BiPredicate<T,U> pixelEquals)
Checks if both images have equal intervals and content.
|
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 boolean |
locationsEqual(Localizable l1,
Localizable l2)
Determines whether the two
Localizable objects have the same
position, with long precision. |
static boolean |
locationsEqual(RealLocalizable l1,
RealLocalizable l2)
Determines whether the two
RealLocalizable objects have the same
position, with double precision. |
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 a
|
static float |
max(List<Float> values) |
static <T extends Type<T> & Comparable<T>> |
max(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 a
|
static float |
min(List<Float> values) |
static <T extends Type<T> & Comparable<T>> |
min(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 String |
printCoordinates(boolean[] value) |
static String |
printCoordinates(double[] value) |
static String |
printCoordinates(float[] value) |
static String |
printCoordinates(int[] value) |
static String |
printCoordinates(long[] value) |
static String |
printCoordinates(RealLocalizable localizable) |
static 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) |
static void |
quicksort(long[] data,
int left,
int right) |
static long |
round(double value) |
static int |
round(float value) |
static int |
roundToInt(double value) |
static int |
roundToInt(float value) |
static long |
roundToLong(double value) |
static long |
roundToLong(float value) |
static <T extends ValueEquals<T>> |
valueEqualsObject(T a,
Object b)
This method should be used in implementations of
ValueEquals , to
override Object.equals(Object) . |
@Deprecated public static <T> T[] genericArray(int length)
See https://github.com/imglib/imglib2/issues/253
public static double log2(double value)
public static double[] getArrayFromValue(double value, int numDimensions)
public static float[] getArrayFromValue(float value, int numDimensions)
public static int[] getArrayFromValue(int value, int numDimensions)
public static long[] getArrayFromValue(long value, int numDimensions)
public static final double distance(RealLocalizable position1, RealLocalizable position2)
public static final double distance(long[] position1, long[] position2)
public static double percentile(double[] values, double percentile)
values
- - the valuespercentile
- - the percentile [0...1]public static float average(float[] values)
public static double average(double[] values)
public static double min(double[] values)
public static double max(double[] values)
public static long median(long[] values)
public static double median(double[] values)
public static float median(float[] values)
public static void quicksort(long[] data)
public static void quicksort(long[] data, int left, int right)
public static void quicksort(double[] data)
public static void quicksort(double[] data, int left, int right)
public static void quicksort(float[] data)
public static void quicksort(float[] data, int left, int right)
public static void quicksort(double[] data, int[] sortAlso, int left, int right)
public static double gLog(double z, double c)
public static float gLog(float z, float c)
public static double gLogInv(double w, double c)
public static double gLogInv(float w, float c)
public static boolean isApproxEqual(float a, float b, float threshold)
public static boolean isApproxEqual(double a, double b, double threshold)
public static int round(float value)
public static long round(double value)
public static int roundToInt(float value)
public static int roundToInt(double value)
public static long roundToLong(float value)
public static long roundToLong(double value)
public static double[] createGaussianKernel1DDouble(double sigma, boolean normalize)
sigma
- Standard Derivation of the gaussian functionnormalize
- Normalize integral of gaussian function to 1 or not...public static int getSuggestedKernelDiameter(double sigma)
public static String printCoordinates(float[] value)
public static String printCoordinates(double[] value)
public static String printCoordinates(RealLocalizable localizable)
public static String printCoordinates(int[] value)
public static String printCoordinates(long[] value)
public static String printCoordinates(boolean[] value)
public static int pow(int a, int b)
public static <T extends Type<T> & Comparable<T>> T max(T value1, T value2)
public static <T extends Type<T> & Comparable<T>> T min(T value1, T value2)
public static final int[] long2int(long[] a)
public static final long[] int2long(int[] i)
public static final <T,F extends Interval & RandomAccessible<T>> T getTypeFromInterval(F rai)
RandomAccessibleInterval
by
querying the value at the min coordinateT
- - the Trai
- - the RandomAccessibleInterval
public static final <T,F extends RealInterval & RealRandomAccessible<T>> T getTypeFromRealInterval(F rai)
RandomAccessibleInterval
by
querying the value at the min coordinateT
- - the Trai
- - the RandomAccessibleInterval
public static <T extends NativeType<T>> ImgFactory<T> getArrayOrCellImgFactory(Dimensions targetSize, T type)
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.targetSize
- size of image that the factory should be able to create.type
- type of the factory.ArrayImgFactory
or a CellImgFactory
.public static <T extends NativeType<T>> ImgFactory<T> getArrayOrCellImgFactory(Dimensions targetSize, int targetCellSize, T type)
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).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.ArrayImgFactory
or a CellImgFactory
.public static <T> ImgFactory<T> getSuitableImgFactory(Dimensions targetSize, T type)
ImgFactory
for the requested
targetSize
and type
. If the target size is a Img
,
return its ImgFactory
. If the type is a NativeType
, then
getArrayOrCellImgFactory(Dimensions, NativeType)
is used; if
not, a ListImgFactory
is returned.targetSize
- size of image that the factory should be able to create.type
- type of the factory.ArrayImgFactory
, CellImgFactory
or
ListImgFactory
as appropriate.public static final int ldu(int v)
v
- unsigned integerpublic static boolean equalIterationOrder(IterableInterval<?>... intervals)
IterableInterval
have the same iteration order.public static boolean locationsEqual(Localizable l1, Localizable l2)
Localizable
objects have the same
position, with long
precision.
At first glance, this method may appear to be unnecessary, since there is
also locationsEqual(RealLocalizable, RealLocalizable)
, which is
more general. The difference is that this method compares the positions
using Localizable.getLongPosition(int)
, which has higher
precision in integer space than
RealLocalizable.getDoublePosition(int)
does, which is what the
locationsEqual(RealLocalizable, RealLocalizable)
method uses.
l1
- The first Localizable
.l2
- The second Localizable
.Localizable.getLongPosition(int)
public static boolean locationsEqual(RealLocalizable l1, RealLocalizable l2)
RealLocalizable
objects have the same
position, with double
precision.l1
- The first RealLocalizable
.l2
- The second RealLocalizable
.RealLocalizable.getDoublePosition(int)
public static <T extends ValueEquals<U>,U> boolean imagesEqual(RandomAccessibleInterval<? extends T> a, RandomAccessibleInterval<? extends U> b)
public static <T,U> boolean imagesEqual(RandomAccessibleInterval<? extends T> a, RandomAccessibleInterval<? extends U> b, BiPredicate<T,U> pixelEquals)
public static final void min(double[] a, double[] b)
a
- b
- public static final void max(double[] a, double[] b)
a
- b
- public static double[] asDoubleArray(Iterable<? extends RealType<?>> iterable)
Iterable<RealType>
as array of doubles.public static double[] asDoubleArray(RandomAccessibleInterval<? extends RealType<?>> rai)
public static double[] asDoubleArray(Img<? extends RealType<?>> image)
public static <T extends ValueEquals<T>> boolean valueEqualsObject(T a, Object b)
ValueEquals
, to
override Object.equals(Object)
.Object.equals(Object)
public static int combineHash(int hash1, int hash2)
Copyright © 2015–2022 ImgLib2. All rights reserved.