Search in sources :

Example 1 with ImageLabelingModel

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

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

the class CustomizedSegmentationComponentDemo 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, false, new ColoredLabelsModel(labelingModel));
    MeasureConnectedComponents.addAction(extensible, labelingModel);
    labelingComponent.addShortcuts(extensible.getShortCuts());
}
Also used : ResetViewAction(sc.fiji.labkit.ui.actions.ResetViewAction) LabelEditAction(sc.fiji.labkit.ui.actions.LabelEditAction) ColoredLabelsModel(sc.fiji.labkit.ui.models.ColoredLabelsModel) BatchSegmentAction(sc.fiji.labkit.ui.actions.BatchSegmentAction) SegmentationExportAction(sc.fiji.labkit.ui.actions.SegmentationExportAction) ClassifierIoAction(sc.fiji.labkit.ui.actions.ClassifierIoAction) ClassifierSettingsAction(sc.fiji.labkit.ui.actions.ClassifierSettingsAction) ImageLabelingModel(sc.fiji.labkit.ui.models.ImageLabelingModel) AddLabelingIoAction(sc.fiji.labkit.ui.actions.AddLabelingIoAction) LabelingIoAction(sc.fiji.labkit.ui.actions.LabelingIoAction) AddLabelingIoAction(sc.fiji.labkit.ui.actions.AddLabelingIoAction) SegmentationItem(sc.fiji.labkit.ui.models.SegmentationItem) BitmapImportExportAction(sc.fiji.labkit.ui.actions.BitmapImportExportAction) SegmentationAsLabelAction(sc.fiji.labkit.ui.actions.SegmentationAsLabelAction) TrainClassifier(sc.fiji.labkit.ui.segmentation.TrainClassifier)

Example 3 with ImageLabelingModel

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

the class CustomizedSegmentationComponentDemo method onSaveResultsClicked.

private void onSaveResultsClicked(ActionEvent actionEvent) {
    SegmentationItem selectedSegmenter = segmentationModel.segmenterList().selectedSegmenter().get();
    if (selectedSegmenter == null || !selectedSegmenter.isTrained()) {
        JOptionPane.showMessageDialog(null, "Please select a segmentation algoritm and train it");
        return;
    }
    ImageLabelingModel imageLabeling = segmentationModel.imageLabelingModel();
    RandomAccessibleInterval<ShortType> segmentation = selectedSegmenter.results(imageLabeling).segmentation();
    ParallelUtils.runInOtherThread(() -> {
        ParallelUtils.populateCachedImg(segmentation, new SwingProgressWriter(null, "Calculate Entire Segmentation"));
        JOptionPane.showMessageDialog(null, "Calculation completed");
        BdvFunctions.show(segmentation, "Segmentation").setDisplayRange(0, 1);
    });
}
Also used : ImageLabelingModel(sc.fiji.labkit.ui.models.ImageLabelingModel) SegmentationItem(sc.fiji.labkit.ui.models.SegmentationItem) ShortType(net.imglib2.type.numeric.integer.ShortType) SwingProgressWriter(sc.fiji.labkit.ui.utils.progress.SwingProgressWriter)

Example 4 with ImageLabelingModel

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

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

the class LabelingComponentDemo method main.

public static void main(String... args) {
    JFrame frame = new JFrame();
    frame.setSize(400, 400);
    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    ImageLabelingModel model = initModel();
    frame.add(initLabelingComponent(frame, model));
    frame.setVisible(true);
}
Also used : ImageLabelingModel(sc.fiji.labkit.ui.models.ImageLabelingModel)

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