pythonimagescikit-imageviewer

Command won't stop running


I have the following piece of code

import skimage.color
import skimage.io
import skimage.viewer
import skimage.filters

fname = "/Users/harryhat/Desktop/Code/Experimental/Frames/frame00055.png"

# read image
image = skimage.io.imread(fname, as_gray=True)

# display the image
viewer = skimage.viewer.ImageViewer(image)
viewer.show()

However when I run the code, firstly the command won't stop running and secondly when I interrupt the command I have to restart the kernel to be able to type in the console. I was wondering why this would be the case / any other ways to do this. Any help would be much appreciated.


Solution

  • The skimage viewer is a Qt application. To run these in a notebook, you need to enable the Qt event loop integration by typing %gui qt in its own cell at the start of the notebook.

    Just by the way, the scikit-image viewer is going to be deprecated. I recommend trying out https://napari.org as an alternative. (But the advice above still applies!)