Login  Register

Re: Problems using ImageJ and Javascript

Posted by Jan Eglinger on Nov 10, 2015; 12:59pm
URL: http://imagej.273.s1.nabble.com/Problems-using-ImageJ-and-Javascript-tp5014901p5014902.html

Hi Avital,

there's nothing wrong with the Javascript to Java array handling, as you
can see running the following script:

     importClass(Packages.ij.IJ);
     importClass(Packages.ij.plugin.RGBStackMerge);

     imp1 = IJ.createImage("Untitled1", "8-bit random", 80, 80, 1);
     imp2 = IJ.createImage("Untitled2", "8-bit random", 80, 80, 1);
     imp3 = IJ.createImage("Untitled3", "8-bit random", 80, 80, 1);

     var imgs = [];
     imgs.push(imp1);
     imgs.push(imp2);
     imgs.push(imp3);
     imgMrgd = RGBStackMerge.mergeChannels(imgs, false);
     imgMrgd.show();


which displays an RGB image as expected.
When I change the dimensions of a single image, I get:

javax.script.ScriptException:
sun.org.mozilla.javascript.internal.WrappedException: Wrapped
java.lang.IllegalArgumentException: Dimensions do not match
(Script.js.js#12) in Script.js.js at line number 12

but I also cannot merge these images using 'Image > Color > Merge
channels...', the error is:

   "The source images or stacks must have the same width and height."

Are you sure that your images impGFP, imRFP and impOutofFoc have the
same dimensions?


Jan



On 10.11.2015 13:34, Avital Steinberg wrote:

> Hi,
> I am trying to create a composite image with ImageJ. I'm scripting in
> Javascript.
>
> I am using the following commands:
>
> var imgs = [];
> imgs.push(impGFP);
> imgs.push(impRFP);
> imgs.push(impOutofFoc);
> imgMrgd = mrg.mergeChannels(imgs, false); // forming merged image
>
> I'm getting the following error message:
>
> "Dimensions do not match"
>
> The dimensions do match - I can merge the images using ImageJ's graphical
> user interface.
>
> I guess it's related to the fact that I'm supposed to give an ImagePlus[]
> array as an argument in the Java command, but since I created it in
> Javascript, it probably isn't converted well into Java.
>
> Does anyone have an idea how to solve this problem?
>
> Thanks,
> Avital
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html