Search in sources :

Example 1 with DatasetInputImage

use of sc.fiji.labkit.ui.inputimage.DatasetInputImage in project labkit-ui by juglab.

the class ChangingImageSegmentationComponentDemo method onChangeImageButtonClicked.

private static void onChangeImageButtonClicked(SegmentationModel segmentationModel) {
    final ImagePlus imp = new ImagePlus("https://imagej.nih.gov/ij/images/apple.tif");
    ImageLabelingModel model = segmentationModel.imageLabelingModel();
    ImgPlus<?> image = VirtualStackAdapter.wrap(imp);
    DatasetInputImage datasetInputImage = new DatasetInputImage(image);
    model.showable().set(datasetInputImage.showable());
    model.imageForSegmentation().set(datasetInputImage.imageForSegmentation());
    model.labeling().set(InitialLabeling.initialLabeling(SingletonContext.getInstance(), datasetInputImage));
}
Also used : ImageLabelingModel(sc.fiji.labkit.ui.models.ImageLabelingModel) DatasetInputImage(sc.fiji.labkit.ui.inputimage.DatasetInputImage) ImagePlus(ij.ImagePlus)

Example 2 with DatasetInputImage

use of sc.fiji.labkit.ui.inputimage.DatasetInputImage in project labkit-ui by juglab.

the class LabelingComponentDemo method initModel.

private static ImageLabelingModel initModel() {
    final ImagePlus imp = new ImagePlus("https://imagej.nih.gov/ij/images/FluorescentCells.jpg");
    ImgPlus<?> image = VirtualStackAdapter.wrap(imp);
    return new ImageLabelingModel(new DatasetInputImage(image));
}
Also used : ImageLabelingModel(sc.fiji.labkit.ui.models.ImageLabelingModel) DatasetInputImage(sc.fiji.labkit.ui.inputimage.DatasetInputImage) ImagePlus(ij.ImagePlus)

Example 3 with DatasetInputImage

use of sc.fiji.labkit.ui.inputimage.DatasetInputImage in project labkit-ui by juglab.

the class MultiChannelMovieDemo method testInputImageImageForSegmentation.

@Test
public void testInputImageImageForSegmentation() {
    DatasetInputImage inputImage = inputImage5d();
    SegmentationModel segmentationModel = new DefaultSegmentationModel(new Context(), inputImage);
    SegmentationItem segmenter = segmentationModel.segmenterList().addSegmenter(PixelClassificationPlugin.create());
    Labeling labeling1 = labeling5d();
    segmentationModel.imageLabelingModel().labeling().set(labeling1);
    segmenter.train(Collections.singletonList(new ValuePair<>(inputImage.imageForSegmentation(), labeling1)));
    RandomAccessibleInterval<ShortType> result = segmenter.results(segmentationModel.imageLabelingModel()).segmentation();
    Labeling labeling = labeling5d();
    LoopBuilder.setImages(labeling, result).forEachPixel((l, r) -> {
        if (l.contains("foreground"))
            assertEquals(1, r.get());
        if (l.contains("background"))
            assertEquals(0, r.get());
    });
}
Also used : Context(org.scijava.Context) DefaultSegmentationModel(sc.fiji.labkit.ui.models.DefaultSegmentationModel) DatasetInputImage(sc.fiji.labkit.ui.inputimage.DatasetInputImage) SegmentationItem(sc.fiji.labkit.ui.models.SegmentationItem) ValuePair(net.imglib2.util.ValuePair) ShortType(net.imglib2.type.numeric.integer.ShortType) Labeling(sc.fiji.labkit.ui.labeling.Labeling) DefaultSegmentationModel(sc.fiji.labkit.ui.models.DefaultSegmentationModel) SegmentationModel(sc.fiji.labkit.ui.models.SegmentationModel) Test(org.junit.Test)

Example 4 with DatasetInputImage

use of sc.fiji.labkit.ui.inputimage.DatasetInputImage in project labkit-ui by juglab.

the class MultiChannelMovieDemo method main2.

private static void main2() {
    DatasetInputImage inputImage = inputImage5d();
    LabkitFrame.showForImage(new Context(), inputImage);
}
Also used : Context(org.scijava.Context) DatasetInputImage(sc.fiji.labkit.ui.inputimage.DatasetInputImage)

