def make_outline_image(imp): imp.show() # one needs to display it, otherwise below function cannot find it IJ.run("3D Fast Filters","filter=Minimum radius_x_pix=1.0 radius_y_pix=1.0 radius_z_pix=1.0"); imp.hide() imp_minimum = WindowManager.getImage("3D_Minimum") imp_outlines = imp.duplicate() calc = ImageCalculator() calc.calculate("Subtract stack", imp_outlines, imp_minimum) # clean up imp_minimum.close() imp_outlines.setTitle("Outlines") return imp_outlines
from ij import IJ # imports the IJ class from ij.plugin import ImageCalculator # imports the Image Calculator from the ImageJ Plugins imp = IJ.getImage() # gets the title of the image IJ.run(imp, "Duplicate...", "title=duplicate.tif duplicate") # runs duplication on selected image imp_2 = IJ.getImage() # gets title of duplicated image IJ.run(imp, "Gaussian Blur 3D...", "x=2 y=2 z=2") # runs gaussian blur 3D on original image IJ.run(imp_2, "Gaussian Blur 3D...", "x=4 y=4 z=4") # runs gaussian blur 3D on duplicated image calc = ImageCalculator() # setting the function equal to the variable calc calc.calculate( "Subtract create stack", imp, imp_2) # calling the ImageCalculator() to subtract imp minus imp_2 imp.close() # closes original image imp_2.close() # closes duplicate image #print imp.title
IJ.run("Convert Stack to Images"); win = w.getWindow("Blue") win.removeNotify() IJ.selectWindow("Red") IJ.run("16-bit"); red=IJ.getImage() IJ.selectWindow("Green") IJ.run("16-bit") green=IJ.getImage() calc = ImageCalculator() calc.calculate("Add create", red,green); IJ.run("Subtract Background...", "rolling=50"); IJ.run("LoG 3D"); imp = IJ.getImage() pix = imp.getProcessor().convertToFloat().getPixels() # find out the minimal pixel value min = reduce(Math.min, pix) # create a new pixel array with the minimal value subtracted pix2 = map(lambda x: x - min, pix) name="log" ImagePlus(name, FloatProcessor(imp.width, imp.height, pix2, None)).show()