//load ImageJ
%classpath config resolver scijava.public https://maven.scijava.org/content/groups/public
%classpath add mvn net.imagej imagej 2.0.0-rc-67
//create ImageJ object
ij = new net.imagej.ImageJ()
Added new repo: scijava.public
net.imagej.ImageJ@565027b
This Op
calculates the Percentile of a given percent on any Iterable
via the Quantile Op
.
sinusoid32 = ij.op().run("create.img", [150, 100])
formula = "63 * (Math.cos(0.3*p[0]) + Math.sin(0.3*p[1])) + 127"
ij.op().image().equation(sinusoid32, formula)
ij.notebook().display(sinusoid32)
All Img
s are Iterable
s, so we can just pass through the Img
to percentile()
. We also need to pass a double
indicating the percent for each call:
import net.imglib2.type.numeric.real.DoubleType
percents = [0.0, 25.0, 50.0, 75.0, 99.9]
for(percent in percents)
println(percent + "th percentile = " + ij.op().stats().percentile(sinusoid32, percent))
0.0th percentile = 1.293813403205192 25.0th percentile = 86.23904508345876 50.0th percentile = 129.34019425677636 75.0th percentile = 176.38650829067143 99.9th percentile = 252.8726096451634
null