Login  Register

Plug-in recorder

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options Options
Embed post
Permalink
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Plug-in recorder

João Silva
Hi everyone!

I was using the plug-in recorder to save the following code:

IJ.run(imp2, "Gray Morphology", "radius=2 type=circle operator=erode");

I wanted to know if it is possible to do something equivalent to this:


int sizeE = 2; //sizeE is asked before since I don't want to call the plug-in I'm re-using itself
IJ.run(imp2, "Gray Morphology", "radius=sizeE type=circle operator=erode");

I have already tried this and ImageJ pops a dialog window saying:

Macro Error

Numeric Vvalue expected in run() function
Dialog box title: "Parameters"
Key: "radius of the structure element(pixels):"
Value or variable name: "sizeE"


I really don't know what to do.



Best Regards,

João

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: Plug-in recorder

Rob van 't Hof-2
Hi,
you need to built up the string for passing arguments to the plugin.
SizeE is a number not a string.
code should be like:

int sizeE = 2; //sizeE is asked before since I don't want to call the plug-in I'm re-using itself
IJ.run(imp2, "Gray Morphology", "radius=" + sizeE + "type=circle operator=erode");

hope this helps,
Rob


On 16/05/2013 19:13, João Silva wrote:

> Hi everyone!
>
> I was using the plug-in recorder to save the following code:
>
> IJ.run(imp2, "Gray Morphology", "radius=2 type=circle operator=erode");
>
> I wanted to know if it is possible to do something equivalent to this:
>
>
> int sizeE = 2; //sizeE is asked before since I don't want to call the plug-in I'm re-using itself
> IJ.run(imp2, "Gray Morphology", "radius=sizeE type=circle operator=erode");
>
> I have already tried this and ImageJ pops a dialog window saying:
>
> Macro Error
>
> Numeric Vvalue expected in run() function
> Dialog box title: "Parameters"
> Key: "radius of the structure element(pixels):"
> Value or variable name: "sizeE"
>
>
> I really don't know what to do.
>
>
>
> Best Regards,
>
> João
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
_____________________________
Dr. Rob van 't Hof
Reader

Centre for Molecular Medicine
MRC IGMM
University of Edinburgh
Western General Hospital
Crewe Road, Edinburgh EH4 2XU
United Kingdom

Phone: (+44)-131-6511031
email: [hidden email]
_____________________________

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: Plug-in recorder

dscho
In reply to this post by João Silva
Hi João,

On Thu, 16 May 2013, João Silva wrote:

> int sizeE = 2; //sizeE is asked before since I don't want to call the plug-in I'm re-using itself
> IJ.run(imp2, "Gray Morphology", "radius=sizeE type=circle operator=erode");

The reason this does not work is because you put "sizeE" *inside* a
String, therefore it is treated as plain text, not a variable name. You
probably wanted to let Java concatenate the value of the variable, though:

        ... "radius=" + sizeE + "..."

instead of

        ... "radius=sizeE ..."

Hth,
Johannes

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: Plug-in recorder

João Silva
In reply to this post by Rob van 't Hof-2
Hello!

It sure does! Thanks a lot Rob!

By the way, I am trying to do something like this but i keep getting a null pointer exception, could you tell me why?

ImagePlus orig = IJ.getImage();
ImagePlus copy1 = orig.duplicate();
ImagePlus copy2 = orig.duplicate();

//then I use a plug-in with orig and after that I do this

 IJ.run(copy2, "Gray Morphology", "radius=20 type=circle operator=close");

And then this tells me it has a null pointer exception...

Don't know really what to do.

Best Regards,

João
________________________________________
De: ImageJ Interest Group [[hidden email]] em nome de Rob van 't Hof [[hidden email]]
Enviado: quinta-feira, 16 de Maio de 2013 20:12
Para: [hidden email]
Assunto: Re: Plug-in recorder

Hi,
you need to built up the string for passing arguments to the plugin.
SizeE is a number not a string.
code should be like:

int sizeE = 2; //sizeE is asked before since I don't want to call the plug-in I'm re-using itself
IJ.run(imp2, "Gray Morphology", "radius=" + sizeE + "type=circle operator=erode");

hope this helps,
Rob


On 16/05/2013 19:13, João Silva wrote:

> Hi everyone!
>
> I was using the plug-in recorder to save the following code:
>
> IJ.run(imp2, "Gray Morphology", "radius=2 type=circle operator=erode");
>
> I wanted to know if it is possible to do something equivalent to this:
>
>
> int sizeE = 2; //sizeE is asked before since I don't want to call the plug-in I'm re-using itself
> IJ.run(imp2, "Gray Morphology", "radius=sizeE type=circle operator=erode");
>
> I have already tried this and ImageJ pops a dialog window saying:
>
> Macro Error
>
> Numeric Vvalue expected in run() function
> Dialog box title: "Parameters"
> Key: "radius of the structure element(pixels):"
> Value or variable name: "sizeE"
>
>
> I really don't know what to do.
>
>
>
> Best Regards,
>
> João
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
_____________________________
Dr. Rob van 't Hof
Reader

Centre for Molecular Medicine
MRC IGMM
University of Edinburgh
Western General Hospital
Crewe Road, Edinburgh EH4 2XU
United Kingdom

Phone: (+44)-131-6511031
email: [hidden email]
_____________________________

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

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: Plug-in recorder

Rob van 't Hof-2
Hi Joao,
That's because .getImage() is not doing what you think it does. Have a
look at the documentation at
http://rsb.info.nih.gov/ij/developer/api/ij/ImagePlus.html

The function you want is:
ImagePlus orig=WindowManager.getCurrentImage();

bye,
Rob

On 16/05/2013 21:21, João Silva wrote:

