use of ij.plugin.ZProjector in project GDSC-SMLM by aherbert.
the class SpotAnalysis method createProfile.
private void createProfile(ImagePlus imp, Rectangle bounds, double psfWidth, double blur) {
areaBounds = bounds;
this.imp = imp;
area = bounds.width * bounds.height;
clearSelectedFrames();
// Get a profile through the images
IJ.showStatus("Calculating raw profile");
final int nSlices = imp.getStackSize();
ImageStack rawSpot = new ImageStack(bounds.width, bounds.height, nSlices);
double[][] profile = extractSpotProfile(imp, bounds, rawSpot);
// Retain the existing display range
double min = 0, max = Double.POSITIVE_INFINITY;
if (rawImp != null) {
min = rawImp.getDisplayRangeMin();
max = rawImp.getDisplayRangeMax();
}
rawImp = showSpot(rawSpotTitle, rawSpot);
if (max != Double.POSITIVE_INFINITY) {
rawImp.setDisplayRange(min, max);
}
rawMean = profile[0];
rawSd = profile[1];
// Check if there are fitted results in memory
addCandidateFrames(imp.getTitle());
updateProfilePlots();
if (blur > 0) {
IJ.showStatus("Calculating blur ...");
ImageStack stack = imp.getImageStack();
ImageStack newStack = new ImageStack(stack.getWidth(), stack.getHeight(), stack.getSize());
// Multi-thread the blur stage
ExecutorService threadPool = Executors.newFixedThreadPool(Prefs.getThreads());
List<Future<?>> futures = new LinkedList<Future<?>>();
Utils.setShowProgress(false);
blurCount = 0;
// TODO - See if this is faster if processing multiple slices in each worker
int slices = 5;
for (int n = 1; n <= nSlices; n += slices) {
futures.add(threadPool.submit(new BlurWorker(stack, n, slices, bounds, blur * psfWidth, newStack)));
}
IJ.showStatus("Calculating blur ... Finishing");
Utils.waitForCompletion(futures);
threadPool.shutdown();
Utils.setShowProgress(false);
IJ.showStatus("Calculating blur ... Drawing");
ImageStack blurSpot = new ImageStack(bounds.width, bounds.height, nSlices);
extractSpotProfile(new ImagePlus("Blur", newStack), bounds, blurSpot);
// Retain the existing display range
max = Double.POSITIVE_INFINITY;
if (blurImp != null) {
min = blurImp.getDisplayRangeMin();
max = blurImp.getDisplayRangeMax();
}
blurImp = showSpot(blurSpotTitle, blurSpot);
if (max != Double.POSITIVE_INFINITY) {
blurImp.setDisplayRange(min, max);
}
IJ.showStatus("");
} else {
blurImp = null;
}
// Add a z-projection of the blur/original image
ZProjector project = new ZProjector((blurImp == null) ? rawImp : blurImp);
project.setMethod(ZProjector.AVG_METHOD);
project.doProjection();
showSpot(avgSpotTitle, project.getProjection().getImageStack());
if (!candidateFrames.isEmpty())
// Set the first candidate frame
rawImp.setSlice(candidateFrames.get(0));
else
updateCurrentSlice(rawImp.getCurrentSlice());
IJ.showStatus("");
}
use of ij.plugin.ZProjector in project GDSC-SMLM by aherbert.
the class ImageBackground method getProjection.
private ImageProcessor getProjection() {
// Get median intensity projection
ZProjector p = new ZProjector(imp);
p.setMethod(ZProjector.MEDIAN_METHOD);
p.doProjection();
ImageProcessor median = p.getProjection().getProcessor();
return median;
}
Aggregations