Search in sources :

Example 16 with Labeling

use of sc.fiji.labkit.ui.labeling.Labeling in project labkit-ui by juglab.

the class TrainableSegmentationSegmenterTest method initLabeling.

private Labeling initLabeling() {
    Labeling labeling = Labeling.createEmpty(Arrays.asList("a", "b"), new FinalInterval(2, 1, 2));
    RandomAccess<LabelingType<Label>> ra = labeling.randomAccess();
    ra.setPosition(new long[] { 0, 0, 0 });
    ra.get().add(labeling.getLabel("a"));
    ra.setPosition(new long[] { 1, 0, 0 });
    ra.get().add(labeling.getLabel("b"));
    return labeling;
}
Also used : FinalInterval(net.imglib2.FinalInterval) Labeling(sc.fiji.labkit.ui.labeling.Labeling) LabelingType(net.imglib2.roi.labeling.LabelingType)

Example 17 with Labeling

use of sc.fiji.labkit.ui.labeling.Labeling in project labkit-ui by juglab.

the class SegmentationUseCaseTest method addLabels.

private void addLabels(ImageLabelingModel imageLabelingModel) {
    Labeling labeling = imageLabelingModel.labeling().get();
    RandomAccess<LabelingType<Label>> ra = labeling.randomAccess();
    ra.setPosition(new long[] { 0, 0 });
    ra.get().add(labeling.getLabel("foreground"));
    ra.setPosition(new long[] { 0, 1 });
    ra.get().add(labeling.getLabel("background"));
}
Also used : Labeling(sc.fiji.labkit.ui.labeling.Labeling) LabelingType(net.imglib2.roi.labeling.LabelingType)

Example 18 with Labeling

use of sc.fiji.labkit.ui.labeling.Labeling in project labkit-ui by juglab.

the class SegmentationUseCaseTest method getLabeling.

private Labeling getLabeling() {
    List<String> labels = Arrays.asList("b", "f");
    Interval interval = new FinalInterval(2, 2);
    Labeling labeling = Labeling.createEmpty(labels, interval);
    RandomAccess<LabelingType<Label>> ra = labeling.randomAccess();
    ra.setPosition(new long[] { 0, 0 });
    ra.get().add(labeling.getLabel("f"));
    ra.setPosition(new long[] { 1, 0 });
    ra.get().add(labeling.getLabel("b"));
    ra.setPosition(new long[] { 0, 1 });
    ra.get().add(labeling.getLabel("b"));
    ra.setPosition(new long[] { 1, 1 });
    ra.get().add(labeling.getLabel("b"));
    return labeling;
}
Also used : FinalInterval(net.imglib2.FinalInterval) Labeling(sc.fiji.labkit.ui.labeling.Labeling) RandomAccessibleInterval(net.imglib2.RandomAccessibleInterval) FinalInterval(net.imglib2.FinalInterval) Interval(net.imglib2.Interval) LabelingType(net.imglib2.roi.labeling.LabelingType)

Example 19 with Labeling

use of sc.fiji.labkit.ui.labeling.Labeling in project labkit-ui by juglab.

the class FloodFillTest method test3.

@Test
public void test3() {
    Labeling labeling = Labeling.fromImgLabeling(exampleImgLabeling());
    final Point seed = new Point(2, 2);
    Label a = labeling.getLabel("a");
    Label b = labeling.getLabel("b");
    Label c = labeling.getLabel("c");
    c.setVisible(false);
    Label ab = labeling.addLabel("ab");
    final Consumer<Set<Label>> operation = l -> l.add(ab);
    FloodFill.doFloodFillOnActiveLabels((RandomAccessibleInterval) labeling, seed, operation);
    assertLabelEqualsInterval(labeling, intervalA, a);
    assertLabelEqualsInterval(labeling, intervalB, b);
    assertLabelEqualsInterval(labeling, intervalC, c);
    assertLabelEqualsInterval(labeling, intervalAintersectB, ab);
}
Also used : BitType(net.imglib2.type.logic.BitType) Point(net.imglib2.Point) Predicate(java.util.function.Predicate) Set(java.util.Set) Test(org.junit.Test) Consumer(java.util.function.Consumer) Intervals(net.imglib2.util.Intervals) Cursor(net.imglib2.Cursor) RandomAccessibleInterval(net.imglib2.RandomAccessibleInterval) Labeling(sc.fiji.labkit.ui.labeling.Labeling) LabelingType(net.imglib2.roi.labeling.LabelingType) ArrayImgs(net.imglib2.img.array.ArrayImgs) ImgLabeling(net.imglib2.roi.labeling.ImgLabeling) Interval(net.imglib2.Interval) Label(sc.fiji.labkit.ui.labeling.Label) Views(net.imglib2.view.Views) Assert.assertEquals(org.junit.Assert.assertEquals) Set(java.util.Set) Label(sc.fiji.labkit.ui.labeling.Label) Point(net.imglib2.Point) Labeling(sc.fiji.labkit.ui.labeling.Labeling) ImgLabeling(net.imglib2.roi.labeling.ImgLabeling) Test(org.junit.Test)

Example 20 with Labeling

use of sc.fiji.labkit.ui.labeling.Labeling in project labkit-ui by juglab.

the class LabeledImage method snapshot.

/**
 * Returns an up to date {@link ImageLabelingModel}. But doesn't guarantee for
 * changes to be tracked, or to keep the reference.
 */
public ImageLabelingModel snapshot() {
    if (imageLabelingModel != null)
        return imageLabelingModel;
    DatasetInputImage inputImage = openInputImage();
    inputImage.setDefaultLabelingFilename(modifiedLabelingFile);
    Labeling labeling = openOrEmptyLabeling(storedIn.get(), inputImage.imageForSegmentation());
    ImageLabelingModel imageLabelingModel = new ImageLabelingModel(inputImage);
    imageLabelingModel.labeling().set(labeling);
    return imageLabelingModel;
}
Also used : ImageLabelingModel(sc.fiji.labkit.ui.models.ImageLabelingModel) DatasetInputImage(sc.fiji.labkit.ui.inputimage.DatasetInputImage) Labeling(sc.fiji.labkit.ui.labeling.Labeling)

Aggregations

Labeling (sc.fiji.labkit.ui.labeling.Labeling)26 LabelingType (net.imglib2.roi.labeling.LabelingType)8 Label (sc.fiji.labkit.ui.labeling.Label)8 FinalInterval (net.imglib2.FinalInterval)7 BitType (net.imglib2.type.logic.BitType)7 Test (org.junit.Test)7 Context (org.scijava.Context)7 ImgPlus (net.imagej.ImgPlus)6 Interval (net.imglib2.Interval)6 Cursor (net.imglib2.Cursor)5 RandomAccessibleInterval (net.imglib2.RandomAccessibleInterval)5 DatasetInputImage (sc.fiji.labkit.ui.inputimage.DatasetInputImage)5 File (java.io.File)4 List (java.util.List)4 Intervals (net.imglib2.util.Intervals)4 ValuePair (net.imglib2.util.ValuePair)4 Views (net.imglib2.view.Views)4 ArrayList (java.util.ArrayList)3 Set (java.util.Set)3 Collectors (java.util.stream.Collectors)3