Sunteți pe pagina 1din 4

Some Practical Assignments in Computer

Vision
Yolanda GONZALEZ Jairo ROCHA
Departamento de Matemáticas e Informática
Universidad de las Islas Baleares
E-07122 Palma de Mallorca, Spain. Tel: (34) 971 172969. Fax: (34) 971 173003
E-mail: y.gonzalez@uib.es jairo@uib.es

Abstract. Some practical assignments using MatLab lab component, students use Matlab and the Image
and OpenCV and experiences while teaching computer Processing Toolbox [3].
vision courses in undergraduate and graduate programs Matlab stands for MATrix LABoratory and the soft-
are presented. ware is built up around vectors and matrices and it is
a high-performance technical computing and visualiza-
1 INTRODUCTION tion environment making it ideal for image processing.
It is available for AIX, Digital UNIX,HP-UX 10, HP-
With the arrival of fast computers and good com- UX 11, IRIX/IRIX64, Linux, Mac OS X, Solaris and
puter vision libraries, students have the possibility of Windows and it is commercialized by The Mathworks
building complex vision systems in a short time. Mat- [5], founded in 1984. Since then it is widely used in all
Lab and OpenCV are some of these libraries that in- areas of applied mathematics in education and research
clude powerful routines that, before they existed, stu- at universities and in the industry.
dents needed one semester to implement. We present Matlab combines comprehensive math and graphics
some practical assignment examples used in undergrad- functions with a powerful high-level language. In addi-
uate and graduate courses, and some other experiences tion, to integrate external routines written in C, C++,
while teaching in different programs and levels. Fortran, and Java with Matlab applications is possible.
The teaching of computer vision is now recognized
The add-on tools extend the power of Matlab. In
worldwide as important in several engineering pro-
particular, the Image Processing Toolbox is especially
grams to the point that some suggest the creation of
useful for practical image processing and computer vi-
a computer vision science program [1]. Readers are
sion courses.
directed to a great review of computer vision texts
done by B. Maxwell [6]. With this paper we would Matlab was choosen for use in the lab because it is
like to share our experiences while teaching computer an interactive environment with lots of demos and help
topics and students can get immediate visual reinforce-
vision courses in the Industrial Engineering undergrad-
uate program and in the Computer Science graduate ment of classroom lectures and concepts. Moreover,
program at the Balearic Islands University. We will Matlab’s language has proven to be easy for students to
understand providing them easy access to sophisticated
concentrate on the practical assignments.
The paper is organized as follows. Section shows algorithms and image processing implementations.
the advantages of using Matlab as lab tool with under- Lab assignments are divided in three main groups:
graduate industrial engineering students while Section understanding basic concepts, developing low-level al-
2.3.3 describes how graduate computer science students gorithms and resolving high-level problems.
use OpenCV with ease to resolve practical problems.
Section 3.2 gives the conclusions.
2.1 Understanding basic concepts
2 MATLAB PRACTICAL ASIGNMENTS The main objective of this set of assignments is that
the student understand the classroom concepts using
This section presents some practical assignments for Matlab Image Processing Toolbox.
an undergraduate image processing course. During
four months the course tackles the low-level image anal- 2.1.1 Examples
ysis methods, including image formation, edge detec-
tion, feature detection, and segmentation. Image Manipulation. Read, write, view images
The course has both a lecture component and a lab and conversion between different formats.
component. Both meet for four hours a week. For the Main Matlab functions: imread, imwrite,
gray2ind, ind2gray, ind2rgb, mat2gray, correct thresholds allows dice to be identified quickly.
rgb2gray, rgb2ind. Within the dice regions, the number of dots is counted.
Students usually do not have problems with this first
Spacial Transformations. Convolution and assignment.
correlation. Figure 1 shows the original color image on the left
Main Matlab functions: imfilter, conv2, and the black and white dots identified on the right.
filter2. Figure 2 shows the processed binary images with the
Frequency Transformations. Fourier dice found.
transform.
Main Matlab functions: fft2, ifft2,
fftshift.
Histogram Modification. Explore histogram as
an enhancement technique.
Main Matlab functions: imhist, histeq,
imadjust.
Filtering. Noise identification and filtering
techniques to remove it. Figure 1: Dice identification: Original color image (left)
Main Matlab functions: imnoise, and processed image with value identified marked with red
medfilt2, ordfilt2, wiener2. crosses (right).

