Skip to Content
Mastering OpenCV 4 with Python
book

Mastering OpenCV 4 with Python

by Alberto Fernández Villán
March 2019
Intermediate to advanced
532 pages
13h 2m
English
Packt Publishing
Content preview from Mastering OpenCV 4 with Python

Grayscale histogram equalization

Using the cv2.equalizeHist() function with the purpose of equalizing the contrast of a given grayscale image is pretty easy:

image = cv2.imread('lenna.png')gray_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)gray_image_eq = cv2.equalizeHist(gray_image)

In the grayscale_histogram_equalization.py script, we apply histogram equalization to three images. The first one is the original grayscale image. The second one is the original image but modified, in the sense that we have added 35 to every pixel of the image. The third one is the original image but modified, in the sense that we have subtracted 35 from every pixel of the image. We have also calculated histograms before and after the equalization of the histogram. ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

OpenCV 4 with Python Blueprints - Second Edition

OpenCV 4 with Python Blueprints - Second Edition

Dr. Menua Gevorgyan, Michael Beyeler (USD), Arsen Mamikonyan, Michael Beyeler
Learning OpenCV 3

Learning OpenCV 3

Adrian Kaehler, Gary Bradski
Machine Learning for OpenCV 4 - Second Edition

Machine Learning for OpenCV 4 - Second Edition

Aditya Sharma, Michael Beyeler (USD), Vishwesh Ravi Shrimali, Michael Beyeler

Publisher Resources

ISBN: 9781789344912Supplemental Content