Login  Register

Re: Scripting IJ with javascript

Posted by Thomas Boudier on Feb 21, 2009; 6:37pm
URL: http://imagej.273.s1.nabble.com/Scripting-IJ-with-javascript-tp3693611p3693617.html

Hi Gabriel,

Why not use the duplicate function ?

erodeExact();

function erodeExact() {
var imp = IJ.getImage();
ip=imp.getProcessor();
ipcopy=ip.duplicate();
 ip.invert();
 ip.erode();
 ip.invert();
 imp.updateAndDraw();
 new ImagePlus("original",ipcopy).show();
}


Cheers,

Thomas

> 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
>
>
>  


--
/*****************************************************/
 Thomas Boudier, MCU Université Pierre et Marie Curie
 UMR 7101 / IFR 83. Bat A 328, Campus Jussieu
 Tél : 01 44 27 35 78  Fax : 01 44 27 25 08
/*****************************************************/