Login  Register

Re: Scripting IJ with javascript

Posted by Gabriel Landini on Feb 22, 2009; 1:44pm
URL: http://imagej.273.s1.nabble.com/Scripting-IJ-with-javascript-tp3693611p3693613.html

Strangely, the same  js below does not execute when run from the menu:

Error: missing ; before statement (<Unknown source>#9) in <Unknown source> at
line number 9

but executes OK from a macro window.

----8<----
erodeExact();

function erodeExact() {
 var imp = IJ.getImage();
 var ip = imp.getProcessor();
 ip.snapshot();
 Undo.setup(Undo.FILTER, imp);
 ip.invert();
 if (Prefs.blackBackground)
    ip.erode();
 else
    ip.dilate();
 ip.invert();
 imp.updateAndDraw();
}
----8<----

I tried adding { } after the "if" but makes no difference
Cheers

Gabriel