April 2020
Intermediate to advanced
438 pages
12h 2m
English
To execute this recipe, perform the following steps:
def plot_image(image, title): plt.imshow(image) plt.title(title, size=20) plt.axis('off') def plot_hist(img): colors = ['r', 'g', 'b'] cdf = np.zeros((256,3)) for i in range(3): hist, bins = np.histogram(img[...,i].flatten(),256,[0,256], \ normed=True) cdf[...,i] = hist.cumsum() cdf_normalized = cdf[...,i] * hist.max() / cdf.max() plt.plot(cdf_normalized, color = colors[i], \ label='cdf ({})'.format(colors[i])) binWidth = bins[1] - bins[0] plt.bar(bins[:-1], hist*binWidth, binWidth, label='hist ({})'.format(colors[i])) plt.xlim([0,256]) ...Read now
Unlock full access