use of sc.fiji.labkit.pixel_classification.pixel_feature.settings.FeatureSettings in project labkit-ui by juglab.
the class TrainableSegmentationSegmenter method initFeatureSettings.
private void initFeatureSettings(List<Pair<ImgPlus<?>, Labeling>> trainingData) {
if (this.featureSettings != null)
return;
final GlobalSettings globalSettings = initGlobalSettings(trainingData);
this.featureSettings = new FeatureSettings(globalSettings, SingleFeatures.identity(), GroupedFeatures.gauss(), GroupedFeatures.differenceOfGaussians(), GroupedFeatures.gradient(), GroupedFeatures.laplacian(), GroupedFeatures.hessian());
}
use of sc.fiji.labkit.pixel_classification.pixel_feature.settings.FeatureSettings in project labkit-ui by juglab.
the class TrainableSegmentationSettingsDialog method main.
public static void main(String... args) {
FeatureSettings defaultFeatureSettings = new FeatureSettings(GlobalSettings.default2d().build(), GroupedFeatures.gauss());
TrainableSegmentationSettingsDialog dialog = new TrainableSegmentationSettingsDialog(new Context(), null, true, defaultFeatureSettings);
dialog.show();
if (dialog.okClicked()) {
dialog.featureSettings().features().forEach(setting -> System.out.println(setting.getName()));
System.out.println("Use Gpu: " + dialog.useGpu());
}
}
use of sc.fiji.labkit.pixel_classification.pixel_feature.settings.FeatureSettings in project labkit-ui by juglab.
the class TrainableSegmentationSegmenterTest method testClassify3DStackInSlices.
@Test
public void testClassify3DStackInSlices() {
Context context = SingletonContext.getInstance();
TrainableSegmentationSegmenter segmenter = new TrainableSegmentationSegmenter(context);
// Settings to 2D
segmenter.setFeatureSettings(new FeatureSettings(GlobalSettings.default2d().build(), SingleFeatures.identity()));
// Train on 3D image
ImgPlus<?> image3d = new ImgPlus<>(ArrayImgs.ints(new int[] { 0, 1, 1, 0 }, 2, 1, 2), "name", new AxisType[] { Axes.X, Axes.Y, Axes.Z });
Labeling labeling = initLabeling();
segmenter.train(Collections.singletonList(new ValuePair<>(image3d, labeling)));
// Segment 3D image
Img<IntType> result = ArrayImgs.ints(2, 1, 2);
segmenter.segment(image3d, result);
ImgLib2Assert.assertImageEquals(image3d, result, Object::equals);
Img<IntType> expected2d = ArrayImgs.ints(new int[] { 0, 1, 0 }, 1, 3);
// Segment 2d image
ImgPlus<IntType> image2d = new ImgPlus<>(expected2d, "");
Img<IntType> result2d = ArrayImgs.ints(1, 3);
segmenter.segment(image2d, result2d);
ImgLib2Assert.assertImageEquals(image2d, result2d, Object::equals);
}
Aggregations