Posted by
Rasband, Wayne (NIH/NIMH) [E] on
URL: http://imagej.273.s1.nabble.com/Plug-in-recorder-tp5003030p5003038.html
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.htmlthat 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