|
Dear members,
In the following code; I am trying to analyze particles from a binary image
and measure each particle in the original image, and I want this
measurements to be in the scaled unit; this is working fine until I show
(use tempImp.show() ) an ImagePlus that I want to use it later to draw
overlays over and save it.
The following java program demonstrate my problem, disable the line
tempImp.show(); will solve the problem.
Any ideas why this is happening and what suggestion you have to overcome
this problem?
import org.imagearchive.lsm.reader.Reader;
import ij.*;
import ij.process.ImageProcessor;
import ij.gui.*;
import ij.plugin.frame.RoiManager;
public class overlayProblemtest {
String image = "/myPath/testing.lsm";
Reader lsm = new Reader();
public measurement_Problem()
{
ImagePlus imp = lsm.open(image, true);
ImageStack is = new ImageStack();
is = imp.getStack();
ImageProcessor ip = is.getProcessor(1);
Overlay overlay = new Overlay();
ImageProcessor ip2 = ip.duplicate();
ImagePlus tempImp = new ImagePlus();
tempImp.setProcessor(ip2);
ImagePlus impBin = new ImagePlus("/myPath/binary.tif");
tempImp.show(); // disable this to have desired measures
RoiManager manager = new RoiManager();
IJ.run(imp, "Set Scale...", "distance=5.365 known=1 pixel=1
unit=µm");
IJ.run(impBin, "Analyze Particles...", "size=100-Infinity
circularity=0.3-1.00 show=Outlines in_situ add");
manager.getInstance();
Roi[] roiArray =null;
if (manager !=null)
roiArray = manager.getRoisAsArray();
for (int i = 0; i < roiArray.length; i++)
{
manager.runCommand("Reset");
manager.addRoi(roiArray[i]);
manager.runCommand("Measure");
}
}
public static void main(String args[])
{
new overlayProblemtest();
}
}
|