Search in sources :

Example 6 with DatasetInputImage

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);
}
Also used : Context(org.scijava.Context) SegmentationPlugin(sc.fiji.labkit.ui.segmentation.SegmentationPlugin) 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) ArrayList(java.util.ArrayList) InputImage(sc.fiji.labkit.ui.inputimage.InputImage) DatasetInputImage(sc.fiji.labkit.ui.inputimage.DatasetInputImage) DefaultSegmentationModel(sc.fiji.labkit.ui.models.DefaultSegmentationModel) SegmentationModel(sc.fiji.labkit.ui.models.SegmentationModel) DefaultSegmentationModel(sc.fiji.labkit.ui.models.DefaultSegmentationModel) SegmentationItem(sc.fiji.labkit.ui.models.SegmentationItem) Test(org.junit.Test)

Example 7 with DatasetInputImage

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

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);
}
Also used : Context(org.scijava.Context) DefaultSegmentationModel(sc.fiji.labkit.ui.models.DefaultSegmentationModel) DatasetInputImage(sc.fiji.labkit.ui.inputimage.DatasetInputImage) SegmenterListModel(sc.fiji.labkit.ui.models.SegmenterListModel)

Example 9 with DatasetInputImage

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();
        }
    });
}
Also used : DefaultSegmentationModel(sc.fiji.labkit.ui.models.DefaultSegmentationModel) DatasetInputImage(sc.fiji.labkit.ui.inputimage.DatasetInputImage) WindowEvent(java.awt.event.WindowEvent) WindowAdapter(java.awt.event.WindowAdapter) DefaultSegmentationModel(sc.fiji.labkit.ui.models.DefaultSegmentationModel) SegmentationModel(sc.fiji.labkit.ui.models.SegmentationModel)

Example 10 with DatasetInputImage

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();
    }
}
Also used : Context(org.scijava.Context) DatasetInputImage(sc.fiji.labkit.ui.inputimage.DatasetInputImage) UnsignedByteType(net.imglib2.type.numeric.integer.UnsignedByteType) Labeling(sc.fiji.labkit.ui.labeling.Labeling) File(java.io.File) Test(org.junit.Test)

Aggregations

DatasetInputImage (sc.fiji.labkit.ui.inputimage.DatasetInputImage)25 Context (org.scijava.Context)10 Test (org.junit.Test)7 UnsignedByteType (net.imglib2.type.numeric.integer.UnsignedByteType)6 ImagePlus (ij.ImagePlus)5 DefaultSegmentationModel (sc.fiji.labkit.ui.models.DefaultSegmentationModel)5 ShortType (net.imglib2.type.numeric.integer.ShortType)4 ValuePair (net.imglib2.util.ValuePair)4 Labeling (sc.fiji.labkit.ui.labeling.Labeling)4 ImageLabelingModel (sc.fiji.labkit.ui.models.ImageLabelingModel)4 SegmentationModel (sc.fiji.labkit.ui.models.SegmentationModel)4 ImgPlus (net.imagej.ImgPlus)3 AxisType (net.imagej.axis.AxisType)3 SegmentationItem (sc.fiji.labkit.ui.models.SegmentationItem)3 File (java.io.File)2 IOException (java.io.IOException)2 ARGBType (net.imglib2.type.numeric.ARGBType)2 ProgressWriter (bdv.export.ProgressWriter)1 ProgressWriterConsole (bdv.export.ProgressWriterConsole)1 AbstractSource (bdv.util.AbstractSource)1