I wish to acquire ~1600 images per second, process them to find the centre coordinates of a bead, and save these along with the time for the frame. I have a script in micro-manager which almost does this. It acquires the image, puts it into an ImageJ ImageProcessor object, and then uses a ShortStatistics object to calculate a centre of mass. Problem is, this centre of mass is skewed by the bright background, and always very close to the centre of the image (within 40nm of the centre for a 4um wide field of view).
I have attempted to alleviate this using thresholding - the bead is very bright, and Otsu thresholding does a good job of removing the background. However the ImageProcessor does not create a mask, meaning the ShortStatistics cannot use this. I have included some code from my micro-manager script below to illustrate this:
pixels = mmc.popNextImage(); // Micro-manager's way of giving me the pixel values as a short ip.setPixels(pixels); ip.setAutoThreshold("Otsu dark"); ss = new ShortStatistics(ip, ij.process.ImageStatistics.CENTER_OF_MASS, null); a = ip.getMaskArray(); print(a); // null print("IP thresh " + ip.minThreshold + " " ip.maxThreshold); // Prints limits with sensible values (~1100 and 65000 normally) print("SS thresh " + ss.lowerThreshold + " " + ss.upperThreshold); // Prints NaN for both limits
The last 4 lines above are my troubleshooting - I cannot get a mask array from the ImageProcessor, but it does have thresholds set. The ShortStatistics does not have thresholds set.
How can I either: Make the ImageProcessor return the mask array correctly (needed for Shortstatistics to use the thresholding)? Or set thresholds to the ShortStatistics?