Let’s optimize! Running 15× faster with a situation-specific algorithm

Let’s speed up some software! Our motivation: we have an image, a photo
of some text from a book. We want to turn it into a 1-bit image, with
just black and white, extracting the text so we can easily read it.

We’ll use an example image from
scikit-image, an excellent image processing
library:

from skimage.data import page
import numpy as np
IMAGE = page()
assert IMAGE.dtype == np.uint8

Here’s what it looks like (it’s licensed under this
license
):

A photo of a page, with a shadow on one side

The task we’re trying to do—turning darker

 

 

 

To finish reading, please visit source site