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