Computer Vision for Busy Developers

Thresholds and Templates

Vinny DaSilva
12 min readJun 4, 2019

This article is part of a series introducing developers to Computer Vision. Check out other articles in this series.

So far in the series, we’ve taken a look at an entire image and manipulated the image in some way. We did this by looping through each pixel and manipulating them. While this produced interesting results, we did not get any closer to understanding anything about the image. Computer vision involves extracting information or data from images in an attempt to allow the computer to understand the contents of said images. For this next article, instead of blindly manipulating each pixel, we are going to try to determine if a particular pixel meets some criteria and if so, flag the pixel within the image. These will be our first steps in better understanding images.

Finding an Object via Color Thresholding

An easy way for us to try out some simple detection is to use simple criteria to determine if a pixel is, or is not, of interest. For instance, let’s assume we have a photo of the full moon (as shown below) and we want to determine where the moon is located within the photo. We will look through each pixel and compare it against a known pixel value that is yellowish in color. If the pixel color is similar enough to our yellowish color, then we will flag it as a pixel we care about. The process of finding areas within an image based on color is often referred to as Color (or Image) Thresholding.

--

--

Vinny DaSilva

Developer Relations Engineer at Google. Passionate about AR & VR. Previously at Lenovo ThinkReality, Samsung NEXT, Vuforia