> Hello!
>
> It sure does! Thanks a lot Rob!
>
> By the way, I am trying to do something like this but i keep getting a null pointer exception, could you tell me why?
>
> ImagePlus orig = IJ.getImage();
> ImagePlus copy1 = orig.duplicate();
> ImagePlus copy2 = orig.duplicate();
>
> //then I use a plug-in with orig and after that I do this
>
>   IJ.run(copy2, "Gray Morphology", "radius=20 type=circle operator=close");
>
> And then this tells me it has a null pointer exception...
>
> Don't know really what to do.
>
> Best Regards,
>
> João
> ________________________________________
> De: ImageJ Interest Group [[hidden email]] em nome de Rob van 't Hof [[hidden email]]
> Enviado: quinta-feira, 16 de Maio de 2013 20:12
> Para: [hidden email]
> Assunto: Re: Plug-in recorder
>
> Hi,
> you need to built up the string for passing arguments to the plugin.
> SizeE is a number not a string.
> code should be like:
>
> int sizeE = 2; //sizeE is asked before since I don't want to call the plug-in I'm re-using itself
> IJ.run(imp2, "Gray Morphology", "radius=" + sizeE + "type=circle operator=erode");
>
> hope this helps,
> Rob
>
>
> On 16/05/2013 19:13, João Silva wrote:
>> Hi everyone!
>>
>> I was using the plug-in recorder to save the following code:
>>
>> IJ.run(imp2, "Gray Morphology", "radius=2 type=circle operator=erode");
>>
>> I wanted to know if it is possible to do something equivalent to this:
>>
>>
>> int sizeE = 2; //sizeE is asked before since I don't want to call the plug-in I'm re-using itself
>> IJ.run(imp2, "Gray Morphology", "radius=sizeE type=circle operator=erode");
>>
>> I have already tried this and ImageJ pops a dialog window saying:
>>
>> Macro Error
>>
>> Numeric Vvalue expected in run() function
>> Dialog box title: "Parameters"
>> Key: "radius of the structure element(pixels):"
>> Value or variable name: "sizeE"
>>
>>
>> I really don't know what to do.
>>
>>
>>
>> Best Regards,
>>
>> João
>>
>> --
>> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>>
> --
> _____________________________
> Dr. Rob van 't Hof
> Reader
>
> Centre for Molecular Medicine
> MRC IGMM
> University of Edinburgh
> Western General Hospital
> Crewe Road, Edinburgh EH4 2XU
> United Kingdom
>
> Phone: (+44)-131-6511031
> email: [hidden email]
> _____________________________
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
_____________________________
Dr. Rob van 't Hof
Reader

Centre for Molecular Medicine
MRC IGMM
University of Edinburgh
Western General Hospital
Crewe Road, Edinburgh EH4 2XU
United Kingdom

Phone: (+44)-131-6511031
email: [hidden email]
_____________________________

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: Plug-in recorder

Rasband, Wayne (NIH/NIMH) [E]
In reply to this post by João Silva
On May 16, 2013, at 4:21 PM, João Silva wrote:

> Hello!
>
> It sure does! Thanks a lot Rob!
>
> By the way, I am trying to do something like this but i keep getting a null pointer exception, could you tell me why?
>
> ImagePlus orig = IJ.getImage();
> ImagePlus copy1 = orig.duplicate();
> ImagePlus copy2 = orig.duplicate();
>
> //then I use a plug-in with orig and after that I do this
>
> IJ.run(copy2, "Gray Morphology", "radius=20 type=circle operator=close");
>
> And then this tells me it has a null pointer exception...
>
> Don't know really what to do.

There is a bug in the Gray Morphology plugin that causes it to throw an exception if the image being processed is not displayed. There is an updated version of the plugin at

    http://rsbweb.nih.gov/ij/plugins/gray-morphology.html

that fixes this bug, or work around it by displaying the image, as in this example:

  ImagePlus orig = IJ.getImage();
  ImagePlus copy2 = orig.duplicate();
  copy2.show();
  radius = 20;
  IJ.run(copy2, "Gray Morphology", "radius="+radius+" type=circle operator=close");

-wayne


> ________________________________________
> De: ImageJ Interest Group [[hidden email]] em nome de Rob van 't Hof [[hidden email]]
> Enviado: quinta-feira, 16 de Maio de 2013 20:12
> Para: [hidden email]
> Assunto: Re: Plug-in recorder
>
> Hi,
> you need to built up the string for passing arguments to the plugin.
> SizeE is a number not a string.
> code should be like:
>
> int sizeE = 2; //sizeE is asked before since I don't want to call the plug-in I'm re-using itself
> IJ.run(imp2, "Gray Morphology", "radius=" + sizeE + "type=circle operator=erode");
>
> hope this helps,
> Rob
>
>
> On 16/05/2013 19:13, João Silva wrote:
>> Hi everyone!
>>
>> I was using the plug-in recorder to save the following code:
>>
>> IJ.run(imp2, "Gray Morphology", "radius=2 type=circle operator=erode");
>>
>> I wanted to know if it is possible to do something equivalent to this:
>>
>>
>> int sizeE = 2; //sizeE is asked before since I don't want to call the plug-in I'm re-using itself
>> IJ.run(imp2, "Gray Morphology", "radius=sizeE type=circle operator=erode");
>>
>> I have already tried this and ImageJ pops a dialog window saying:
>>
>> Macro Error
>>
>> Numeric Vvalue expected in run() function
>> Dialog box title: "Parameters"
>> Key: "radius of the structure element(pixels):"
>> Value or variable name: "sizeE"
>>
>>
>> I really don't know what to do.
>>
>>
>>
>> Best Regards,
>>
>> João

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