Tutorial 10 - Image Processing
In this tutorial you will explore some simple image processing techniques
and investigate the advantages and drawbacks of each.
Average Intensity
RGB to HSV conversion
Histogram
Filtering
Suppose you would like to determine the location of the object (the
can) in with respect to the camera. The distigushing characteristic
of the can is that it is composed mainly of red. However notice that
the can in the center of the image has multiple shades of red. Therefore,
a threshold value must be determined, which if the red component is
above the threshold, then the pixel will be considered "red".
[000000] |
black |
[FFFFFF] |
white |
[0000FF] |
blue |
[00FF00] |
green |
[FF0000] |
red |
[00FFFF] |
cyan |
[FF00FF]
|
magenta |
[FFFF00] |
yellow |
The primary and secondary colors
To find the can, first find filter for the color red. The first approach
is to check each pixel to see if its red component is larger than some
threshold value. If so then that pixel is accepted as being "red".
Using that filtering technique produces an image like
The can is slightly distinguishable from the background, however not
nowing previously that the image was of a tin can, even a human might
not be able to tell the object from the background.
The problem with the above filtering technique is that white [255,
255, 255] also has a large red component.
Therefore, we can filter for red above a certain value and the other
components below a certain value.
This technique produces a better image
Notice that some of the white is still allowed by the filter as being
red. By adjusting the weights we can achieve a better image
The final image represents a reasonable outline of the can. Now that
you have filtered the image to find the "red" can, we would
like to determine a location in the image which will represent the "center"
of the can. An easy way to do this is to allocate two integer vectors,
lets denote them row_vec
and col_vec,
and for each element of each vector, sum the number of pixels which
passed the test for red. Once this is completed for the entire image,
search each array for the largest value. This will give an approximation
for the row and column coordinates for the red can in the image.