Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

stough 202-

Colab runs notebooks in the cloud, so you don’t need to install anything, and it offers a free GPU for the neural network chapters. But the book’s notebooks are not standalone: they load images from dip_pics/ and helper code from dip_utils/, through relative paths like ../dip_utils. A notebook opened by itself in Colab has none of that.

This notebook sets you up properly. Run it once (and again whenever you want the latest version of the book):

  1. It copies the whole book (a git clone) into your Google Drive, so the book and your work in it survive after the Colab session ends.

  2. It prepares a folder in your Drive for the datasets that a few chapters use.

  3. It prints a short setup cell that you paste at the top of any book notebook you open in Colab.

If you’re working locally (VS Code or JupyterLab), you don’t need this; see the README instead.

1. Settings

If you made a private fork of the book, put its address in REPO_URL. A private repository needs a GitHub personal access token with read access to it. Don’t paste the token into this notebook: add it as a Colab secret (the key icon in the left sidebar), and put the secret’s name in TOKEN_SECRET.

2. Copy the book into your Drive

Colab will ask for permission to use your Google Drive. If the book is already there from an earlier run, this updates it instead (git pull); your own changes to the notebooks are kept, but if they conflict with an update, git will say so and leave everything as it was.

3. Datasets and packages

Colab already has NumPy, Matplotlib, scikit-image, scikit-learn, SciPy, OpenCV and PyTorch. It lacks ipympl, which draws the book’s interactive (%matplotlib widget) figures; the setup cell below installs it in each session.

The MNIST data downloads itself the first time it’s used. The ORL and Yale face datasets have to be downloaded by hand: see the dataset table in the README, and put them in the dip_data folder this cell creates in your Drive (e.g. dip_data/ORL/).

4. Open a chapter

In Colab, choose File → Open notebook → Google Drive, and open any notebook from the imageprocessing-awesome folder, for example Color/color_HSV.ipynb. Then, before anything else, insert a code cell at the very top of that notebook, paste in the cell printed below, set CHAPTER to the notebook’s folder, and run it. It moves into that folder (so ../dip_utils and ../dip_pics are found), tells the book where your datasets are, and turns on interactive figures.

For the neural network chapters, also choose Runtime → Change runtime type → GPU.

Your work is saved in the notebooks in your Drive. Remember that if you’re in a course using this book, the activities are there to help you learn: see the note on AI in the preface.