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);
}
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());
}
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());
}
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());
}
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());
}
Aggregations