I'm using List.setMeasurements to get measurement values as follows:
measurements="area mean standard modal min centroid center integrated median skewness kurtosis"; run("Set Measurements...", measurements+" redirect=None decimal=6"); List.setMeasurements; Note that I specify "decimal=6". Nevertheless, several of the values are printed with up to 19 decimal places: printthis = List.getValue("Area")+" "+List.getValue("Mean")+" "+List.getValue("StdDev"); printthis += " "+List.getValue("Mode")+" "+List.getValue("Median")+" "+List.getValue("Min")+" "+List.getValue("Max"); printthis += " "+List.getValue("X")+" "+List.getValue("Y")+" "+List.getValue("XM")+" "+List.getValue("YM"); printthis += " "+List.getValue("IntDen")+" "+List.getValue("Skew")+" "+List.getValue("Kurt"); print(printthis); 115856.0 -0.0028565558275383002 0.020379772636744016 7.486325921490788E-5 -0.002357484307140112 -0.23820121586322784 0.14423562586307526 300.0 300.0 314.9788664929413 296.8684989366027 -330.9491319552773 -0.42541313968512906 5.547452767132739 Is this a bug? Thanks, Neil -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
On Aug 1, 2014, at 12:27 PM, Neil Fazel wrote:
> I'm using List.setMeasurements to get measurement values as follows: > > measurements="area mean standard modal min centroid center integrated median skewness kurtosis"; > run("Set Measurements...", measurements+" redirect=None decimal=6"); > List.setMeasurements; > > Note that I specify "decimal=6". Nevertheless, several of the values are printed with up to 19 decimal places: The List.* macro functions return a string except for List.getValue() when used in an assignment statement. For example print(List.getValue("Mean")); outputs 103.26857775590551 but value = List.getValue("Mean"); print(value); outputs 103.2686 Use the d2s() (Double to String) macro function to print a number using a specified number of decimal places, for example value = List.getValue("Mean"); print(d2s(value,6)); outputs 103.268578 The following example macro prints the values of 14 measurement parameters using 6 decimal places. digits = 6; List.setMeasurements; p("Area"); p("Mean"); p("StdDev"); p("Mode"); p("Median"); p("Min"); p("Max"); p("X"); p("Y"); p("XM"); p("YM"); p("IntDen"); p("Skew"); p("Kurt"); function p(parameter) { value = List.getValue(parameter); print(parameter+": "+d2s(value,digits)); } Output: Area: 65024.000000 Mean: 103.268578 StdDev: 71.057094 Mode: 48.000000 Median: 64.000000 Min: 8.000000 Max: 248.000000 X: 128.000000 Y: 127.000000 XM: 129.981796 YM: 126.484026 IntDen: 6714936.000000 Skew: 0.713069 Kurt: -1.078397 > printthis = List.getValue("Area")+" "+List.getValue("Mean")+" "+List.getValue("StdDev"); > printthis += " "+List.getValue("Mode")+" "+List.getValue("Median")+" "+List.getValue("Min")+" "+List.getValue("Max"); > printthis += " "+List.getValue("X")+" "+List.getValue("Y")+" "+List.getValue("XM")+" "+List.getValue("YM"); > printthis += " "+List.getValue("IntDen")+" "+List.getValue("Skew")+" "+List.getValue("Kurt"); > print(printthis); > > 115856.0 -0.0028565558275383002 0.020379772636744016 7.486325921490788E-5 -0.002357484307140112 -0.23820121586322784 0.14423562586307526 300.0 300.0 314.9788664929413 296.8684989366027 -330.9491319552773 -0.42541313968512906 5.547452767132739 > > Is this a bug? > > Thanks, > Neil -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
In reply to this post by Neil Fazel
Hi Wayne,
Thank you for the very helpful explanation and the example. Best regards, Neil -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Free forum by Nabble | Edit this page |