Login  Register

Re: launch functions in java

Posted by CARL Philippe (LBP) on Jun 12, 2016; 9:29pm
URL: http://imagej.273.s1.nabble.com/launch-functions-in-java-tp5016624p5016630.html

Hi Wayne,

How are you doing?

I thank you very much for your answer and I indeed confirm (i.e. by checking it) all what you had written.
Nevertheless, please find the following java code of a quite small plugin which had as well been generated by using the recorder (i.e. by using Plugins>Macros>Record):
        ImagePlus imp = IJ.openImage("http://wsr.imagej.net/images/blobs.gif");
        imp = IJ.openImage("http://wsr.imagej.net/images/blobs.gif");
        IJ.run(imp, "Images to Stack", "name=Stack title=[] use");
        imp.show();
Which is given the error message: "No images are open.". What is the issue about it?

Besides this, within a macro, it is possible to import data from a launched plugin by using a defined "Ext." through the macro extensions features.
But how can this be done by launching the plugin from an another plugin?

I thank you very much in advance fir your help and wish you a nice end of week-end.

Kindest regards,

Philippe

Le Samedi 11 Juin 2016 17:14 CEST, "Rasband, Wayne (NIH/NIMH) [E]" <[hidden email]> a écrit:

> > On Jun 10, 2016, at 11:11 AM, Philippe CARL <[hidden email]> wrote:
> >
> > Dear all,
> >
> > In a plugin the function crop can be launched through: IJ.run("Crop”);
>
> It is best to use the recorder (Plugins>Macros>Record) to generate code. This is the code recorded when you open the Boats sample image and crop it:
>
>   imp = IJ.openImage("http://wsr.imagej.net/images/boats.gif");
>   imp.setRoi(136,185,125,177);
>   IJ.run(imp, "Crop", "”);
>   imp.show();
>
> > But given that the crop corresponds (Ctrl +l) to the function:
> > ij.plugin.Resizer("crop")
> >
> > How can it be launched through a call?
>
> The Resizer class is not designed to be called directly. Instead, call the ImageProcessor.crop() method. Here is an example:
>
>   imp = IJ.openImage("http://wsr.imagej.net/images/boats.gif");
>   ip = imp.getProcessor();
>   ip.setRoi(136,185,125,177);
>   ip = ip.crop();
>   new ImagePlus("Lighthouse",ip).show();
>
> > And is it better to use a call rather than a IJ.run instruction or inverse?
>
> It is better to use IJ.run(imp,"Crop","”); since it works with stacks and overlays, and it preserves spatial calibration.
>
> -wayne
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html





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