use of sc.fiji.labkit.ui.segmentation.SegmentationPlugin in project labkit-ui by juglab.
the class SegmentationUseCaseTest method test.
@Test
public void test() {
ImgPlus<UnsignedByteType> image = new ImgPlus<>(ArrayImgs.unsignedBytes(new byte[] { 1, 1, 2, 2 }, 2, 2));
InputImage inputImage = new DatasetInputImage(image);
SegmentationModel segmentationModel = new DefaultSegmentationModel(new Context(), inputImage);
addLabels(segmentationModel.imageLabelingModel());
SegmentationPlugin plugin = PixelClassificationPlugin.create();
SegmentationItem segmenter = segmentationModel.segmenterList().addSegmenter(plugin);
segmenter.train(Collections.singletonList(new ValuePair<>(image, segmentationModel.imageLabelingModel().labeling().get())));
RandomAccessibleInterval<ShortType> result = segmenter.results(segmentationModel.imageLabelingModel()).segmentation();
List<Integer> list = new ArrayList<>();
Views.iterable(result).forEach(x -> list.add(x.getInteger()));
assertEquals(Arrays.asList(1, 1, 0, 0), list);
}
use of sc.fiji.labkit.ui.segmentation.SegmentationPlugin in project labkit-ui by juglab.
the class SegmenterPanel method showAddSegmenterPopupMenu.
private void showAddSegmenterPopupMenu() {
SegmentationPluginService pluginService = segmentationModel.context().service(SegmentationPluginService.class);
List<SegmentationPlugin> plugins = pluginService.getSegmentationPlugins();
JPopupMenu menu = new JPopupMenu();
for (SegmentationPlugin plugin : plugins) {
JMenuItem menuItem = new JMenuItem(plugin.getTitle());
menuItem.addActionListener(ignore -> addSegmenter(plugin));
menu.add(menuItem);
}
menu.show(addSegmenterButton, 0, addSegmenterButton.getHeight());
}
use of sc.fiji.labkit.ui.segmentation.SegmentationPlugin in project labkit-ui by juglab.
the class AddSegmenterPanel method addButtons.
private void addButtons(SegmenterListModel segmenterListModel, JPanel list) {
Context context = segmenterListModel.context();
SegmentationPluginService pluginService = context.service(SegmentationPluginService.class);
for (SegmentationPlugin sp : pluginService.getSegmentationPlugins()) {
JButton button = new JButton(sp.getTitle());
button.addActionListener(ignore -> {
segmenterListModel.addSegmenter(sp);
});
list.add(button, "grow, wrap");
}
}
Aggregations