Login  Register

Re: Plug-in recorder

Posted by Rob van 't Hof-2 on May 16, 2013; 8:42pm
URL: http://imagej.273.s1.nabble.com/Plug-in-recorder-tp5003030p5003035.html

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