Search code examples
pluginsjythonimagej

Using imageJ plugin from jython : how to call it in the script?


I want to use Jython to analyse images on ImageJ, but I don't know how to call existing plugins and run it from the script. Do you have an idea ? Thanks.


Solution

  • Use the syntax from packagename import namespace

    An example:

    from ij import IJ, ImagePlus
    from ij.plugin.filter import RankFilters
    
    imp = IJ.getImage()
    ip = imp.getProcessor().convertToFloat()
    
    radius = 2
    RankFilters().rank(ip, radius, RankFilters.MEDIAN)
    
    imp2 = ImagePlus(imp.title + " median filtered", ip)
    imp2.show()
    

    You can find the name of specific plugins by searching the command finder.