%classpath config resolver imagej.public https://maven.imagej.net/content/groups/public %%classpath add mvn net.imagej imagej 2.0.0-rc-71 net.imagej imagej-notebook 0.7.1 ij = new net.imagej.ImageJ() "ImageJ v${ij.getVersion()} is ready to go." // image = ij.io().open("https://imagej.net/images/lymp.tif") image = ij.io().open("C:/structure/data/lymp.tif") histogram = ij.op().image().histogram(image) binaryImage = ij.op().threshold().huang(image) import net.imglib2.algorithm.labeling.ConnectedComponents; ij.op().labeling().cca(image, ConnectedComponents.StructuringElement.EIGHT_CONNECTED); eyes32 = ij.op().convert().float32(eyes) eyes.firstElement().getClass().getName() eyes32.firstElement().getClass().getName() import net.imglib2.algorithm.neighborhood.HyperSphereShape median = ij.op().run("create.img", eyes32) neighborhood = new HyperSphereShape(4) ij.op().run("filter.median", median, eyes32, neighborhood) dogFormula = "gauss(image, sigma1) - gauss(image, sigma2)" dog = ij.op().eval(dogFormula, [ "image": eyes32, "sigma1": [20, 20], "sigma2": [4, 4] ]) topHat = ij.op().morphology().topHat(eyes, [neighborhood]) blackTopHat = ij.op().morphology().blackTopHat(eyes, [neighborhood]) ij.notebook().display(["median":median, "topHat":topHat, "blackTopHat":blackTopHat]) ij.notebook().display([["median":median, "topHat":topHat, "blackTopHat":blackTopHat]]) import net.imglib2.util.Util lowpass = { fft, radius -> // Declare an array to hold the current position of the cursor. pos = new long[fft.numDimensions()] // Define origin as 0,0. long[] origin = [0, 0] // Define a 2nd 'origin' at bottom left of image. // This is a bit of a hack. We want to draw a circle around the origin, // since the origin is at 0,0 - the circle will 'reflect' to the bottom. long[] origin2 = [0, fft.dimension(1)] // Loop through all pixels. cursor = fft.localizingCursor() while (cursor.hasNext()) { cursor.fwd() cursor.localize(pos) // Calculate distance from 0,0 and bottom left corner // (so we can form the reflected semi-circle). dist = Util.distance(origin, pos) dist2 = Util.distance(origin2, pos) // If distance is above radius (cutoff frequency) set value of FFT to zero. if (dist > radius && dist2 > radius) cursor.get().setZero() } } import net.imglib2.type.numeric.real.FloatType // Perform fft of the input. fft = ij.op().filter().fft(image) // Filter it. lowpass(fft, radius=10) // Reverse the FFT. inverse = ij.op().run("create.img", image, new FloatType()) ij.op().filter().ifft(inverse, fft) // Display the result. ij.notebook().display([["image":image, "lowpass":inverse]])