use of net.imglib2.algorithm.neighborhood.Shape in project imagej-ops by imagej.
the class LocalThresholdIntegral method initialize.
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public void initialize() {
// Increase span of shape by 1 to return correct values together with
// the integralSum operation
shape = new RectangleShape(shape.getSpan() + 1, false);
filterOp = unaryComputer();
integralImgOp = (AbstractUnaryHybridCF) ops().op(Ops.Image.Integral.class, in());
squareIntegralImgOp = (AbstractUnaryHybridCF) ops().op(Ops.Image.SquareIntegral.class, in());
}
use of net.imglib2.algorithm.neighborhood.Shape in project imagej-ops by imagej.
the class NonLinearFiltersTest method testVarianceFilter.
/**
* @see VarianceFilterOp
* @see DefaultVarianceFilter
*/
@Test
public void testVarianceFilter() {
ops.run(VarianceFilterOp.class, out, in, shape, oobFactory);
double sum = 0.0;
double sumSq = 0.0;
NeighborhoodsIterableInterval<ByteType> neighborhoods = shape.neighborhoods(Views.interval(Views.extendMirrorSingle(in), in));
for (ByteType t : neighborhoods.firstElement()) {
sum += t.getRealDouble();
sumSq += t.getRealDouble() * t.getRealDouble();
}
assertEquals((byte) Util.round((sumSq - (sum * sum / 9)) / 8), out.firstElement().get());
}
use of net.imglib2.algorithm.neighborhood.Shape in project imagej-ops by imagej.
the class NonLinearFiltersTest method testMaxFilter.
/**
* @see MaxFilterOp
* @see DefaultMaxFilter
*/
@Test
public void testMaxFilter() {
ops.run(MaxFilterOp.class, out, in, shape, oobFactory);
byte max = Byte.MIN_VALUE;
NeighborhoodsIterableInterval<ByteType> neighborhoods = shape.neighborhoods(Views.interval(Views.extendMirrorSingle(in), in));
for (ByteType t : neighborhoods.firstElement()) {
max = (byte) Math.max(t.getInteger(), max);
}
assertEquals(out.firstElement().get(), max);
}
use of net.imglib2.algorithm.neighborhood.Shape in project imagej-ops by imagej.
the class NonLinearFiltersTest method testMinFilter.
/**
* @see MinFilterOp
* @see DefaultMinFilter
*/
@Test
public void testMinFilter() {
ops.run(MinFilterOp.class, out, in, shape, oobFactory);
byte min = Byte.MAX_VALUE;
NeighborhoodsIterableInterval<ByteType> neighborhoods = shape.neighborhoods(Views.interval(Views.extendMirrorSingle(in), in));
for (ByteType t : neighborhoods.firstElement()) {
min = (byte) Math.min(t.getInteger(), min);
}
assertEquals(min, out.firstElement().get());
}
Aggregations