Login  Register

Problems converting macro to plugin

Posted by Geoff Nelson on Sep 13, 2005; 2:46pm
URL: http://imagej.273.s1.nabble.com/Problems-converting-macro-to-plugin-tp3704833.html

Hello

I have recorded a macro and am trying to convert it to a plugin. The goal is
to take a scanned image that has some light coloured parts on a black
background and determine the total area and average size. The variable that
we are trying to monitor changes through the process. The macro runs
perfectly but I cannot get it converted to a macro. I am not a Java
programmer and so have no idea what is wrong. Can someone please help.

The macro thresholds an image and then the image is analysed and the area
that has been differentiated by thresholding is then put in the results
table.

The macro looks like this.
setAutoThreshold();
//run("Threshold...");
setThreshold(0, 140);
setThreshold(0, 140);
run("Threshold", "thresholded remaining black");
setAutoThreshold();
run("Set Scale...", "distance=11.860 known=1 pixel=1 unit=mm global");
run("Analyze Particles...", "minimum=10 maximum=999999 bins=20 show=Nothing
display exclude clear");


The .java file looks like this:
import ij.*;
import ij.process.*;
import ij.gui.*;
import java.awt.*;
import ij.plugin.*;

public class Stickies_ implements PlugIn {

 public void run(String arg) {
  IJ.setAutoThreshold();
  IJ.run("Threshold...");
  IJ.setThreshold(0, 140);
  IJ.setThreshold(0, 140);
  IJ.run("Threshold", "thresholded remaining black");
  IJ.setAutoThreshold();
  IJ.run("Set Scale...", "distance=11.86 known=1 pixel=1 unit=mm global");
  IJ.run("Set Measurements...", "area redirect=None decimal=3");
  IJ.run("Analyze Particles...", "minimum=10 maximum=999999 bins=20
show=Nothing display exclude clear");
 }

}


And these are the errors:
:\Program Files\ImageJ\plugins\Stickies_.java:10: Method setAutoThreshold()
not found in class ij.IJ.
  IJ.setAutoThreshold();

Kind regards

Geoff Nelson