use of gdsc.smlm.model.MaskDistribution3D in project GDSC-SMLM by aherbert.
the class CreateData method createMaskDistribution.
private SpatialDistribution createMaskDistribution(ImagePlus imp, double sliceDepth, boolean updateArea) {
// Calculate the scale of the mask
final int w = imp.getWidth();
final int h = imp.getHeight();
final double scaleX = (double) settings.size / w;
final double scaleY = (double) settings.size / h;
// Use an image for the distribution
if (imp.getStackSize() > 1) {
ImageStack stack = imp.getImageStack();
List<int[]> masks = new ArrayList<int[]>(stack.getSize());
int[] maxMask = new int[w * h];
for (int slice = 1; slice <= stack.getSize(); slice++) {
int[] mask = extractMask(stack.getProcessor(slice));
if (updateArea) {
for (int i = 0; i < mask.length; i++) if (mask[i] != 0)
maxMask[i] = 1;
}
masks.add(mask);
}
if (updateArea)
updateArea(maxMask, w, h);
if (sliceDepth == 0)
// Auto configure to the full depth of the simulation
sliceDepth = settings.depth / masks.size();
return new MaskDistribution3D(masks, w, h, sliceDepth / settings.pixelPitch, scaleX, scaleY, createRandomGenerator());
} else {
int[] mask = extractMask(imp.getProcessor());
if (updateArea)
updateArea(mask, w, h);
return new MaskDistribution(mask, w, h, settings.depth / settings.pixelPitch, scaleX, scaleY, createRandomGenerator());
}
}
Aggregations