//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() ij.op().help("outline") input_full = ij.scifio().datasetIO().open("http://imagej.net/images/blobs.gif") //input_full has 3 channels. We only need one. input = ij.op().run("hyperSliceView", input_full, 2, 0) //invert the image so that the blobs are "on" and the background "off" inverted = ij.op().run("create.img", input) ij.op().run("invert", inverted, input) binaryInput = ij.op().run("threshold.huang", inverted) ij.notebook().display(binaryInput) import net.imglib2.algorithm.neighborhood.HyperSphereShape output = ij.op().run("outline", binaryInput, true) ij.notebook().display(output) import net.imglib2.img.Img list = new ArrayList() list.add(binaryInput) list.add(output) stacked = ij.op().run("stackView", list) ij.notebook().display(stacked)