Search in sources :

Example 1 with MaskData

use of omero.gateway.model.MaskData in project simple-omero-client by GReD-Clermont.

the class ShapeTest method testMaskConstructor.

@Test
public void testMaskConstructor() {
    final byte[] maskValues = new byte[25];
    for (int i = 0; i < maskValues.length; i++) {
        maskValues[i] = (byte) (i >= maskValues.length / 2 ? 1 : 0);
    }
    MaskWrapper m1 = new MaskWrapper(10, 10, 5, 5, maskValues);
    MaskWrapper m2 = new MaskWrapper(new MaskData(0, 0, 5, 5, maskValues));
    m1.setCoordinates(0, 0, 5, 5);
    double[] coordinates1 = m1.getCoordinates();
    double[] coordinates2 = m2.getCoordinates();
    byte[] checkValues1 = m1.getMask();
    byte[] checkValues2 = m2.getMask();
    int differences = 0;
    for (int i = 0; i < 4; i++) differences = (int) (differences + Math.abs(coordinates1[i] - coordinates2[i]));
    for (int i = 0; i < maskValues.length; i++) differences += Math.abs(checkValues2[i] - checkValues1[i]);
    assertEquals(0, differences, Double.MIN_VALUE);
}
Also used : MaskData(omero.gateway.model.MaskData) BasicTest(fr.igred.omero.BasicTest) Test(org.junit.Test)

Example 2 with MaskData

use of omero.gateway.model.MaskData in project imagej-omero by imagej.

the class CompositeMaskPredicateToMaskData method testXor.

@Test
public void testXor() {
    final Ellipsoid e = GeomMasks.closedEllipsoid(new double[] { 30, 25 }, new double[] { 15, 20 });
    final Sphere s = GeomMasks.closedSphere(new double[] { 14, 14 }, 13);
    final RealMaskRealInterval xor = e.xor(s);
    final Converter<?, ?> c = convert.getHandler(xor, MaskData.class);
    assertTrue(c instanceof RealMaskRealIntervalToMaskData);
    final MaskData md = c.convert(xor, MaskData.class);
    final RandomAccessibleInterval<BoolType> rai = Views.interval(Views.raster(Masks.toRealRandomAccessibleRealInterval(xor)), Intervals.smallestContainingInterval(xor));
    assertIsEqual(rai, md);
    assertEquals(ROIConverters.UNSPECIFIED_BOUNDARY_TEXT, md.getText());
}
Also used : Sphere(net.imglib2.roi.geom.real.Sphere) BoolType(net.imglib2.type.logic.BoolType) RealMaskRealInterval(net.imglib2.roi.RealMaskRealInterval) Ellipsoid(net.imglib2.roi.geom.real.Ellipsoid) MaskData(omero.gateway.model.MaskData) Test(org.junit.Test)

Example 3 with MaskData

use of omero.gateway.model.MaskData in project imagej-omero by imagej.

the class CompositeMaskPredicateToMaskData method testAnd.

@Test
public void testAnd() {
    final Box b = GeomMasks.closedBox(new double[] { 0, 0 }, new double[] { 20, 20 });
    final Box b2 = GeomMasks.closedBox(new double[] { 10, 10 }, new double[] { 30, 30 });
    final RealMaskRealInterval and = b.and(b2);
    final Converter<?, ?> c = convert.getHandler(and, MaskData.class);
    assertTrue(c instanceof RealMaskRealIntervalToMaskData);
    final MaskData md = c.convert(and, MaskData.class);
    final RandomAccessibleInterval<BoolType> rai = Views.interval(Views.raster(Masks.toRealRandomAccessibleRealInterval(and)), Intervals.smallestContainingInterval(and));
    assertIsEqual(rai, md);
    assertEquals(ROIConverters.CLOSED_BOUNDARY_TEXT, md.getText());
}
Also used : BoolType(net.imglib2.type.logic.BoolType) Box(net.imglib2.roi.geom.real.Box) RealMaskRealInterval(net.imglib2.roi.RealMaskRealInterval) MaskData(omero.gateway.model.MaskData) Test(org.junit.Test)

Example 4 with MaskData

use of omero.gateway.model.MaskData in project imagej-omero by imagej.

the class CompositeMaskPredicateToMaskData method testMinus.

