Manipulating the exposure of an image
The exposure of an image tells us whether the image is too dark, too light, or balanced. It can be measured with a histogram of the intensity values of all pixels. Improving the exposure of an image is a basic image-editing operation. As we will see in this recipe, it can be done easily with scikit-image.
Getting ready
The scikit-image
command should be included by default in Anaconda. Otherwise, you can always install it manually with conda install scikit-image
.
How to do it...
Let's import the packages:
>>> import numpy as np import matplotlib.pyplot as plt import skimage.exposure as skie %matplotlib inline
We open an image with Matplotlib. We only take a single RGB component to have a grayscale image (it is a very crude way of doing it, we give much better ways at the end of this recipe):
>>> img = plt.imread('https://github.com/ipython-books/' 'cookbook-2nd-data/blob/master/' 'beach...