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