01.04.2015 Views

1FfUrl0

1FfUrl0

1FfUrl0

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Computer Vision – Pattern Recognition<br />

This screenshot of a building is one of the images in the dataset. We will use this<br />

screenshot as an example.<br />

As you may be aware, image processing is a large field. Here we will only be looking<br />

at some very basic operations we can perform on our images. Some of the most basic<br />

operations can be performed using NumPy only, but otherwise we will use mahotas.<br />

Thresholding<br />

Thresholding is a very simple operation: we transform all pixel values above a<br />

certain threshold to 1 and all those below to 0 (or by using Booleans, transform it<br />

to True and False):<br />

binarized = (image > threshold_value)<br />

The value of the threshold width (threshold_value in the code) needs to be<br />

chosen. If the images are all very similar, we can pick one statically and use it for<br />

all images. Otherwise, we must compute a different threshold for each image based<br />

on its pixel values.<br />

Mahotas implements a few methods for choosing a threshold value. One is called<br />

Otsu, after its inventor. The first necessary step is to convert the image to grayscale<br />

with rgb2gray.<br />

[ 202 ]

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!