Search in sources :

Example 6 with ImageLabelingModel

use of sc.fiji.labkit.ui.models.ImageLabelingModel 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)

Example 7 with ImageLabelingModel

use of sc.fiji.labkit.ui.models.ImageLabelingModel in project labkit-ui by juglab.

the class LabelPanelDemo method main.

public static void main(String... args) {
    Img<? extends NumericType<?>> image = ArrayImgs.unsignedBytes(10, 10);
    ImageLabelingModel imageLabeling = new ImageLabelingModel(new DatasetInputImage(image));
    ColoredLabelsModel model = new ColoredLabelsModel(imageLabeling);
    LabelPanel panel = new LabelPanel(null, model, true, ignore -> new JPopupMenu());
    showInFrame(panel.getComponent());
}
Also used : ImageLabelingModel(sc.fiji.labkit.ui.models.ImageLabelingModel) DatasetInputImage(sc.fiji.labkit.ui.inputimage.DatasetInputImage) ColoredLabelsModel(sc.fiji.labkit.ui.models.ColoredLabelsModel)

Example 8 with ImageLabelingModel

use of sc.fiji.labkit.ui.models.ImageLabelingModel 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)

Example 9 with ImageLabelingModel

use of sc.fiji.labkit.ui.models.ImageLabelingModel in project labkit-ui by juglab.

the class LabelingComponentHdf5Demo method initLabelingComponent.

private static JComponent initLabelingComponent(JFrame frame, String filename) {
    ImageLabelingModel model = new ImageLabelingModel(new SpimDataInputImage(filename, 0));
    LabelingComponent labelingComponent = new LabelingComponent(frame, model);
    frame.addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent e) {
            labelingComponent.close();
        }
    });
    return labelingComponent;
}
Also used : ImageLabelingModel(sc.fiji.labkit.ui.models.ImageLabelingModel) LabelingComponent(sc.fiji.labkit.ui.LabelingComponent) BasicLabelingComponent(sc.fiji.labkit.ui.BasicLabelingComponent) WindowEvent(java.awt.event.WindowEvent) WindowAdapter(java.awt.event.WindowAdapter) SpimDataInputImage(sc.fiji.labkit.ui.inputimage.SpimDataInputImage)

Example 10 with ImageLabelingModel

use of sc.fiji.labkit.ui.models.ImageLabelingModel in project labkit-ui by juglab.

the class SegmentationComponent method initActions.

private void initActions() {
    final Holder<SegmentationItem> selectedSegmenter = segmentationModel.segmenterList().selectedSegmenter();
    final ImageLabelingModel labelingModel = segmentationModel.imageLabelingModel();
    new TrainClassifier(extensible, segmentationModel.segmenterList());
    new ClassifierSettingsAction(extensible, segmentationModel.segmenterList());
    new ClassifierIoAction(extensible, segmentationModel.segmenterList());
    new LabelingIoAction(extensible, labelingModel);
    new AddLabelingIoAction(extensible, labelingModel.labeling());
    new SegmentationExportAction(extensible, labelingModel);
    new ResetViewAction(extensible, labelingModel);
    new BatchSegmentAction(extensible, selectedSegmenter);
    new SegmentationAsLabelAction(extensible, segmentationModel);
    new BitmapImportExportAction(extensible, labelingModel);
    new LabelEditAction(extensible, unmodifiableLabels, new ColoredLabelsModel(labelingModel));
    MeasureConnectedComponents.addAction(extensible, labelingModel);
    new ShowHelpAction(extensible);
    labelingComponent.addShortcuts(extensible.getShortCuts());
}
Also used : ColoredLabelsModel(sc.fiji.labkit.ui.models.ColoredLabelsModel) ImageLabelingModel(sc.fiji.labkit.ui.models.ImageLabelingModel) SegmentationItem(sc.fiji.labkit.ui.models.SegmentationItem) TrainClassifier(sc.fiji.labkit.ui.segmentation.TrainClassifier)

Aggregations

ImageLabelingModel (sc.fiji.labkit.ui.models.ImageLabelingModel)10 DatasetInputImage (sc.fiji.labkit.ui.inputimage.DatasetInputImage)5 SegmentationItem (sc.fiji.labkit.ui.models.SegmentationItem)4 ColoredLabelsModel (sc.fiji.labkit.ui.models.ColoredLabelsModel)3 ImagePlus (ij.ImagePlus)2 ShortType (net.imglib2.type.numeric.integer.ShortType)2 Labeling (sc.fiji.labkit.ui.labeling.Labeling)2 TrainClassifier (sc.fiji.labkit.ui.segmentation.TrainClassifier)2 WindowAdapter (java.awt.event.WindowAdapter)1 WindowEvent (java.awt.event.WindowEvent)1 ImgPlus (net.imagej.ImgPlus)1 FinalInterval (net.imglib2.FinalInterval)1 UnsignedByteType (net.imglib2.type.numeric.integer.UnsignedByteType)1 ValuePair (net.imglib2.util.ValuePair)1 Test (org.junit.Test)1 Context (org.scijava.Context)1 BasicLabelingComponent (sc.fiji.labkit.ui.BasicLabelingComponent)1 LabelingComponent (sc.fiji.labkit.ui.LabelingComponent)1 AddLabelingIoAction (sc.fiji.labkit.ui.actions.AddLabelingIoAction)1 BatchSegmentAction (sc.fiji.labkit.ui.actions.BatchSegmentAction)1