Book Image

The Computer Vision Workshop

By : Hafsa Asad, Vishwesh Ravi Shrimali, Nikhil Singh
Book Image

The Computer Vision Workshop

By: Hafsa Asad, Vishwesh Ravi Shrimali, Nikhil Singh

Overview of this book

Computer Vision (CV) has become an important aspect of AI technology. From driverless cars to medical diagnostics and monitoring the health of crops to fraud detection in banking, computer vision is used across all domains to automate tasks. The Computer Vision Workshop will help you understand how computers master the art of processing digital images and videos to mimic human activities. Starting with an introduction to the OpenCV library, you'll learn how to write your first script using basic image processing operations. You'll then get to grips with essential image and video processing techniques such as histograms, contours, and face processing. As you progress, you'll become familiar with advanced computer vision and deep learning concepts, such as object detection, tracking, and recognition, and finally shift your focus from 2D to 3D visualization. This CV course will enable you to experiment with camera calibration and explore both passive and active canonical 3D reconstruction methods. By the end of this book, you'll have developed the practical skills necessary for building powerful applications to solve computer vision problems.
Table of Contents (10 chapters)

3. Working with Histograms

Activity 3.01: Enhancing Images Using Histogram Equalization and CLAHE

Solution:

  1. Open a new file in a Jupyter notebook in the folder you want to work on. Remember that your relevant finger veins image file must also be in the same folder so that when reading the image, you won't need to give a path along with the filename.
  2. Import the OpenCV library and the pyplot module from the Matplotlib library:
    import cv2
    import matplotlib.pyplot as plt
  3. Read the image as grayscale:
    img= cv2.imread('fingervein.bmp', 0)
  4. Display the image. Let's use Matplotlib to display the images in this example. You can also use OpenCV's cv2.imshow() if you want:
    imgplot = plt.imshow(img , cmap="gray")
    plt.title('Original image')
    plt.show()

    The plot looks as follows:

    Figure 3.59: Original finger vein image

    The values on the X and Y axes show the width and height of the displayed image.

  5. Plot the histogram:
    plt.hist(img...