Computer Vision-
Computer Vision refers to enable computers to understand digital images and videos. Mathematical and signal processing knowledge can help a lot to understand computer vision study field. The computer vision study field requires acquiring information from digital videos and analyzing them using using machine learning, deep learning and other techniques. Moreover, Computer Vision has lot of applications in several fields such as in robotics, medical image analysis and face detection.
Library (Open Source Computer Vision)
This open source computer vision library was developed by Intel in 1999 and a very popular library for computer vision. The OpenCV library supports three languages C/C++, Java and Python, so you do not need to worry if you know any of three languages. However, in this post, I will
write a simple post which reads an image and displays it in a window.
Read an Image using OpenCV in Python
import cv2
img = cv2.imread(‘postnetworklogo.png’, cv2.IMREAD_GRAYSCALE)
cv2.imshow(‘PostNetwork Logo’, img)
cv2.waitKey(0)
cv2.destoryAllWindows()
Output:
Program Description-
In the first line you can see that the statement import cv2 which imports OpenCV module in program. imread() function takes a parameter which is path to image, if program and image are in the same directory you do not need to specify the path. Further, imshow() takes two parameter the first one is name of window and the second one is image object and this function shows the original image in a window. cv2.waitKey(0)
cv2.destoryAllWindows() I will discuss in later posts.
Read an Image using OpenCV in Python and Convert it into Grey Image
import cv2
img = cv2.imread(‘postnetworklogo.png’)
grayimgage = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
cv2.imshow(‘PostNetwork Logo’, grayimgage)
cv2.waitKey(0)
cv2.destoryAllWindows()
Output:
Program Description- In the above program, cvtColor() function takes two arguments image object img and parameter
COLOR_BGR2GRAY. This function converts BGR image to a grey image and as in the first program imshow() function displays the image in a window.