Git Product home page Git Product logo

histogram-of-an-images's Introduction

EX 03 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: THIRISHA.S
# Register Number: 212222230160

Output:

Input Grayscale Image and Color Image

import cv2
import matplotlib.pyplot as plt
gray_image = cv2.imread("vijay.jpeg")
color_image = cv2.imread("ajith.jpeg",-1)
cv2.imshow("Gray Image",gray_image)
cv2.imshow("Colour Image",color_image)
cv2.waitKey(0)
cv2.destroyAllWindows()

image

Screenshot 2024-04-12 083509

Histogram of Grayscale Image and any channel of Color Image

import numpy as np
import cv2
Gray_image = cv2.imread("vijay.jpeg")
Color_image = cv2.imread("ajith.jpeg")
import matplotlib.pyplot as plt
gray_hist = cv2.calcHist([Gray_image],[0],None,[256],[0,256])
color_hist = cv2.calcHist([Color_image],[0],None,[256],[0,256])
plt.figure()
plt.imshow(Gray_image)
plt.show()
plt.title("Histogram")
plt.xlabel("Grayscale Value")
plt.ylabel("Pixel Count")
plt.stem(gray_hist)
plt.show()

image

Grayscale Image

Screenshot 2024-04-12 083609

Screenshot 2024-04-12 083623

Colour Image

plt.imshow(Color_image)
plt.show()
plt.title("Histogram of Color Image - Green Channel")
plt.xlabel("Intensity Value")
plt.ylabel("Pixel Count")
plt.stem(color_hist)
plt.show()
cv2.waitKey(0)

image

Screenshot 2024-04-12 083651

Screenshot 2024-04-12 083726

Histogram Equalization of Grayscale Image.

import cv2
gray_image = cv2.imread("vijay.png",0)
cv2.imshow('Gray Scale Image',gray_image)
equ = cv2.equalizeHist(gray_image)
cv2.imshow("Equalized Image",equ)
cv2.waitKey(0)
cv2.destroyAllWindows()

image

Screenshot 2024-04-12 083834

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.

histogram-of-an-images's People

Contributors

swedha333 avatar thirisha-s avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.