In [8]:
%run ../../common.ipynb
import cv2, scipy, tifffile
from IPython.html.widgets import interact, IntTextWidget


Populating the interactive namespace from numpy and matplotlib

In [5]:
img = scipy.misc.lena().astype(np.uint8)

In [10]:
def fn(low_threshold, high_threshold):
    edges = cv2.Canny(img, low_threshold, high_threshold)
    figure(figsize=(16,8))
    plt.subplot(121)
    plt.imshow(edges, cmap="gray")
    plt.subplot(122)
    plt.imshow(img, cmap="gray")

interact(fn, low_threshold=IntTextWidget(min=10, max=1000, value=50), high_threshold=IntTextWidget(min=10, max=1000, value=100))


Out[10]:
<function __main__.fn>

In [11]:
%pylab qt
img = tifffile.imread('../mp.tif')
interact(fn, low_threshold=IntTextWidget(min=10, max=1000, value=50), high_threshold=IntTextWidget(min=10, max=1000, value=100))