Scripting IJ with javascript
Posted by Gabriel Landini on Feb 21, 2009; 3:02pm
URL: http://imagej.273.s1.nabble.com/Scripting-IJ-with-javascript-tp3693611.html
I have a couple of question regarding javascript and IJ:
Q1:How do I enable at least one Undo?
I created a js file, below, that erodes the white (as foreground) (the exact
erosion we discussed about a few days ago) :
----8<----
erodeExact();
function erodeExact() {
var imp = IJ.getImage();
var ip = imp.getProcessor();
ip.invert();
ip.erode();
ip.invert();
imp.updateAndDraw();
}
----8<----
However this process cannot be undone. Is there a way to return to the
original image before running the script? If I execute ip.snapshot(); this is
not restored with the "undo" found in the Edit menu. I guess that there is no
way of undoing this?
Q2: Is there a way of finding out what is the status of the
Process>Binary>Options "black background"?
This is recorded with:
run("Options...", "iterations=1 black count=1");
But how do I know whether "black" is true or false in javascript?
Many thanks in advance.
Cheers
Gabriel