Search in sources :

Example 1 with FeatureSettings

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());
}
Also used : FeatureSettings(sc.fiji.labkit.pixel_classification.pixel_feature.settings.FeatureSettings) GlobalSettings(sc.fiji.labkit.pixel_classification.pixel_feature.settings.GlobalSettings)

Example 2 with FeatureSettings

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());
    }
}
Also used : Context(org.scijava.Context) FeatureSettings(sc.fiji.labkit.pixel_classification.pixel_feature.settings.FeatureSettings)

Example 3 with FeatureSettings

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);
}
Also used : Context(org.scijava.Context) SingletonContext(sc.fiji.labkit.pixel_classification.utils.SingletonContext) FeatureSettings(sc.fiji.labkit.pixel_classification.pixel_feature.settings.FeatureSettings) ImgPlus(net.imagej.ImgPlus) ValuePair(net.imglib2.util.ValuePair) Labeling(sc.fiji.labkit.ui.labeling.Labeling) IntType(net.imglib2.type.numeric.integer.IntType) Test(org.junit.Test)

Aggregations

FeatureSettings (sc.fiji.labkit.pixel_classification.pixel_feature.settings.FeatureSettings)3 Context (org.scijava.Context)2 ImgPlus (net.imagej.ImgPlus)1 IntType (net.imglib2.type.numeric.integer.IntType)1 ValuePair (net.imglib2.util.ValuePair)1 Test (org.junit.Test)1 GlobalSettings (sc.fiji.labkit.pixel_classification.pixel_feature.settings.GlobalSettings)1 SingletonContext (sc.fiji.labkit.pixel_classification.utils.SingletonContext)1 Labeling (sc.fiji.labkit.ui.labeling.Labeling)1