Morphological Transformations. Dilatation


and erosion as fundamental morphological
operations.
Main Matlab functions: imdilate,
imerode, imclose, imopen, bwmorph.
Segmentation using Edge Detection. Detection
of boundaries between two regions using
different gradient aproximations.
Main Matlab function: edge.
Segmentation using Thresholding. Divide Figure 2: Dice identification: White dice (left) and Black
the image in regions depending on the die (right).
graylevel.
Main Matlab function: im2bw.
2.3.2 Identify the maximum number of wood
2.2 Developing low-level algorithms pieces using edge detection

Once the student have understood the main concepts In this assignment students have to work with differ-
he would be qualified to develop in MatLab some of the ent edge detection algorithms to select the correct one.
algorithms tested previously with the matlab functions. First of all, an enhancement of the image have to be
This block of assignments set out the development done.
of some of the low-level image processing algorithms. The students usually have problems with the shad-
The student has to prove that the result is the same ows and the illumination.
using his own algorithm and the MatLab function. Figure 3 shows the original color image on the left
and the equalized result on the right. Figure 4 shows
a student contribution.
2.3 Resolving high-level problems
This set of assignments has the purpose of summarizing 2.3.3 Identify the number of domino and their
all the concepts tackled in the course. The student has value
to resolve a problem that involves more than one tech-
This is the most complex assignment. Filtering, en-
nique and he has to choose the right way to accomplish
hancement and threshold techniques have to be used.
it. Next, three examples are shown.
Figure 5 shows on the left side the noisy salt and
pepper image where domino and their value have to
2.3.1 Identify the number of black and white be identified. Moreover one die and chess counters are
dice and their value present. On the right side the filtered image is shown.
With this assignment the student must apply threshold Students usually have to prove more than one way
techniques. It is an easy example where selecting the to achieve the correct solution. Figure 6 shows it.
Figure 3: Wood pieces detection: original color image (left) Figure 5: Domino identification: Noise original image
and its enhancement (right). (left) and corrected image (right).

Figure 4: Wood pieces detection: edge detection (left) and Figure 6: Domino identification: domino (left) and domino
pieces detected (right). value (right).

