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