WHAT IS OPENCV?
OpenCV (Open Source Computer Vision) is a library of programming functions mainly aimed at real-time computer vision which is a methods for acquiring, processing , analysing and understanding digital images, and extraction of high-dimensional data from the real world in order to produce numerical or symbolic information, e.g., in the forms of decisions.
So lets do some basic image processing using python and open cv.
The topics we are covering are,
- colour conversion
- image thresholding
- smoothing images
- morphological transformation
- edge detection
- histogram equalisation
1 . Colour conversion
Now you are going to learn how to convert image from one colour-space to another using the function cv2.cvtColor() .
- For BGR (blue , green , red) to gray scale conversion type the following commands in your python terminal
import cv2 imgbgr = cv2.imread("image.png") cv2.imshow("original image",imgbgr) imggray=cv2.cvtColor(imgbgr,cv2.COLOR_BGR2GRAY) cv2.imshow("converted image",imggray) cv2.waitKey(0)
The original image is
The converted image is,
- If you want to convert a BGR image to HSV format,
use cv2.COLOR_BGR2HSV instead of cv2.COLOR_BGR2GRAY