Search in sources :

Example 1 with InputImage

use of sc.fiji.labkit.ui.inputimage.InputImage 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 2 with InputImage

use of sc.fiji.labkit.ui.inputimage.InputImage in project labkit-ui by juglab.

the class LabkitImportPlugin method run.

private static void run(Context context, File file) {
    try {
        ProgressWriter progressWriter = new StatusServiceProgressWriter(context.service(StatusService.class));
        InputImage image = openImage(context, progressWriter, file);
        LabkitFrame.showForImage(context, image);
    } catch (SpimDataInputException e) {
        JOptionPane.showMessageDialog(null, "There was an error when opening: " + file + "\n\n" + e.getMessage(), "Problem", JOptionPane.ERROR_MESSAGE);
    }
}
Also used : StatusService(org.scijava.app.StatusService) StatusServiceProgressWriter(sc.fiji.labkit.ui.utils.progress.StatusServiceProgressWriter) ProgressWriter(bdv.export.ProgressWriter) StatusServiceProgressWriter(sc.fiji.labkit.ui.utils.progress.StatusServiceProgressWriter) InputImage(sc.fiji.labkit.ui.inputimage.InputImage) SpimDataInputImage(sc.fiji.labkit.ui.inputimage.SpimDataInputImage) DatasetInputImage(sc.fiji.labkit.ui.inputimage.DatasetInputImage) SpimDataInputException(sc.fiji.labkit.ui.inputimage.SpimDataInputException)

Example 3 with InputImage

use of sc.fiji.labkit.ui.inputimage.InputImage in project labkit-ui by juglab.

the class ImageLabelingModel method getScaling.

private AffineTransform3D getScaling(Interval inputImage, Interval initialLabeling) {
    long[] dimensionsA = get3dDimensions(inputImage);
    long[] dimensionsB = get3dDimensions(initialLabeling);
    double[] values = IntStream.range(0, 3).mapToDouble(i -> (double) dimensionsA[i] / (double) dimensionsB[i]).toArray();
    AffineTransform3D affineTransform3D = new AffineTransform3D();
    affineTransform3D.set(values[0], 0.0, 0.0, 0.0, 0.0, values[1], 0.0, 0.0, 0.0, 0.0, values[2], 0.0);
    return affineTransform3D;
}
Also used : IntStream(java.util.stream.IntStream) Arrays(java.util.Arrays) ImgPlus(net.imagej.ImgPlus) Dimensions(net.imglib2.Dimensions) Axes(net.imagej.axis.Axes) InputImage(sc.fiji.labkit.ui.inputimage.InputImage) ParametricNotifier(sc.fiji.labkit.ui.utils.ParametricNotifier) List(java.util.List) FinalDimensions(net.imglib2.FinalDimensions) Labeling(sc.fiji.labkit.ui.labeling.Labeling) BdvShowable(sc.fiji.labkit.ui.bdv.BdvShowable) Interval(net.imglib2.Interval) FinalInterval(net.imglib2.FinalInterval) Label(sc.fiji.labkit.ui.labeling.Label) AffineTransform3D(net.imglib2.realtransform.AffineTransform3D) ImgPlusViewsOld(sc.fiji.labkit.ui.inputimage.ImgPlusViewsOld) AffineTransform3D(net.imglib2.realtransform.AffineTransform3D)

Aggregations

InputImage (sc.fiji.labkit.ui.inputimage.InputImage)3 ImgPlus (net.imagej.ImgPlus)2 DatasetInputImage (sc.fiji.labkit.ui.inputimage.DatasetInputImage)2 ProgressWriter (bdv.export.ProgressWriter)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 List (java.util.List)1 IntStream (java.util.stream.IntStream)1 Axes (net.imagej.axis.Axes)1 Dimensions (net.imglib2.Dimensions)1 FinalDimensions (net.imglib2.FinalDimensions)1 FinalInterval (net.imglib2.FinalInterval)1 Interval (net.imglib2.Interval)1 AffineTransform3D (net.imglib2.realtransform.AffineTransform3D)1 ShortType (net.imglib2.type.numeric.integer.ShortType)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 StatusService (org.scijava.app.StatusService)1