/* If you publish data processed with this macro or otherwise build on this method, please credit Michael Cammer &/or the DART Microscopy Lab at NYU Langone Medical Center. See http://microscopynotes.com/imagej/medianfiltering/ for an explanation what this does. It is an alternative to deconvolution only when you know a priori that you are looking for high contrast and bright structures smaller than the radius used for the median filtering. This version 20170208 is an update to http://microscopynotes.com/imagej/medianfiltering/2photonexample/Macro_v100.txt which adds the percentage subtraction to the dialog. Tested with ImageJ 1.51 with Java 1.6. */ var radius = 15; var percentagesub = 0.95; macro "subtract median [q]" { Dialog.create("Gimme numbers"); Dialog.addNumber("Please input a median radius", radius); Dialog.addNumber("Input a percentage of intensity to subtract", percentagesub); Dialog.show(); radius = Dialog.getNumber(); percentagesub = Dialog.getNumber(); title = getTitle(); run("Duplicate...", "title=med duplicate"); medid = getImageID(); run("Median...", "radius="+radius+" stack"); run("Multiply...", "value="+percentagesub + " stack"); imageCalculator("Subtract create stack", title,"med"); rename(title+"_med"+radius); setSlice(round(nSlices()/2)); resetMinAndMax(); selectImage(medid); close(); // Three commands you may want to add are: // resetMinAndMax(); or other contrast adjustment // run("Median...", "radius=1"); to remove one pixel noise // run("CLAHE ", "blocksize=21 histogram=512 maximum=4"); with numbers that work for your images }