On Oct 28, 2013, at 5:34 AM, Andreas Rzepecki wrote:
> I am still not sure how to define precision separatly for every column, e.g.:
>
> pixel X pixel y value
>
> 1 1 5,876
> 1 2 6,703
> 1 3 5,435
> 2 1 8,567
> ...
>
> "Set Measurement..." and set.Precision seem to work just for the complete results table. Did I miss a valuable command?
> Thanking in advance.
Convert the values to strings using IJ.d2s(value,precision) before adding them to the results table, as the JavaScript example below does. Integer values are automatically displayed using a precision of 0.
This is what the output of the script looks like:
X Y Value Value2 Value9
1 1 1 8.061 8.06 8.061325073
2 1 2 4.026 4.03 4.025660038
3 1 3 8.211 8.21 8.211483955
4 2 1 2.602 2.60 2.601737976
And this is the script:
imp = IJ.createImage("Untitled", "32-bit black", 10, 10, 1)
IJ.run(imp, "Add Noise", "")
ip = imp.getProcessor()
rt = new ResultsTable()
add(ip, rt, 1, 1)
add(ip, rt, 1, 2)
add(ip, rt, 1, 3)
add(ip, rt, 2, 1)
rt.show("Results")
function add(ip, rt, x, y, value) {
rt.incrementCounter()
rt.addValue("X", x)
rt.addValue("Y", y)
rt.addValue("Value", ip.getf(x,y))
rt.addValue("Value2", IJ.d2s(ip.getf(x,y),2))
rt.addValue("Value9", IJ.d2s(ip.getf(x,y),9))
}
-wayne
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html