Use Ctrl+\ (Backslash) to inject a canvas at the cursor position in the selected cell. Draw on it:
In-line, canvases act as variable names. On running the cell, silently injected code sets the variables equal to NumPy image data. (This performs a number of imports: base64, numpy as np, io.BytesIO, and PIL.Image. If you pass the image as a single argument to a function (e.g. foo(canvas)) it will also pass the locals() dict as an added '.locals' attribute of the nparray object.)
Pass handwritten digits to an MNIST recognizer for all I care! Here's an example of a magical QCR function recognizing a handwritten quantum circuit (function not included):
And here's an obligatory MNIST example (see examples/ folder for more):
- You can copy+paste canvases like you would text.
- Experimental: You can also paste images and they will be loaded into a canvas. You could, for instance, set a variable equal to an image copied from Google Images.
- Drag right/bottom sides of canvas to resize.
- Experimental: When moused over the resize area, click (without moving the cursor) to open a modal dialog and enter width+height pixel values.
- Click on a canvas to enter full-screen view. It contains a toolbar with basic drawing operations, including undo/redo. Click off the view to minimize:
- Install Jupyter Notebook Extensions.
- Find the nbextensions folder. On Mac, it's in /Users/yourusername/Library/Jupyter.
- Place the notate-jupyter folder inside.
- If you had Jupyter Notebook open, restart it. On the Jupyter Home page, click the Nbextensions tab. Click 'Notate' to enable.
Relatedly, ensure your namespace doesn't use names Image, BytesIO, or base64 except where imported from the PIL, io, and base64 libraries. Note that I cannot guarantee compatibility with other extensions.