diff options
author | Patrick Simianer <p@simianer.de> | 2016-11-26 12:40:34 +0100 |
---|---|---|
committer | Patrick Simianer <p@simianer.de> | 2016-11-26 12:40:34 +0100 |
commit | 162187608bbaf1f79d38c88803754c8e58359129 (patch) | |
tree | 24a10ed5f715585215377854af6c0cbde276ca83 /display-histogram.py | |
parent | 89ec4030ba4e426e6e7992336a6665ef9d37ec48 (diff) |
cleanup
Diffstat (limited to 'display-histogram.py')
-rw-r--r-- | display-histogram.py | 33 |
1 files changed, 0 insertions, 33 deletions
diff --git a/display-histogram.py b/display-histogram.py deleted file mode 100644 index 0f0fedd..0000000 --- a/display-histogram.py +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env python - -""" -Sample code for displaying image histogram with Matplotlib -""" - -import cv2 -import matplotlib.pyplot as plt - -def show_histogram(im): - """ Function to display image histogram. - Supports single and three channel images. """ - if im.ndim == 2: - # Input image is single channel - plt.hist(im.flatten(), 256, range=(0,250), fc='k') - plt.show() - elif im.ndim == 3: - # Input image is three channels - fig = plt.figure() - fig.add_subplot(311) - plt.hist(im[...,0].flatten(), 256, range=(0,250), fc='b') - fig.add_subplot(312) - plt.hist(im[...,1].flatten(), 256, range=(0,250), fc='g') - fig.add_subplot(313) - plt.hist(im[...,2].flatten(), 256, range=(0,250), fc='r') - plt.show() - -if __name__ == '__main__': - im = cv2.imread("lena.jpg"); - if not (im == None): - show_histogram(im) - - |