IMAGE PROCESSING WITH PYTHON AND OPEN CV

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,

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

 

python-logo-master[1]

The converted image is,newwgray.PNG

  • If you want to convert a BGR image to HSV format,

use   cv2.COLOR_BGR2HSV instead of cv2.COLOR_BGR2GRAY

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s