SimpleITK.Show() generates error in ImageJ on Macbook

316 Views Asked by At

I'm struggling with imagej on Jupyter. This is part of the code that i'm running:

def ImageGen(a,b,x_0,y_0, sigma_x, sigma_y, theta ):
    g=GaussianFunc(x_0,y_0,sigma_x,sigma_y,theta)
    g2=sitk.GetImageFromArray(g)
    res=a*g2+b
    if ("SITK_NOSHOW" not in os.environ):
        sitk.Show(res, title="res", debugOn=True)
Image_a=ImageGen(40,100,100,200,20,20,0)

and the output is:

Exception thrown in SimpleITK Show: 
../../Code/IO/src/sitkImageViewer.cxx:620:
sitk::ERROR: No ImageJ/Fiji application found.

The ImageJ is already in the applications and it works well, so i'm not sure what is the reason for this error. I would be grateful if anyone can help me to fix that. Thank you in advance!

1

There are 1 best solutions below

0
On

Where is your ImageJ executable located? Clearly SimpleITK is not finding it. You can use the SITK_SHOW_COMMAND environment variable give the full path to the ImageJ executable.

For instance, on my Mac, I could set SITK_SHOW_COMMAND as follows:

export SITK_SHOW_COMMAND=/Users/dchen/Applications/Fiji.app/Contents/MacOS/ImageJ-macosx

By default SimpleITK searches for Fiji/ImageJ in /Applications and ~/Applications

You can read more about displaying images with SimpleITK in Jupyter notebooks here: http://insightsoftwareconsortium.github.io/SimpleITK-Notebooks/Python_html/04_Image_Display.html