use of uk.ac.sussex.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.getSize() / w;
final double scaleY = (double) settings.getSize() / h;
// Use an image for the distribution
if (imp.getStackSize() > 1) {
final ImageStack stack = imp.getImageStack();
final List<int[]> masks = new ArrayList<>(stack.getSize());
final int[] maxMask = new int[w * h];
for (int slice = 1; slice <= stack.getSize(); slice++) {
final 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.getDepth() / masks.size();
}
return new MaskDistribution3D(masks, w, h, sliceDepth / settings.getPixelPitch(), scaleX, scaleY, createRandomGenerator());
}
final int[] mask = extractMask(imp.getProcessor());
if (updateArea) {
updateArea(mask, w, h);
}
return new MaskDistribution(mask, w, h, settings.getDepth() / settings.getPixelPitch(), scaleX, scaleY, createRandomGenerator());
}
Aggregations