Jupyter Snippet CB2nd 01_exposure
Jupyter Snippet CB2nd 01_exposure
11.1. Manipulating the exposure of an image
import numpy as np
import matplotlib.pyplot as plt
import skimage.exposure as skie
%matplotlib inline
img = plt.imread('https://github.com/ipython-books/'
'cookbook-2nd-data/blob/master/'
'beach.png?raw=true')[..., 0]
def show(img):
# Display the image.
fig, (ax1, ax2) = plt.subplots(1, 2,
figsize=(12, 3))
ax1.imshow(img, cmap=plt.cm.gray)
ax1.set_axis_off()
# Display the histogram.
ax2.hist(img.ravel(), lw=0, bins=256)
ax2.set_xlim(0, img.max())
ax2.set_yticks([])
plt.show()
show(img)
show(skie.rescale_intensity(
img, in_range=(0.4, .95), out_range=(0, 1)))
show(skie.equalize_adapthist(img))