Search in sources :

Example 26 with RectangleShape

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

the class DilationTest method testListDilateFull.

@Test
public void testListDilateFull() {
    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));
    @SuppressWarnings("unchecked") final IterableInterval<ByteType> out1 = (IterableInterval<ByteType>) ops.run(ListDilate.class, IterableInterval.class, in, shapes, true);
    final Img<ByteType> out2 = Dilation.dilateFull(in, shapes, 1);
    final Cursor<ByteType> c1 = out1.cursor();
    final Cursor<ByteType> c2 = out2.cursor();
    while (c1.hasNext()) assertEquals(c1.next().get(), c2.next().get());
}
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) DiamondShape(net.imglib2.algorithm.neighborhood.DiamondShape) ArrayList(java.util.ArrayList) ByteType(net.imglib2.type.numeric.integer.ByteType) HorizontalLineShape(net.imglib2.algorithm.neighborhood.HorizontalLineShape) RectangleShape(net.imglib2.algorithm.neighborhood.RectangleShape) IterableInterval(net.imglib2.IterableInterval) AbstractOpTest(net.imagej.ops.AbstractOpTest) Test(org.junit.Test)

Example 27 with RectangleShape

use of net.imglib2.algorithm.neighborhood.RectangleShape 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 28 with RectangleShape

use of net.imglib2.algorithm.neighborhood.RectangleShape 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 29 with RectangleShape

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

the class NonLinearFiltersTest method before.

/**
 * Initialize images.
 *
 * @throws Exception
 */
@Before
public void before() throws Exception {
    in = generateByteArrayTestImg(true, new long[] { 10, 10 });
    out = generateByteArrayTestImg(false, new long[] { 10, 10 });
    shape = new RectangleShape(1, false);
}
Also used : RectangleShape(net.imglib2.algorithm.neighborhood.RectangleShape) Before(org.junit.Before)

Example 30 with RectangleShape

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

the class IntegralCursorTest method testIntegralCursor.

@SuppressWarnings({ "unchecked", "rawtypes" })
@Test
public void testIntegralCursor() {
    Shape rectangleShape = new RectangleShape(1, false);
    IterableInterval<Neighborhood<ByteType>> ii = rectangleShape.neighborhoodsSafe(img);
    Cursor<Neighborhood<ByteType>> cursor = ii.cursor();
    // Manually select the neighborhood that is centered on the image
    cursor.fwd();
    cursor.fwd();
    cursor.fwd();
    cursor.fwd();
    cursor.fwd();
    IntegralCursor<ByteType> integralCursor = new IntegralCursor<>((RectangleNeighborhood) cursor.get());
    assertEquals(integralCursor.next(), new ByteType((byte) 1));
    assertEquals(integralCursor.next(), new ByteType((byte) 2));
    assertEquals(integralCursor.next(), new ByteType((byte) 5));
    assertEquals(integralCursor.next(), new ByteType((byte) 4));
    assertFalse(integralCursor.hasNext());
    integralCursor.reset();
    assertEquals(integralCursor.next(), new ByteType((byte) 1));
    assertEquals(integralCursor.next(), new ByteType((byte) 2));
    assertEquals(integralCursor.next(), new ByteType((byte) 5));
    assertEquals(integralCursor.next(), new ByteType((byte) 4));
    assertFalse(integralCursor.hasNext());
}
Also used : Shape(net.imglib2.algorithm.neighborhood.Shape) RectangleShape(net.imglib2.algorithm.neighborhood.RectangleShape) RectangleShape(net.imglib2.algorithm.neighborhood.RectangleShape) ByteType(net.imglib2.type.numeric.integer.ByteType) Neighborhood(net.imglib2.algorithm.neighborhood.Neighborhood) RectangleNeighborhood(net.imglib2.algorithm.neighborhood.RectangleNeighborhood) Test(org.junit.Test)

Aggregations

RectangleShape (net.imglib2.algorithm.neighborhood.RectangleShape)53 ByteType (net.imglib2.type.numeric.integer.ByteType)47 Test (org.junit.Test)46 AbstractOpTest (net.imagej.ops.AbstractOpTest)44 Img (net.imglib2.img.Img)34 ArrayImg (net.imglib2.img.array.ArrayImg)33 Shape (net.imglib2.algorithm.neighborhood.Shape)12 ArrayList (java.util.ArrayList)11 DiamondShape (net.imglib2.algorithm.neighborhood.DiamondShape)11 IterableInterval (net.imglib2.IterableInterval)9 HorizontalLineShape (net.imglib2.algorithm.neighborhood.HorizontalLineShape)8 BitType (net.imglib2.type.logic.BitType)5 RandomAccessibleInterval (net.imglib2.RandomAccessibleInterval)4 Neighborhood (net.imglib2.algorithm.neighborhood.Neighborhood)4 IncompatibleTypeException (net.imglib2.exception.IncompatibleTypeException)4 Op (net.imagej.ops.Op)3 AbstractUnaryComputerOp (net.imagej.ops.special.computer.AbstractUnaryComputerOp)3 RandomAccess (net.imglib2.RandomAccess)2 RectangleNeighborhood (net.imglib2.algorithm.neighborhood.RectangleNeighborhood)2 LabelingType (net.imglib2.roi.labeling.LabelingType)2