Hello! I am getting started with ImageJ, the code below does bicubic interpolation and unsharp masking. I want to take the Scale of bicubic interpolation, radius of gaussian blur and mask coefficient as user input. Please suggest the changes needed?
You could do this with a plugin if you want. You also can certainly accomplish this with the macro language or as a script quite easily. You can use script parameters to automagically generate the dialog for you. In Jython, you could implement the bicubic interpolation and dialog for the scaling factors as follows:
# @ImagePlus(label="Image to process") imp
# @float(label="x scaling factor: ") x_factor
# @float(label="x scaling factor: ") y_factor
from ij import IJ
IJ.run(imp, "Scale...", "x="+str(x_factor)+" y="+str(y_factor)+" interpolation=Bilinear average create");
I hope this helps you out! Let me know how adding the additional processing steps go!
When you give a blank parameter string to IJ.run(), as in the
above sample code, the commands being called are generally
smart enough to open up their own standard parameter dialogs
to let the user enter the parameter values interactively.
(I don’t know how to make this happen only using the macro
recorder, but it’s certainly quite easy to edit the code to put
in the empty parameter string by hand.)
Also, if you want greater control over getting the parameters
interactively than offered by this method (or script paramters),
it is also relatively easy to use a Generic Dialog to customize
how you read in the parameters.
How are you running it? It works for me when I do the following:
I ran it as follows:
File -> New -> Script.
Copy and paste the script above.
Set the language to Python.
I have found the following feature of Fiji very useful. If I then save my Python script as a file in the …/Fiji.app/plugins/Scripts/Plugins/ in a new folder, perhaps “My_Scripts” as filename_.py then I can run it from the ImageJ menu by navigating through Plugins -> My_Scripts -> filename. You must have the underscore at the end of the filename. More on that can be found here.