diff --git a/src/main/java/net/imglib2/roi/labeling/ImgLabeling.java b/src/main/java/net/imglib2/roi/labeling/ImgLabeling.java index 2184d407..7ae615f7 100644 --- a/src/main/java/net/imglib2/roi/labeling/ImgLabeling.java +++ b/src/main/java/net/imglib2/roi/labeling/ImgLabeling.java @@ -243,7 +243,7 @@ public LabelingType< T > firstElement() @Override public LabelingType< T > getType() { - return new LabelingType<>( null, mapping, generation ); + return new LabelingType<>( indexAccessible.getType(), mapping, generation ); } @Override diff --git a/src/test/java/net/imglib2/roi/labeling/ImgLabelingTest.java b/src/test/java/net/imglib2/roi/labeling/ImgLabelingTest.java index d0ad40a6..7f1dc203 100644 --- a/src/test/java/net/imglib2/roi/labeling/ImgLabelingTest.java +++ b/src/test/java/net/imglib2/roi/labeling/ImgLabelingTest.java @@ -34,6 +34,7 @@ package net.imglib2.roi.labeling; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import java.util.Arrays; @@ -174,4 +175,14 @@ public void testHashCodeAndEquals() assertTrue( pixel.equals( expected ) ); assertEquals( expected.hashCode(), pixel.hashCode() ); } + + @Test + public void testGetType() + { + ImgLabeling< String, IntType > imgLabeling = new ImgLabeling<>( ArrayImgs.ints( 10, 10 ) ); + LabelingType< String > type = imgLabeling.getType().createVariable(); + type.clear(); + type.add( "A" ); + assertEquals( Collections.singleton( "A" ), type ); + } }