|
Hi everyone !
I have a problem in my program with overwriting the results in the Results window.
I'm using to measurement - stack - 15 slices (15 pictures ) on this same time, from first to the last, on one action. I would like to see all results in one list from the top to the bottom , but unfortunately, results overwrite and is the measurement only from the last pictures.
Source from macro :
else if (cmd=="Get Roi"){
selectWindow("3");
for (i=1; i<=nSlices; i++) {
setSlice(i);
run("Compile and Run...", "compile=[~~\\Calculate_Mean.java]");
And Calculate_Mean instruction :
import ij.*;
import ij.process.*;
import ij.gui.*;
import java.awt.*;
import ij.plugin.*;
import ij.measure.ResultsTable;
import ij.text.TextWindow;
public class Calculate_Mean implements PlugIn {
public void run(String arg) {
ImagePlus imp = IJ.getImage();
Roi roi = imp.getRoi();
if (roi!=null && !roi.isArea()) roi = null;
ImageProcessor ip = imp.getProcessor();
ImageProcessor mask = roi!=null?roi.getMask():null;
Rectangle r = roi!=null?roi.getBounds():new Rectangle(0,0,ip.getWidth(),ip.getHeight());
double sum = 0;
int count = 0;
double mvalue = 0;
ResultsTable rt = new ResultsTable();
for (int y=0; y<r.height; y++) {
for (int x=0; x<r.width; x++) {
if (mask==null||mask.getPixel(x,y)!=0) {
count++;
mvalue = ip.getPixelValue(x+r.x, y+r.y);
sum += mvalue;
rt.incrementCounter();
rt.addValue("x", +x);
rt.addValue("y", +y);
rt.addValue("mvalue", +mvalue);
}
;
}
}
rt.showRowNumbers(true);
rt.show("Results");
}
}
</i>
Anybody Help ?
|