Example 5 with DatasetInputImage

use of sc.fiji.labkit.ui.inputimage.DatasetInputImage in project labkit-ui by juglab.

the class SegmentationUseCaseTest method testMultiChannel.

@Test
public void testMultiChannel() throws InterruptedException {
    Img<UnsignedByteType> img = ArrayImgs.unsignedBytes(new byte[] { -1, 0, -1, 0, -1, -1, 0, 0 }, 2, 2, 2);
    ImgPlus<UnsignedByteType> imgPlus = new ImgPlus<>(img, "Image", new AxisType[] { Axes.X, Axes.Y, Axes.CHANNEL });
    DatasetInputImage inputImage = new DatasetInputImage(imgPlus, BdvShowable.wrap(Views.hyperSlice(img, 2, 0)));
    Labeling labeling = getLabeling();
    SegmentationModel segmentationModel = new DefaultSegmentationModel(new Context(), inputImage);
    ImageLabelingModel imageLabelingModel = segmentationModel.imageLabelingModel();
    imageLabelingModel.labeling().set(labeling);
    SegmentationItem segmenter = segmentationModel.segmenterList().addSegmenter(PixelClassificationPlugin.create());
    segmenter.train(Collections.singletonList(new ValuePair<>(imgPlus, imageLabelingModel.labeling().get())));
    RandomAccessibleInterval<ShortType> result = segmenter.results(imageLabelingModel).segmentation();
    Iterator<ShortType> it = Views.iterable(result).iterator();
    assertEquals(1, it.next().get());
    assertEquals(0, it.next().get());
    assertEquals(0, it.next().get());
    assertEquals(0, it.next().get());
    assertTrue(Intervals.equals(new FinalInterval(2, 2), result));
}
Also used : Context(org.scijava.Context) ImgPlus(net.imagej.ImgPlus) DatasetInputImage(sc.fiji.labkit.ui.inputimage.DatasetInputImage) UnsignedByteType(net.imglib2.type.numeric.integer.UnsignedByteType) ValuePair(net.imglib2.util.ValuePair) ShortType(net.imglib2.type.numeric.integer.ShortType) DefaultSegmentationModel(sc.fiji.labkit.ui.models.DefaultSegmentationModel) SegmentationModel(sc.fiji.labkit.ui.models.SegmentationModel) ImageLabelingModel(sc.fiji.labkit.ui.models.ImageLabelingModel) DefaultSegmentationModel(sc.fiji.labkit.ui.models.DefaultSegmentationModel) SegmentationItem(sc.fiji.labkit.ui.models.SegmentationItem) FinalInterval(net.imglib2.FinalInterval) Labeling(sc.fiji.labkit.ui.labeling.Labeling) Test(org.junit.Test)

Aggregations

DatasetInputImage (sc.fiji.labkit.ui.inputimage.DatasetInputImage)25 Context (org.scijava.Context)10 Test (org.junit.Test)7 UnsignedByteType (net.imglib2.type.numeric.integer.UnsignedByteType)6 ImagePlus (ij.ImagePlus)5 DefaultSegmentationModel (sc.fiji.labkit.ui.models.DefaultSegmentationModel)5 ShortType (net.imglib2.type.numeric.integer.ShortType)4 ValuePair (net.imglib2.util.ValuePair)4 Labeling (sc.fiji.labkit.ui.labeling.Labeling)4 ImageLabelingModel (sc.fiji.labkit.ui.models.ImageLabelingModel)4 SegmentationModel (sc.fiji.labkit.ui.models.SegmentationModel)4 ImgPlus (net.imagej.ImgPlus)3 AxisType (net.imagej.axis.AxisType)3 SegmentationItem (sc.fiji.labkit.ui.models.SegmentationItem)3 File (java.io.File)2 IOException (java.io.IOException)2 ARGBType (net.imglib2.type.numeric.ARGBType)2 ProgressWriter (bdv.export.ProgressWriter)1 ProgressWriterConsole (bdv.export.ProgressWriterConsole)1 AbstractSource (bdv.util.AbstractSource)1