Search in sources :

Example 31 with Shape

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());
}
Also used : RectangleShape(net.imglib2.algorithm.neighborhood.RectangleShape)

Example 32 with Shape

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());
}
Also used : ByteType(net.imglib2.type.numeric.integer.ByteType) AbstractOpTest(net.imagej.ops.AbstractOpTest) Test(org.junit.Test)

Example 33 with Shape

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);
}
Also used : ByteType(net.imglib2.type.numeric.integer.ByteType) AbstractOpTest(net.imagej.ops.AbstractOpTest) Test(org.junit.Test)

Example 34 with Shape

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());
}
Also used : ByteType(net.imglib2.type.numeric.integer.ByteType) AbstractOpTest(net.imagej.ops.AbstractOpTest) Test(org.junit.Test)

Aggregations

RectangleShape (net.imglib2.algorithm.neighborhood.RectangleShape)26 ByteType (net.imglib2.type.numeric.integer.ByteType)24 Test (org.junit.Test)24 Shape (net.imglib2.algorithm.neighborhood.Shape)23 AbstractOpTest (net.imagej.ops.AbstractOpTest)22 DiamondShape (net.imglib2.algorithm.neighborhood.DiamondShape)20 HorizontalLineShape (net.imglib2.algorithm.neighborhood.HorizontalLineShape)18 ArrayList (java.util.ArrayList)12 IterableInterval (net.imglib2.IterableInterval)11 Img (net.imglib2.img.Img)11 RandomAccessibleInterval (net.imglib2.RandomAccessibleInterval)5 Neighborhood (net.imglib2.algorithm.neighborhood.Neighborhood)4 BitType (net.imglib2.type.logic.BitType)4 FinalInterval (net.imglib2.FinalInterval)3 Interval (net.imglib2.Interval)3 RandomAccess (net.imglib2.RandomAccess)2 RectangleNeighborhood (net.imglib2.algorithm.neighborhood.RectangleNeighborhood)2 LabelingType (net.imglib2.roi.labeling.LabelingType)2 IntType (net.imglib2.type.numeric.integer.IntType)2 ExtendedRandomAccessibleInterval (net.imglib2.view.ExtendedRandomAccessibleInterval)2