Search in sources :

Example 1 with FeatureCalculator

use of sc.fiji.labkit.pixel_classification.pixel_feature.calculator.FeatureCalculator in project labkit-ui by juglab.

the class TrainableSegmentationSegmenter method cachedFeatureBlock.

private DiskCachedCellImg<FloatType, ?> cachedFeatureBlock(FeatureCalculator feature, ImgPlus<?> image) {
    int count = feature.count();
    if (count <= 0)
        throw new IllegalArgumentException();
    long[] dimensions = Intervals.dimensionsAsLongArray(feature.outputIntervalFromInput(image));
    dimensions = LabkitUtils.extend(dimensions, count);
    int[] cellDimensions = suggestCellSize(image);
    cellDimensions = LabkitUtils.extend(cellDimensions, count);
    final DiskCachedCellImgOptions featureOpts = DiskCachedCellImgOptions.options().cellDimensions(cellDimensions).dirtyAccesses(false);
    final DiskCachedCellImgFactory<FloatType> featureFactory = new DiskCachedCellImgFactory<>(new FloatType(), featureOpts);
    RandomAccessible<?> input = Views.extendBorder(image);
    CellLoader<FloatType> loader = target -> feature.apply(input, target);
    return featureFactory.create(dimensions, loader);
}
Also used : Pair(net.imglib2.util.Pair) GsonUtils(sc.fiji.labkit.pixel_classification.gson.GsonUtils) WekaException(weka.core.WekaException) Context(org.scijava.Context) FloatType(net.imglib2.type.numeric.real.FloatType) DiskCachedCellImgOptions(net.imglib2.cache.img.DiskCachedCellImgOptions) Cursor(net.imglib2.Cursor) SparseRandomAccessIntType(sc.fiji.labkit.ui.utils.sparse.SparseRandomAccessIntType) SingleFeatures(sc.fiji.labkit.pixel_classification.pixel_feature.filter.SingleFeatures) FeatureSettings(sc.fiji.labkit.pixel_classification.pixel_feature.settings.FeatureSettings) Map(java.util.Map) DiskCachedCellImgFactory(net.imglib2.cache.img.DiskCachedCellImgFactory) Views(net.imglib2.view.Views) RandomAccess(net.imglib2.RandomAccess) CancellationException(java.util.concurrent.CancellationException) Set(java.util.Set) Collectors(java.util.stream.Collectors) PrefService(org.scijava.prefs.PrefService) Objects(java.util.Objects) DiskCachedCellImg(net.imglib2.cache.img.DiskCachedCellImg) List(java.util.List) Labelings(sc.fiji.labkit.ui.labeling.Labelings) LabelingType(net.imglib2.roi.labeling.LabelingType) Cast(net.imglib2.util.Cast) RealType(net.imglib2.type.numeric.RealType) ImgPlus(net.imagej.ImgPlus) ARGBType(net.imglib2.type.numeric.ARGBType) IntegerType(net.imglib2.type.numeric.IntegerType) Axes(net.imagej.axis.Axes) Composite(net.imglib2.view.composite.Composite) HashMap(java.util.HashMap) Function(java.util.function.Function) ArrayList(java.util.ArrayList) Intervals(net.imglib2.util.Intervals) RandomAccessibleInterval(net.imglib2.RandomAccessibleInterval) Labeling(sc.fiji.labkit.ui.labeling.Labeling) LabkitUtils(sc.fiji.labkit.ui.utils.LabkitUtils) FastRandomForest(hr.irb.fastRandomForest.FastRandomForest) BiConsumer(java.util.function.BiConsumer) AxisType(net.imagej.axis.AxisType) Label(sc.fiji.labkit.ui.labeling.Label) CellLoader(net.imglib2.cache.img.CellLoader) Training(sc.fiji.labkit.pixel_classification.classification.Training) Segmenter(sc.fiji.labkit.ui.segmentation.Segmenter) GlobalSettings(sc.fiji.labkit.pixel_classification.pixel_feature.settings.GlobalSettings) FeatureCalculator(sc.fiji.labkit.pixel_classification.pixel_feature.calculator.FeatureCalculator) GroupedFeatures(sc.fiji.labkit.pixel_classification.pixel_feature.filter.GroupedFeatures) IntType(net.imglib2.type.numeric.integer.IntType) ChannelSetting(sc.fiji.labkit.pixel_classification.pixel_feature.settings.ChannelSetting) RandomAccessible(net.imglib2.RandomAccessible) ImgPlusViews(net.imglib2.img.display.imagej.ImgPlusViews) ImgPlusViewsOld(sc.fiji.labkit.ui.inputimage.ImgPlusViewsOld) javax.swing(javax.swing) DiskCachedCellImgOptions(net.imglib2.cache.img.DiskCachedCellImgOptions) FloatType(net.imglib2.type.numeric.real.FloatType) DiskCachedCellImgFactory(net.imglib2.cache.img.DiskCachedCellImgFactory)

Aggregations

FastRandomForest (hr.irb.fastRandomForest.FastRandomForest)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Objects (java.util.Objects)1 Set (java.util.Set)1 CancellationException (java.util.concurrent.CancellationException)1 BiConsumer (java.util.function.BiConsumer)1 Function (java.util.function.Function)1 Collectors (java.util.stream.Collectors)1 javax.swing (javax.swing)1 ImgPlus (net.imagej.ImgPlus)1 Axes (net.imagej.axis.Axes)1 AxisType (net.imagej.axis.AxisType)1 Cursor (net.imglib2.Cursor)1 RandomAccess (net.imglib2.RandomAccess)1 RandomAccessible (net.imglib2.RandomAccessible)1 RandomAccessibleInterval (net.imglib2.RandomAccessibleInterval)1 CellLoader (net.imglib2.cache.img.CellLoader)1