MounishT / Histogram-of-an-images

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Histogram-of-an-images

Aim

To obtain a histogram for finding the frequency of pixels in an Image with pixel values ranging from 0 to 255. Also write the code using OpenCV to perform histogram equalization.

Software Required:

Anaconda - Python 3.7

Algorithm:

Step1:

Read the gray and color image using imread()

Step2:

Print the image using imshow().

Step3:

Use calcHist() function to mark the image in graph frequency for gray and color image.

step4:

Use calcHist() function to mark the image in graph frequency for gray and color image.

Step5:

The Histogram of gray scale image and color image is shown.

Program:

Developed By: T MOUNISH

Register Number: 21222223098

Input Grayscale Image and Color Image:

import cv2
import matplotlib.pyplot as plt
Gray_image = cv2.imread('tree.jpg')
Color_image = cv2.imread('york.jpg')
plt.imshow(Gray_image)
plt.show()
plt.imshow(Color_image)
plt.show()

Histogram of Grayscale Image and Green channel of Color Image:

hist = cv2.calcHist([Gray_image],[0],None,[256],[0,256])
hist1 = cv2.calcHist([Color_image],[1],None,[256],[0,256])
plt.figure()
plt.title("Histogram")
plt.xlabel('grayscale value')
plt.ylabel('pixel count')
plt.stem(hist)
plt.show()
plt.figure()
plt.title("Histogram of Color Image Green Channel")
plt.xlabel('Intensity value')
plt.ylabel('pixel count')
plt.stem(hist1)
plt.show()

Histogram Equalization of Grayscale Image:

equ = cv2.equalizeHist(gray_image)
cv2.imshow("Equalized Image",equ)

Output:

Input Grayscale Image and Color Image:

image image

Histogram of Grayscale Image and any channel of Color Image

image

Histogram Equalization of Grayscale Image.

image

Result:

Thus the histogram for finding the frequency of pixels in an image with pixel values ranging from 0 to 255 is obtained. Also,histogram equalization is done for the gray scale image using OpenCV.

About

License:GNU General Public License v3.0


Languages

Language:Python 100.0%