0

I've found this post which uses the IJ.runMacro() method, but I'm confused as to what the "Clown (14K)" refers to, and I want to use a macro that I made myself, not one downloaded from imageJ's website.

My macro is just this for now:

run("Non-local Means Denoising", "sigma=5 smoothing_factor=1");

and that works in ImageJ when I use the batch processor. (Non-Local Means Denoising is an ImageJ Plugin)

My two questions are these:

  • How do I call a macro that I made using the IJ.runMacro method (or alternative)?

  • How do I specify what image the runMacro method will affect?

Thank you for your time.

Community
  • 1
  • 1
Nexion21
  • 149
  • 11
  • Clown (14K) refers to a sample image that comes with ImageJ. https://imagej.nih.gov/ij/docs/properties.html – Piglet Dec 24 '16 at 18:26
  • @Piglet ah, thank you for linking that. Would you happen to know how to specify which image I'd like to run the macro on? I've tried replacing "Clown (14K)" with my image directory but that definitely isn't correct., because it gives me an "Unrecognized command" error message. – Nexion21 Dec 24 '16 at 18:32
  • Please read https://imagej.nih.gov/ij/docs/macro_reference_guide.pdf Search open – Piglet Dec 25 '16 at 11:56

1 Answers1

1

I finally found the answer to my question here

The line of code that ended up solving it was:

System.setProperty("plugins.dir", "C:\\Users\\Speedy Octopus\\Downloads\\ij150-win-java8\\ImageJ\\plugins");

So the entire Test class looks like this now:

import ij.IJ;
import ij.ImagePlus;
import ij.io.FileSaver;
import ij.plugin.PlugIn;


public class Test implements PlugIn {

public static void main(String[] args) {

    Test test = new Test();
    test.run("Denoise.ijm");

}

@Override
public void run(String arg0) {
    String directory = "C:\\Users\\Speedy Octopus\\Desktop\\10Cover Shots\\10.JPG";

    ImagePlus imp = IJ.openImage(directory);
    FileSaver fileSaver = new FileSaver(imp);

    System.setProperty("plugins.dir", "C:\\Users\\Speedy Octopus\\Downloads\\ij150-win-java8\\ImageJ\\plugins");
    IJ.run(imp, "Non-local Means Denoising", "sigma=5 smoothing_factor=1");
    fileSaver.saveAsJpeg("C:\\Users\\Speedy Octopus\\Desktop\\10Cover Shots\\10edited.JPG");
}
}
Nexion21
  • 149
  • 11