Search in sources :

Example 1 with MaskDistribution3D

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());
}
Also used : ImageStack(ij.ImageStack) ArrayList(java.util.ArrayList) TIntArrayList(gnu.trove.list.array.TIntArrayList) TFloatArrayList(gnu.trove.list.array.TFloatArrayList) MaskDistribution(uk.ac.sussex.gdsc.smlm.model.MaskDistribution) ReadHint(uk.ac.sussex.gdsc.smlm.results.ImageSource.ReadHint) MaskDistribution3D(uk.ac.sussex.gdsc.smlm.model.MaskDistribution3D)

Aggregations

TFloatArrayList (gnu.trove.list.array.TFloatArrayList)1 TIntArrayList (gnu.trove.list.array.TIntArrayList)1 ImageStack (ij.ImageStack)1 ArrayList (java.util.ArrayList)1 MaskDistribution (uk.ac.sussex.gdsc.smlm.model.MaskDistribution)1 MaskDistribution3D (uk.ac.sussex.gdsc.smlm.model.MaskDistribution3D)1 ReadHint (uk.ac.sussex.gdsc.smlm.results.ImageSource.ReadHint)1