@Test
public void testMinus() {
    final Sphere s = GeomMasks.closedSphere(new double[] { 30, 30 }, 5);
    final Sphere s2 = GeomMasks.closedSphere(new double[] { 30, 30 }, 2);
    final RealMaskRealInterval minus = s.minus(s2);
    final Converter<?, ?> c = convert.getHandler(minus, MaskData.class);
    assertTrue(c instanceof RealMaskRealIntervalToMaskData);
    final MaskData md = c.convert(minus, MaskData.class);
    final RandomAccessibleInterval<BoolType> rai = Views.interval(Views.raster(Masks.toRealRandomAccessibleRealInterval(minus)), Intervals.smallestContainingInterval(minus));
    assertIsEqual(rai, md);
    assertEquals(ROIConverters.UNSPECIFIED_BOUNDARY_TEXT, md.getText());
}
Also used : Sphere(net.imglib2.roi.geom.real.Sphere) BoolType(net.imglib2.type.logic.BoolType) RealMaskRealInterval(net.imglib2.roi.RealMaskRealInterval) MaskData(omero.gateway.model.MaskData) Test(org.junit.Test)

Example 5 with MaskData

use of omero.gateway.model.MaskData in project imagej-omero by imagej.

the class CompositeMaskPredicateToMaskData method testMultipleOperands.

@Test
public void testMultipleOperands() {
    final Ellipsoid e = GeomMasks.closedEllipsoid(new double[] { 30, 25 }, new double[] { 15, 20 });
    final Sphere s = GeomMasks.closedSphere(new double[] { 14, 14 }, 13);
    final Box b = GeomMasks.closedBox(new double[] { 0, 0 }, new double[] { 5, 6 });
    final AffineTransform2D transform = new AffineTransform2D();
    transform.rotate(Math.PI / 3);
    final RealMaskRealInterval rmri = e.or(s.xor(b.transform(transform.inverse())));
    final Converter<?, ?> c = convert.getHandler(rmri, ShapeData.class);
    assertTrue(c instanceof RealMaskRealIntervalToMaskData);
    final MaskData md = c.convert(rmri, MaskData.class);
    final RandomAccessibleInterval<BoolType> rai = Views.interval(Views.raster(Masks.toRealRandomAccessibleRealInterval(rmri)), Intervals.smallestContainingInterval(rmri));
    assertIsEqual(rai, md);
    // NB: transform is only preserved if it is the only operation
    assertNull(md.getTransform());
    assertEquals(ROIConverters.UNSPECIFIED_BOUNDARY_TEXT, md.getText());
}
Also used : Sphere(net.imglib2.roi.geom.real.Sphere) BoolType(net.imglib2.type.logic.BoolType) Box(net.imglib2.roi.geom.real.Box) RealMaskRealInterval(net.imglib2.roi.RealMaskRealInterval) Ellipsoid(net.imglib2.roi.geom.real.Ellipsoid) AffineTransform2D(net.imglib2.realtransform.AffineTransform2D) MaskData(omero.gateway.model.MaskData) Test(org.junit.Test)

Aggregations

MaskData (omero.gateway.model.MaskData)18 Test (org.junit.Test)13 RealMaskRealInterval (net.imglib2.roi.RealMaskRealInterval)7 BoolType (net.imglib2.type.logic.BoolType)6 FinalInterval (net.imglib2.FinalInterval)5 MaskInterval (net.imglib2.roi.MaskInterval)4 DefaultMaskInterval (net.imglib2.roi.mask.integer.DefaultMaskInterval)4 Point (net.imglib2.Point)3 RealPoint (net.imglib2.RealPoint)3 Box (net.imglib2.roi.geom.real.Box)3 Sphere (net.imglib2.roi.geom.real.Sphere)3 Ellipsoid (net.imglib2.roi.geom.real.Ellipsoid)2 BasicTest (fr.igred.omero.BasicTest)1 Interval (net.imglib2.Interval)1 RandomAccessibleInterval (net.imglib2.RandomAccessibleInterval)1 AffineTransform2D (net.imglib2.realtransform.AffineTransform2D)1 RealMask (net.imglib2.roi.RealMask)1 EllipseData (omero.gateway.model.EllipseData)1 LineData (omero.gateway.model.LineData)1 PointData (omero.gateway.model.PointData)1