diff --git a/Image-Processing/RealTime _Image_Histogram/Histogram_output.png b/Image-Processing/RealTime _Image_Histogram/Histogram_output.png new file mode 100644 index 00000000..a30377fa Binary files /dev/null and b/Image-Processing/RealTime _Image_Histogram/Histogram_output.png differ diff --git a/Image-Processing/RealTime _Image_Histogram/README.md b/Image-Processing/RealTime _Image_Histogram/README.md new file mode 100644 index 00000000..cb9c00ec --- /dev/null +++ b/Image-Processing/RealTime _Image_Histogram/README.md @@ -0,0 +1,31 @@ +# Image Processing + +Image Processing is most commonly termed as 'Digital Image Processing' and the domain in which it is frequently used is 'Computer Vision'. +Don't be confused - we are going to talk about both of these terms and how they connect. +Both Image Processing algorithms and Computer Vision (CV) algorithms take an image as input; however, in image processing, +the output is also an image, whereas in computer vision the output can be some features/information about the image. + +## OpenCV + +![](https://logodix.com/logo/1989939.png) + +## Installation + +### Windows + $ pip install opencv-python +### MacOS + $ brew install opencv3 --with-contrib --with-python3 +### Linux + $ sudo apt-get install libopencv-dev python-opencv + +## Other Modules + + $ pip install numpy
+ $ pip install matplotlib + +# About RealTime Image Histrogram +This script is used to make real-time image histogram with respect to RGB (Red, Green, Blue) colors. It starts with open the camera to capture the image using **opencv** module, and store it to your script directory. After that by using **numpy** and **matplotlib** it creates the histogram of image by mapping it through 256 gray scales. + +# Output + +![](https://github.com/gulshanbaraik01/Awesome-Python-Scripts/blob/Image-Process/Image-Processing/RealTime%20_Image_Histogram/Histogram_output.png) diff --git a/Image-Processing/RealTime _Image_Histogram/realtime0.png b/Image-Processing/RealTime _Image_Histogram/realtime0.png new file mode 100644 index 00000000..e9b9b668 Binary files /dev/null and b/Image-Processing/RealTime _Image_Histogram/realtime0.png differ diff --git a/Image-Processing/RealTime _Image_Histogram/realtime_image_histogram.py b/Image-Processing/RealTime _Image_Histogram/realtime_image_histogram.py new file mode 100644 index 00000000..78e2b772 --- /dev/null +++ b/Image-Processing/RealTime _Image_Histogram/realtime_image_histogram.py @@ -0,0 +1,34 @@ +# -*- coding: utf-8 -*- +""" +Created on Fri Aug 28 11:31:58 2020 + +@author: Gulshan +""" + + +#Importing necessary libraries for capture image and plot histrogram +import cv2 +import numpy as np +from matplotlib import pyplot as plt + +#Script to capture realtime image +webcam = cv2.VideoCapture(0) #Inititalize object for camera +i = 0 +while i < 10: + input('Press Enter to capture') + return_value, image = webcam.read() + cv2.imwrite('realtime'+str(i)+'.png', image) + if i == i: #Break when value becomes greater than 1 + break +del(webcam) #Delete camera object after capture + +#Script to load realtime captured image +img = cv2.imread('realtime0.png') +color = ('b','g','r') #Create RGB Histogram +plt.figure(figsize = (10, 8)) +for i, col in enumerate(color): + histr = cv2.calcHist([img],[i],None,[256],[0,256]) + plt.plot(histr,color = col) + plt.xlim([0,256]) +plt.show() #Show Histogram +