public class ImgMath extends Object
RandomAccessibleInterval
instances.
Peak performance is within 1.2X - 1.8X of manually writing a loop
using ImgLib2's low-level Cursor
or RandomAccess
with
native math + / - *
and flow if else
operators
and in-loop variable declarations.
Input images can be of different Type
as long as all of them
extend RealType.
An example in java:
import static net.imglib2.algorithm.math.ImgMath.*;
RandomAccessibleInterval<A> img1 = ...
RandomAccessibleInterval<B> img2 = ...
RandomAccessibleInterval<C> img3 = ...
RandomAccessibleInterval<O> result = ...
compute( div( max( img1, img2, img3 ), 3.0 ) ).into( result );
Another example, illustrating variable declaration with Let
and also if/then/else flow control, to compute the saturation of
an RGB image:
import static net.imglib2.algorithm.math.ImgMath.*;
RandomAccessible< ARGBType > rgb = ...
final RandomAccessibleInterval< UnsignedByteType >
red = Converters.argbChannel( rgb, 1 ),
green = Converters.argbChannel( rgb, 2 ),
blue = Converters.argbChannel( rgb, 3 );
RandomAccessibleInterval< FloatType > saturation = new ArrayImgFactory< FloatType >( new FloatType() ).create( rgb );
compute( let( "red", red,
"green", green,
"blue", blue,
"max", max( var( "red" ), var( "green" ), var( "blue" ) ),
"min", min( var( "red" ), var( "green" ), var( "blue" ) ),
IF ( EQ( 0, var( "max" ) ),
THEN( 0 ),
ELSE( div( sub( var( "max" ), var( "min" ) ),
var( "max" ) ) ) ) ) )
.into( saturation );
Constructor and Description |
---|
ImgMath() |
Modifier and Type | Method and Description |
---|---|
static Add |
add(Object... obs) |
static Add |
add(Object o1,
Object o2) |
static AndLogical |
AND(Object... o) |
static AndLogical |
AND(Object o1,
Object o2) |
static <T extends RealType<T>> |
block(RandomAccessible<T> src,
long radius) |
static <T extends RealType<T>> |
block(RandomAccessible<T> src,
long[] radius) |
static <T extends RealType<T>> |
block(RandomAccessible<T> src,
long[][] corners) |
static Compute |
compute(IFunction operation) |
static <I extends RealType<I>> |
compute(RandomAccessibleInterval<I> src) |
static <O extends RealType<O>> |
computeInto(IFunction operation,
RandomAccessibleInterval<O> target) |
static <O extends RealType<O>> |
computeInto(IFunction operation,
RandomAccessibleInterval<O> target,
Converter<RealType<?>,O> converter) |
static <O extends NativeType<O> & RealType<O>> |
computeIntoArrayImg(IFunction operation) |
static RandomAccessibleInterval<FloatType> |
computeIntoFloats(IFunction operation) |
static <O extends NativeType<O> & RealType<O>> |
computeIntoImg(IFunction operation) |
static Div |
div(Object... obs) |
static Div |
div(Object o1,
Object o2) |
static Else |
ELSE(Object o) |
static Equal |
EQ(Object o1,
Object o2) |
static Equal |
equal(Object o1,
Object o2) |
static Exp |
exp(Object o1) |
static <T extends RealType<T>> |
gen(KDTree<T> kdtree,
double radius) |
static <T extends RealType<T>> |
gen(KDTree<T> kdtree,
double radius,
Object outside) |
static <T extends RealType<T>> |
gen(KDTree<T> kdtree,
double radius,
Object outside,
Interval interval) |
static <T extends RealType<T>> |
gen(List<Point> positions,
List<T> values,
double radius) |
static <T extends RealType<T>> |
gen(List<Point> positions,
List<T> values,
double radius,
Object outside) |
static <T extends RealType<T>> |
gen(List<Point> positions,
List<T> values,
double radius,
Object outside,
Interval interval) |
static <T extends RealType<T>> |
gen(List<Point> positions,
T value,
double radius) |
static <T extends RealType<T>> |
gen(List<Point> positions,
T value,
double radius,
Object outside) |
static <T extends RealType<T>> |
gen(List<Point> positions,
T value,
double radius,
Object outside,
Interval interval) |
static GreaterThan |
greaterThan(Object o1,
Object o2) |
static GreaterThan |
GT(Object o1,
Object o2) |
static If |
IF(Object o1,
Object o2,
Object o3) |
static <T extends RealType<T>> |
img(RandomAccessibleInterval<T> rai) |
static <T extends RealType<T>> |
intervalSource(RandomAccessibleInterval<T> rai)
Synonym of
img(RandomAccessibleInterval) , given that img is a widely used variable name. |
static LessThan |
lessThan(Object o1,
Object o2) |
static Let |
let(Object... obs) |
static Let |
let(Object[] pairs,
Object body) |
static Let |
let(String varName,
Object varValue,
Object body) |
static Log |
log(Object o1) |
static Log |
logarithm(Object o1) |
static LessThan |
LT(Object o1,
Object o2) |
static Max |
max(Object... obs) |
static Max |
max(Object o1,
Object o2) |
static Max |
maximum(Object... obs) |
static Max |
maximum(Object o1,
Object o2) |
static Min |
min(Object... obs) |
static Min |
min(Object o1,
Object o2) |
static Min |
minimum(Object... obs) |
static Min |
minimum(Object o1,
Object o2) |
static Minus |
minus(Object o1) |
static Mul |
mul(Object... obs) |
static Mul |
mul(Object o1,
Object o2) |
static NotEqual |
NEQ(Object o1,
Object o2) |
static NotLogical |
NOT(Object o) |
static NotEqual |
notEqual(Object o1,
Object o2) |
static NumberSource |
number(Number number) |
static <T extends RealType<T>> |
offset(IFunction f,
long[] offset) |
static <T extends RealType<T>> |
offset(RandomAccessible<T> src,
long[] offset) |
static OrLogical |
OR(Object... o) |
static OrLogical |
OR(Object o1,
Object o2) |
static Pow |
pow(Object o1,
Object o2) |
static Pow |
power(Object o1,
Object o2) |
static <T extends RealType<T>> |
source(RandomAccessible<T> src) |
static Sub |
sub(Object... obs) |
static Sub |
sub(Object o1,
Object o2) |
static Then |
THEN(Object o) |
static Var |
var(String name) |
static <O extends RealType<O>> |
view(ViewableFunction operation)
Almost all
IFunction are also ViewableFunction . |
static RandomAccessibleInterval<FloatType> |
viewFloats(ViewableFunction operation)
Almost all
IFunction are also ViewableFunction . |
static XorLogical |
XOR(Object... o) |
static XorLogical |
XOR(Object o1,
Object o2) |
public static final <I extends RealType<I>> Compute compute(RandomAccessibleInterval<I> src)
public static final RandomAccessibleInterval<FloatType> computeIntoFloats(IFunction operation)
public static final <O extends RealType<O>> RandomAccessibleInterval<O> computeInto(IFunction operation, RandomAccessibleInterval<O> target)
public static final <O extends RealType<O>> RandomAccessibleInterval<O> computeInto(IFunction operation, RandomAccessibleInterval<O> target, Converter<RealType<?>,O> converter)
public static final <O extends NativeType<O> & RealType<O>> RandomAccessibleInterval<O> computeIntoImg(IFunction operation)
public static final <O extends NativeType<O> & RealType<O>> RandomAccessibleInterval<O> computeIntoArrayImg(IFunction operation)
public static final <O extends RealType<O>> RandomAccessibleInterval<O> view(ViewableFunction operation)
IFunction
are also ViewableFunction
.operation
- public static final RandomAccessibleInterval<FloatType> viewFloats(ViewableFunction operation)
IFunction
are also ViewableFunction
.operation
- public static final GreaterThan GT(Object o1, Object o2)
public static final GreaterThan greaterThan(Object o1, Object o2)
public static final AndLogical AND(Object o1, Object o2)
public static final AndLogical AND(Object... o)
public static final XorLogical XOR(Object o1, Object o2)
public static final XorLogical XOR(Object... o)
public static final NotLogical NOT(Object o)
public static final <T extends RealType<T>> ImgSource<T> img(RandomAccessibleInterval<T> rai)
public static final <T extends RealType<T>> ImgSource<T> intervalSource(RandomAccessibleInterval<T> rai)
img(RandomAccessibleInterval)
, given that img
is a widely used variable name.public static final NumberSource number(Number number)
public static final <T extends RealType<T>> BlockReadSource<T> block(RandomAccessible<T> src, long[] radius)
public static final <T extends RealType<T>> BlockReadSource<T> block(RandomAccessible<T> src, long radius)
public static final <T extends RealType<T>> BlockReadSource<T> block(RandomAccessible<T> src, long[][] corners)
public static final <T extends RealType<T>> RandomAccessibleSource<T> offset(RandomAccessible<T> src, long[] offset)
public static final <T extends RealType<T>> OffsetSource<T> offset(IFunction f, long[] offset)
public static final <T extends RealType<T>> IFunction source(RandomAccessible<T> src)
public static final <T extends RealType<T>> KDTreeSource<T> gen(List<Point> positions, T value, double radius)
public static final <T extends RealType<T>> KDTreeSource<T> gen(List<Point> positions, T value, double radius, Object outside)
public static final <T extends RealType<T>> KDTreeSource<T> gen(List<Point> positions, T value, double radius, Object outside, Interval interval)
public static final <T extends RealType<T>> KDTreeSource<T> gen(List<Point> positions, List<T> values, double radius)
public static final <T extends RealType<T>> KDTreeSource<T> gen(List<Point> positions, List<T> values, double radius, Object outside)
public static final <T extends RealType<T>> KDTreeSource<T> gen(List<Point> positions, List<T> values, double radius, Object outside, Interval interval)
public static final <T extends RealType<T>> KDTreeSource<T> gen(KDTree<T> kdtree, double radius)
public static final <T extends RealType<T>> KDTreeSource<T> gen(KDTree<T> kdtree, double radius, Object outside)
public static final <T extends RealType<T>> KDTreeSource<T> gen(KDTree<T> kdtree, double radius, Object outside, Interval interval)
Copyright © 2015–2022 ImgLib2. All rights reserved.