Visionary Code Lab

Unleashing the Power of Tech Innovation in AI and Beyond

Introduction to Histogram Techniques in Digital Image Processing

rahuldevyadav Avatar

Introduction

Understanding Histograms in Digital Image Processing

Basic Histogram Computation

"""
Python Example: Basic Histogram Computation
"""

import cv2
import numpy as np
from matplotlib import pyplot as plt

def plot_histogram(image_path):
    image = cv2.imread(image_path, cv2.IMREAD_GRAYSCALE)
    histogram = cv2.calcHist([image], [0], None, [256], [0, 256])
    plt.figure()
    plt.title("Grayscale Histogram")
    plt.xlabel("Pixel Intensity")
    plt.ylabel("Frequency")
    plt.plot(histogram)
    plt.xlim([0, 256])
    plt.show()

plot_histogram('path_to_your_image.jpg')

Dark image
Light Image
High Contrast Image
Low Contrast Image

NOTE: Image Source https://www.imageprocessingplace.com/DIP-3E/dip3e_book_images_downloads.htm

Conclusion


  • Gonzalez, Rafael C. Digital image processing. Pearson education india, 2009.
  • Burger, Wilhelm, and Mark J. Burge. Digital image processing: An algorithmic introduction. Springer Nature, 2022.
  • Furht, Borko, Esad Akar, and Whitney Angelica Andrews. Digital Image Processing: Practical Approach. Springer International Publishing, 2018.
  • Baskar, A., Rajappa, M., Vasudevan, S.K., & Murugesh, T.S. (2023). Digital Image Processing (1st ed.). Chapman and Hall/CRC. https://doi.org/10.1201/9781003217428.
rahuldevyadav Avatar

More Articles & Posts