Académique Documents
Professionnel Documents
Culture Documents
I. INTRODUCTION
In todays digital word, images and videos are
everywhere, and with the advent of powerful and
affordable computer device, it has been never easier to do
computer vision [1]. Development of ICT technologies
(Information and Communication Technology) and their
implementation in common live expand demand for more
efficient way to work with images and videos. Especially
in real-time application, it is necessary to use the most
efficient computer vision. In result CPU time consuming
of basic algorithm in computer vision is compared.
A. OpenCv
OpenCv is an open source computer vision library
containing more than 500 optimized algorithms for image
and video analysis, including factory product inspection,
medical imaging, security, user interface, camera
calibration, stereo vision and robotics. Since its
introduction in 1999, it has been largely adopted as the
primary development tool by the community of
researchers and developers in computer vision [1, 3].
The library is written in optimized C and takes
advantage of multi-core processors. Version 1.0 was
launched in 2006 and second major release occurred in
2009 with launch of OpenCv 2 that proposed important
changes, especially the new C++ interface. This new
interface seeks to reduce the number of lines of code
necessary to code up vision functionality as well as
reduce common programming errors such as memory
leaks (through automatic data allocation and deallocation) that can arise when using OpenCV in C.
Recently, the most of new developments and
algorithms in OpenCV are developed in the C++
interface. There is active development on interfaces for:
75
D. Edge Detection
Edge detection is an important pre-processing step in
image analysis. In general, the most common operator
used to represent edges is the Sobel derivative operator.
OpenCV provides function:
cvSobel(*src, *dst, xorder, yorder, aparature_size).
A. Smoothing
Smoothing is a simple and frequently used image
processing operation. There are many reasons for
smoothing, but it is usually done to reduce noise, camera
artifacts or help finding edges. OpenCV offers five
different smoothing operations, which are supported
through one function:
void cvSmooth( *src, *dst, smoothtype, p1, p2, p3, p4).
Arguments src and dst are input and output image, xorder
and yorder are the orders of derivate. Typical values are
0,1 or at most 2. The aperture_size parameter should be
odd and determine the width of the square filter. Sobel
derivatives have the nice property that they can be
defined for kernels of any size, and those kernels can be
constructed quickly and iteratively. The larger kernels
give a better approximation to the derivative because the
smaller kernels are very sensitive to noise.
Canny edge detector is an edge detection operator that
uses a multi-stage algorithm to detect a wide range of
edges in images. The first derivatives are computed in x
and y and then combined into four directional derivatives.
The points where these directional derivatives are local
maximum are then candidates for assembling into edges.
OpenCv provides function:
void cvCanny(*img, *edges, low_thresh, high_thresh,
opertureSize).
Function expects an input image, which has to be
grayscale, and an output image, which has to be also
grayscale. The next two arguments are the low and high
thresholds, and the last argument is another aperture. As
usual, this is the aperture used by the Sobel derivative
operators that are called inside of the implementation of
cvCanny() [3, 5, 8].
The src and dst are source and destination images. The
third argument is the kernel, which default value is
NULL. In the NULL case, the kernel used is a 3-by-3
kernel with the anchor at its center. You can make your
own custom morphological kernel using IplConvKernel.
Last argument is the number of iterations with default
value set to 1 [3, 5, 8].
C. Image Pyramids
Image pyramids are heavily used in a wide variety of
vision applications. An image pyramid is a collection of
images, all arising from a single original image, that are
successively down-sampled until some desired stopping
point is reached. They are two kinds of image pyramids:
the Gaussian and Laplacian pyramids. The Gaussian
pyramid is used to down-sample images, and the
Laplacian pyramid is required when is needed to
reconstruct an up-sampled image from an image lower in
the pyramid. OpenCv provides function:
void cvPyrDown(*src, *dst, filter).
(1)
76
TABLE I.
OPENCV - SMOOTHING
Number
of threads
1
2
4
8
16
32
64
220x260
(ms)
0.5
0.95
0.56
0.42
0.36
0.31
0.27
1024x768
(ms)
4.37
5.03
3.35
2.24
1.55
1.46
1.15
1920x1080
(ms)
20.97
16.56
8.79
5.42
4.53
4.31
4.13
TABLE V.
OPENCV IMAGE PYRAMID
3264x2448
(ms)
77.31
57.27
31.83
21.26
18.8
17.9
18.1
Number
of threads
1
2
4
8
16
32
64
TABLE II.
MATLAB SMOOTHING
Number
of threads
1
2
4
8
220x260
(ms)
21.45
8.58
4.94
3.11
1024x768
(ms)
163.2
69.25
35.86
20.45
1920x1080
(ms)
672.93
307.2
157.61
92.99
Number
of threads
1
2
4
8
1
2
4
8
16
32
64
1024x768
(ms)
1.05
2.22
1.57
1.07
0.95
1.08
0.83
1920x1080
(ms)
6.66
8.02
5.32
3.17
2.32
2.52
2.31
1
2
4
8
220x260
(ms)
21.46
20.12
10.77
6.92
1024x768
(ms)
148.57
146.22
82.89
52.26
1920x1080
(ms)
541.84
675.64
368.97
232.27
3264x2448
(ms)
35.67
23.3
13.08
7.41
5.16
5.72
6.16
220x260
(ms)
2.86
3.24
2.1
1.5
1024x768
(ms)
5.33
14.1
8.03
5.05
1920x1080
(ms)
14.16
57.35
30.9
18.37
3264x2448
(ms)
39.23
213.3
111.26
65.24
TABLE VII.
OPENCV SOBEL DERIVATE OPERATOR
Number
of threads
1
2
4
8
16
32
64
3264x2448
(ms)
27.02
24.74
14.36
10.04
8.93
9.2
9.05
220x260
(ms)
0.81
1.15
0.71
0.45
0.35
0.39
0.33
1024x768
(ms)
6.13
6.14
3.88
2.45
1.57
1.61
1.5
1920x1080
(ms)
28.12
18.65
10.68
6.06
3.91
4.07
4.44
3264x2448
(ms)
107.16
66.3
35.95
19.97
14.04
13.67
14.01
TABLE VIII.
MATLAB SOBEL DERIVATE OPERATOR
Number
of threads
TABLE IV.
MATLAB EROSION
Number
of threads
1920x1080
(ms)
8.47
9.05
6.3
3.87
2.5
2.61
2.64
TABLE III.
OPENCV EROSION
220x260
(ms)
0.15
0.43
0.27
0.25
0.28
0.22
0.18
1024x768
(ms)
1.83
2.55
1.54
1.03
0.81
0.92
0.81
TABLE VI.
MATLAB IMAGE PYRAMID
3264x2448
(ms)
2755.45
1313.3
739.95
482.48
Number
of threads
220x260
(ms)
0.24
0.43
0.27
0.22
0.18
0.15
0.13
1
2
4
8
3264x2448
(ms)
2060.95
2658.17
1500.85
965.92
220x260
(ms)
6.54
4.73
2.95
2.15
1024x768
(ms)
34.5
34.24
18.91
11.03
1920x1080
(ms)
144.64
167.13
85.12
49.62
3264x2448
(ms)
487.56
709.51
370.61
207.85
77
TABLE IX.
OPENCV CANNY EDGE DETECTOR
Number
of threads
220x260
(ms)
1.16
1.23
1.03
0.69
0.55
0.68
0.56
1
2
4
8
16
32
64
1024x768
(ms)
16.75
11.12
6.81
4.38
3.31
3.09
3
1920x1080
(ms)
41.39
25.03
15.12
9.28
6.95
7.72
8.87
3264x2448
(ms)
215.28
150.51
66.99
38.91
27.38
27.66
28.26
ACKNOWLEDGMENT
This contribution/publication is the result of the project
implementation: Centre of excellence for systems and
services of intelligent transport, ITMS 26220120050
supported by the Research & Development Operational
Programme funded by the ERDF.
TABLE X.
MATLAB CANNY EDGE DETECTOR
Number
of threads
220x260
(ms)
34.62
18.89
10.35
6.17
1
2
4
8
1024x768
(ms)
266.01
155.21
79.99
49.58
1920x1080
(ms)
1070.89
682.93
358.13
223.98
3264x2448
(ms)
4419.55
2743.17
1563.46
1138.89
REFERENCES
[1]
[2]
[3]
[4]
[5]
[6]
40
OpenCv Sobel
35
[7]
Matlab Sobel
30
[8]
25
20
15
10
5
0
1
16
32
64
Number of threads
IV. CONCLUSION
In this paper, we have presented basic algorithm for
image processing, focusing for their CPU time
consuption in Matlab and OpenCV. Results showed, that
OpenCv is faster than Matlab in some algorithm from 4
to 30 times and in case of Erosion algorithm up to 100
times. On the other hand, Matlab environment is relative
simply and friendly to use, and provides various sort of
function and algorithm. It isnt necessary to care about
memory allocation and memory leak in Matlab, but it is
78