On Tuesday, 9 June 2020 22:42:09 BST you wrote:
> a) if the current image is a stack - I want to run the macro for every slice
> in the stack, producing one line in the Results window for each slice (I
> assume the lines will be labelled with the slice labels?) b) (probably
> trivial, but...as long as I'm here) write the contents of the Results
> window to a file.
Hi Kenneth,
I would consider your images to be always a stack, with the case of single
images as a stack with only one slice.
The reserved variable nSlices tells you how many slices there are.
for(i=0;i<nSlices;i++){
setSlice(i+1);
// do whatever here \
}
As for the Results Table, there is also a reserved variable nResults that
tells you how much data (rows) there are in the Table, so you can add the new
results in the 'next' row (can't remember if it starts at 0 or at 1).
> Also...I'm *really* interested in the percentages of white/black pixels
> after thresholding. I'm assuming that "Percent Area" is the correct
> measurement? And...which percentage is reported - pct WHITE or pct BLACK?
> Again - ordinarily I would simply write the Java code to count the pixels,
> but that's probably overkill for this application.
Easiest is to get the histogram and obtain the number you want from there:
(assuming a greyscale):
nBins = 256;
getHistogram(values, counts, nBins);
counts[0] is the number of black pixels and counts[255] are the white ones
Hope that helps a bit.
Cheers
Gabriel
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html