changing the pixel size in a plugin

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

changing the pixel size in a plugin

Philippe GENDRE
Dear List,

I am writing an imagej plugin to apply a specific spatial calibration to an
image.

I use the following line to do that : IJ.run("Set Scale...", "distance=1
known=&myvariable unit=µm global") but it doesn't work. Imagej returns a
message such like : "Macro error.Numeric value expected in run()
fuction.Dialog box title :"Set Scale". Key : "known distance". Value or
variable name :"my variable".

Help to solve that would be apreciated.

Best regards,

Philippe
Reply | Threaded
Open this post in threaded view
|

Re: changing the pixel size in a plugin

Michael Schmid
Hi Philippe,

the notation with the ampersand '&' for variables works in macros only, not in plugins.
In a plugin you need

 IJ.run("Set Scale...", "distance=1 known="+myvariable+" unit=µm global");

IJ.run needs Strings as arguments. In Java, String concatenation with the '+' operator automatically converts non-String arguments to a String by the respective toString method (Double.toString for a double variable).


Michael
________________________________________________________________
On Jan 23, 2012, at 12:31, Philippe GENDRE wrote:

> Dear List,
>
> I am writing an imagej plugin to apply a specific spatial calibration to an
> image.
>
> I use the following line to do that : IJ.run("Set Scale...", "distance=1
> known=&myvariable unit=µm global") but it doesn't work. Imagej returns a
> message such like : "Macro error.Numeric value expected in run()
> fuction.Dialog box title :"Set Scale". Key : "known distance". Value or
> variable name :"my variable".
>
> Help to solve that would be apreciated.
>
> Best regards,
>
> Philippe