use of sc.fiji.labkit.ui.inputimage.DatasetInputImage 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.inputimage.DatasetInputImage 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.inputimage.DatasetInputImage in project labkit-ui by juglab.
the class SegmenterPanelDemo method main.
public static void main(String... args) {
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
frame.setSize(400, 400);
SegmenterListModel model = new DefaultSegmentationModel(new Context(), new DatasetInputImage(ArrayImgs.unsignedBytes(10, 10))).segmenterList();
final SegmenterPanel segmenterPanel = new SegmenterPanel(model, item -> newMenu(item, model));
frame.add(segmenterPanel);
frame.setVisible(true);
}
use of sc.fiji.labkit.ui.inputimage.DatasetInputImage in project labkit-ui by juglab.
the class GarbageCollectionTest method addSegmentationComponent.
private void addSegmentationComponent(JFrame frame) {
SegmentationModel segmentationModel = new DefaultSegmentationModel(context, new DatasetInputImage(ArrayImgs.bytes(10, 10)));
SegmentationComponent component = new SegmentationComponent(frame, segmentationModel, false);
frame.add(component);
frame.addWindowListener(new WindowAdapter() {
@Override
public void windowClosed(WindowEvent e) {
component.close();
}
});
}
use of sc.fiji.labkit.ui.inputimage.DatasetInputImage in project labkit-ui by juglab.
the class InitialLabelingTest method testInitialLabeling.
@Test
public void testInitialLabeling() throws IOException {
File empty = File.createTempFile("labkit-InitialLabelingTest-", ".czi.labeling");
try {
ImgPlus<UnsignedByteType> image = ImgPlus.wrap(ArrayImgs.unsignedBytes(2, 3));
image.setSource(empty.getAbsolutePath().replace(".labeling", ""));
DatasetInputImage inputImage = new DatasetInputImage(image);
Context context = new Context();
List<String> defaultLabels = Collections.emptyList();
Labeling result = InitialLabeling.initLabeling(inputImage, context, defaultLabels);
assertNotNull(result);
} finally {
empty.delete();
}
}
Aggregations