Computer vision and Image analysis beginner introduction with Python

In this tutorial we get started with computer vision and image analysis using OpenCV and python. Computer vision holds many benefits and is exactly what is sounds like. When I began my research into artificial intelligence working with tools like tensor flow and complicated algorithms I actually didn’t know there was a difference between computer vision and AI. They seemed one and the same but they are not as I soon realized.

Thresholding a cute puppy

Computer vision gives the computer vision; Can you just image what a computer could do if it can see they way we see. This is how awesome computer vision is. In order to do computer vision many image analysis techniques are used. Commonly used to accomplishing this is OpenCV. You can learn more about OpenCV on their website. Built originally in C++ we will use the python binding to play with some of these image analysis techniques. The entire tutorial is done using python but python is a simple language so its great for beginners so you should have no problems understanding it.

In the tutorial we look at how we can read in an image and display it as an array.

image = cv2.imread('dog.png')

A numpy array to be exact. After which we play with some color space conversions on the image.

gray_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) # these do two different
gray_image = cv2.cvtColor(image, cv2.COLOR_RGB2BGR) # things. 

We learn how to resize images and save images. Then we get into some more complex techniques.

small_image = cv2.resize(gray_image, (300, 300)) # resize image
cv2.imwrite("dogtest.png", small_image)  # saving an image

We learn how to apply thresholding on our images and then blur them so they can be read by an OCR engine. Further we go into drawing rectangles on our images and cropping them.

ret, thresh_image = cv2.threshold(small_image, 127, 255, cv2.THRESH_BINARY) # thresholding

This is really only the beginning of what we can do with OpenCV there is so much more but we have to start somewhere. With these basic techniques you have a great started to dig further into more image analysis techniques. Check out the full tutorial below.

Leave a Reply

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

You are commenting using your 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 )

Connecting to %s