Search in sources :

Example 11 with Shape

use of net.imglib2.algorithm.neighborhood.Shape in project imagej-ops by imagej.

the class ErosionTest method testListErodeFull.

@Test
public void testListErodeFull() {
    final List<Shape> shapes = new ArrayList<>();
    shapes.add(new DiamondShape(1));
    shapes.add(new DiamondShape(1));
    shapes.add(new RectangleShape(1, false));
    shapes.add(new HorizontalLineShape(2, 1, false));
    final Img<ByteType> out2 = Erosion.erodeFull(in, shapes, 1);
    @SuppressWarnings("unchecked") final IterableInterval<ByteType> out1 = (IterableInterval<ByteType>) ops.run(ListErode.class, IterableInterval.class, in, shapes, true);
    assertIterationsEqual(out1, out2);
}
Also used : DiamondShape(net.imglib2.algorithm.neighborhood.DiamondShape) Shape(net.imglib2.algorithm.neighborhood.Shape) RectangleShape(net.imglib2.algorithm.neighborhood.RectangleShape) HorizontalLineShape(net.imglib2.algorithm.neighborhood.HorizontalLineShape) RectangleShape(net.imglib2.algorithm.neighborhood.RectangleShape) DiamondShape(net.imglib2.algorithm.neighborhood.DiamondShape) ArrayList(java.util.ArrayList) IterableInterval(net.imglib2.IterableInterval) ByteType(net.imglib2.type.numeric.integer.ByteType) HorizontalLineShape(net.imglib2.algorithm.neighborhood.HorizontalLineShape) AbstractOpTest(net.imagej.ops.AbstractOpTest) Test(org.junit.Test)

Example 12 with Shape

use of net.imglib2.algorithm.neighborhood.Shape in project imagej-ops by imagej.

the class ErosionTest method testListErode.

// @Test
public void testListErode() {
    final List<Shape> shapes = new ArrayList<>();
    shapes.add(new DiamondShape(1));
    shapes.add(new DiamondShape(1));
    shapes.add(new RectangleShape(1, false));
    shapes.add(new HorizontalLineShape(2, 1, false));
    final Img<ByteType> out2 = in.copy();
    Erosion.erode(Views.extendValue(in, new ByteType((byte) -128)), out2, shapes, 1);
    @SuppressWarnings("unchecked") final IterableInterval<ByteType> out1 = (IterableInterval<ByteType>) ops.run(ListErode.class, IterableInterval.class, in, shapes, false);
    assertIterationsEqual(out1, out2);
}
Also used : DiamondShape(net.imglib2.algorithm.neighborhood.DiamondShape) Shape(net.imglib2.algorithm.neighborhood.Shape) RectangleShape(net.imglib2.algorithm.neighborhood.RectangleShape) HorizontalLineShape(net.imglib2.algorithm.neighborhood.HorizontalLineShape) RectangleShape(net.imglib2.algorithm.neighborhood.RectangleShape) DiamondShape(net.imglib2.algorithm.neighborhood.DiamondShape) ArrayList(java.util.ArrayList) IterableInterval(net.imglib2.IterableInterval) ByteType(net.imglib2.type.numeric.integer.ByteType) HorizontalLineShape(net.imglib2.algorithm.neighborhood.HorizontalLineShape)

Example 13 with Shape

use of net.imglib2.algorithm.neighborhood.Shape in project imagej-ops by imagej.

the class OpeningTest method testSingleOpen.

@Test
public void testSingleOpen() {
    final Shape shape = new DiamondShape(1);
    final List<Shape> shapes = Arrays.asList(shape);
    @SuppressWarnings("unchecked") final Img<ByteType> out1 = (Img<ByteType>) ops.run(ListOpen.class, Img.class, in, shapes);
    final Img<ByteType> out2 = Opening.open(in, shape, 1);
    assertIterationsEqual(out2, out1);
}
Also used : Img(net.imglib2.img.Img) DiamondShape(net.imglib2.algorithm.neighborhood.DiamondShape) Shape(net.imglib2.algorithm.neighborhood.Shape) RectangleShape(net.imglib2.algorithm.neighborhood.RectangleShape) HorizontalLineShape(net.imglib2.algorithm.neighborhood.HorizontalLineShape) DiamondShape(net.imglib2.algorithm.neighborhood.DiamondShape) ByteType(net.imglib2.type.numeric.integer.ByteType) AbstractOpTest(net.imagej.ops.AbstractOpTest) Test(org.junit.Test)

Example 14 with Shape

use of net.imglib2.algorithm.neighborhood.Shape in project imagej-ops by imagej.

the class TopHatTest method testSingleTopHat.

@Test
public void testSingleTopHat() {
    final Shape shape = new DiamondShape(1);
    final List<Shape> shapes = Arrays.asList(shape);
    @SuppressWarnings("unchecked") final Img<ByteType> out1 = (Img<ByteType>) ops.run(ListTopHat.class, Img.class, in, shapes);
    final Img<ByteType> out2 = TopHat.topHat(in, shape, 1);
    assertIterationsEqual(out2, out1);
}
Also used : Img(net.imglib2.img.Img) DiamondShape(net.imglib2.algorithm.neighborhood.DiamondShape) Shape(net.imglib2.algorithm.neighborhood.Shape) RectangleShape(net.imglib2.algorithm.neighborhood.RectangleShape) HorizontalLineShape(net.imglib2.algorithm.neighborhood.HorizontalLineShape) DiamondShape(net.imglib2.algorithm.neighborhood.DiamondShape) ByteType(net.imglib2.type.numeric.integer.ByteType) AbstractOpTest(net.imagej.ops.AbstractOpTest) Test(org.junit.Test)

Example 15 with Shape

use of net.imglib2.algorithm.neighborhood.Shape in project imagej-ops by imagej.

the class NonLinearFiltersTest method testMeanFilter.

/**
 * @see MeanFilterOp
 * @see DefaultMeanFilter
 */
@Test
public void testMeanFilter() {
    ops.run(MeanFilterOp.class, out, in, shape, oobFactory);
    double sum = 0.0;
    NeighborhoodsIterableInterval<ByteType> neighborhoods = shape.neighborhoods(Views.interval(Views.extendMirrorSingle(in), in));
    for (ByteType t : neighborhoods.firstElement()) {
        sum += t.getRealDouble();
    }
    assertEquals(Util.round(sum / 9.0), 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