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