3 OPENCV PRACTICAL ASIGNMENTS ternatives for the thresholds used. This is the most
important advantage of OpenCV: It implements com-
The OpenCV library [4] is a tool-box of 500 imaging plex procedures so that the programmer devotes most
and computer vision functions and applications, avail- of its time to witness the difficulties of tuning a method
able for Windows and Linux operating systems, and is for a particular setting, and the result is the possibility
free for commercial and academic use. to solve a more complex task.
Like with all libraries, students should study the
OpenCV library for a while before starting to write
programs. They must be familiar with basic image 3.2 Hand tracking in a movie
types and image methods and operations before they
This assignment deals with the problem of tracking
can make profit of the powerful routines of OpenCV.
the user hand with a camera so that the 2D position,
The system includes very good programming demon-
orientation and width are known in each frame.
strations that make the student save considerable time,
assuming that the students are good C++ program- The algorithm should use the color distribution of
mers. the hand that is seen at the beginning of the sequence
In the following examples we present briefly several (the user puts its hand inside a fixed square on the
practical assignments that were successfully used in a window).
graduate computer vision class. Using the function CvCamShift(), the problem is
easy to solve. In this function, the hue (in the HSV
3.1 Point tracking in a movie color model) distribution on a fix square of the initial
The assignment consists of two parts: First, finding frames of the sequence, where the user fixes his hand at
points easy to track in a frame and second, matching the beginning, is stored in a 1D histogram. Hue is very
them in the next frame. The result is a set of point stable through brightness changes, and even through
correspondences from frame to frame. different people races. The other color channels are
Both parts are easy to carry out using particular ignored, except that pixels where the brightness is too
functions of the library, CvGoodFeaturesToTrack() low or too high are ignored, and also pixels where the
and CvCalcOpticalFlowPyrLK(). Figure 7 shows the saturation is too low, because the hue values are not
points found by the first procedure in a frame and then stable. The color distribution is used to calculate the
the results of the matching procedure in the consecu- probability that each pixel in each frame belongs to the
tive frame. The first procedure finds corners using the region tracked.
eigenvalues of a matrix of gray level derivatives. The Tracking is carried out by an iterative procedure that
second procedure implements the Lucas and Kanade finds the window that has the best similar probability
algorithm in its hierarchical version. distribution with respect to the stored distribution. In-
Students spend most of the time finding the correct side the window, the principal axes are calculated to
parameters to call the functions and trying several al- find the main orientation and extension in each direc-
has the advantage of being free software useful for good
C++ programmers so that it is more appropriate for
advanced computer vision courses.
Other interesting library that we explore in this year
graduate class is Megawave [2] developed at the Centre
de Mathématiques et de Leurs Applications (CMLA),
Paris. We recommend it for teaching level sets.
Acknowledgements. We thank Javier Antich and
Silvia Campins for some of the images. This works
Figure 7: Feature tracking: “good” features (left) and is partially supported by the Spanish grant CICYT
matching points in the consecutive frame (right). DPI2001-2311-C03-02 and FEDER funding.
References
[1] G. Bebis, D. Egbert, and M. Shah. Review of com-
puter vision education. IEEE Trans. on Education,
46(1):2–21, 2003.
[2] CMLA. http://www.cachan.ens-cachan.fr/
Figure 8: Hand tracking: user fix its hand under the square cmla/megawave. 2003.
(left), pixels with the same hue distribution (center) and
[3] S. Eddins and M. Orchard. Using matlab and c in
cross showing the tracked hand (right) in three different
frames of the same sequence. an image processing lab course. IEEE Proceedings
of 1st International Conference on Image Process-
ing, pages 515–519, 1994.
tion.
Students can build easily a tracking system using this [4] Intel. http://www.intel.com/research/mrl/
library routine that tracks patches of color, and they research/opencv. 2003.
can understand the importance of the color channels [5] Mathworks. http://www.mathworks.com. 2003.
used and their approximate perceptual meanings. In
Figure 8 we can see the original square under which the [6] B. Maxwell. A survey of computer vision educa-
user puts its hand, the pixels in a subsequent frame tion and text resources. Int. Journal of Pattern
that have a color distribution similar to the original Recognition and Artificial Intelligence, 15(5):757–
one, and the tracking results in another frame. The 773, 2001.
position, orientation and size of the cross with respect
to the original one can be used to control an interactive
application.

4 CONCLUSION

Undergraduate and graduate computer vision


courses can have very different results according to stu-
dents’ individual motivations. Some students finish the
assignments and explore extensions while others dis-
cover that it is a subject that they do not like and
never quite finish them. The high level libraries now
available allow students to reach quicker the difficul-
ties that the subject tackles nowadays so they can get
interested (or not) having more realistic experiences.
Students on practical assignments realize how diffi-
cult is to build general robust systems and the impor-
tance of controling the capture conditions. However,
the lack of programming skills of undergraduate indus-
trial engineering students make it difficult for them to
create real systems.
Matlab and OpenCV seem to be suitable lab tools in
computer vision teaching. Matlab is better for image
processing courses of undergraduate programs because
of its interactive environment and the no need of solid
programming knowledge. On the other hand, OpenCV

S-ar putea să vă placă și