0% found this document useful (0 votes)
70 views3 pages

Img Edge Detection

Uploaded by

Charme YEBADOKPO
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
70 views3 pages

Img Edge Detection

Uploaded by

Charme YEBADOKPO
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

International Journal of Electronics and Electrical Engineering Vol. 1, No.

2, June 2013

Image Edge Detection Based On Opencv


Guobo Xie and Wen Lu
School of computer, Guangdong University of technology, Guang zhou, China 510006
E-mail: {guoboxie, lu_wenwen }@163.com

Abstract—Image processing is one of most growing research specific quantity of copper. However due to the small
area these days and now it is very much integrated with the size of the copper core and the defects, which to some
industrial production. Generally speaking, It is very difficult extent increases the difficulty to distinguish. So we use
for us to distinguish the exact number of the copper core in
the tiny wire, However, in order to ensure that the wire the digital image processing to determine the exact
meets the requirements of production, we have to know the quantity of the copper core. This paper describes how
accurate number of copper core in the wire. Here the paper efficiently image processing applications can be used to
will introduce a method of image edge detection to check and judge the merits of the industrial product. In
determine the exact number of the copper core in the tiny section 2 it describes previous work on the image before
wire based on OpenCV with rich computer vision and image processing. In section 3 it states Morphological image
processing algorithms and functions. Firstly, we use
high-resolution camera to take picture of the internal
processing. In section 4 it introduces the effect of the
structure of the wire. Secondly, we use OpenCV image contour tracking theory. Section 5 consists of the
processing functions to implement image preprocessing. conclusion.
Thirdly we use morphological opening and closing
operations to segment image because of their blur image II. PREVIOUS WORKS ON IMAGE
edges. Finally the exact number of copper core can be
clearly distinguished through contour tracking. By using of A. Capture Image
Borland C++ Builder 6.0, experimental results show that
In OpenCV, the data type of image is usual IplImage.
OpenCV based image edge detection methods are simple,
high code integration, and high image edge positioning IplImage comes from Intel Image Processing Library.
accuracy.  Image Processing Library is inheritance from the actual
OpenCV versions which may require IplImage data type
Index Terms—OpenCV, image edge detection, morphology, is defined in CXCORE [3]. IplImage is the main image
contour tracking. structure used in OpenCV. IplImage has been in OpenCV
since the very beginning. It is a part of the C interface for
OpenCV. You need to allocate and deallocate memory
I. INTRODUCTION
for Iplmage structures yourself. OpenCV has many
The rapid development of computer industry powerful image processing functions. In order to capture
production and computer intelligence, as well as the and show an image we should use cvLoadImage
corresponding developments in computer-aided image cvNamedWindow, and cvShowImage functions. The
analysis, has made industrial image processing to be a function cvLoadImage loads the specified image file and
very important branch of scientific image processing. return IplImage pointer to the file. CvNameWindown
Image processing plays a very important role in industrial defines a window for displaying. The function
production, which can visualize the anatomical structure cvShowImage display the image in the specified window.
of the product, therefore, we can check and judge the By using the above three functions, we can successfully
merits of the product in time and to some extent reduce
display the image that we will deal with. The source
the unnecessary losses, so it is necessary for us to avoid
image is as Fig. 1 which edge is not clear.
the traditional off-line manual detection methods which
may easily result in error detection.
OpenCV is one of the most extended software libraries
used in computer vision applications. OpenCV as an open
source library [1].constituted by a series of C / C ++
functions and classes, offers many common algorithms to
realize image processing and computer vision computing,
which can be used to achieve powerful image processing,
and to develop real-time applications system. [2]
In the tiny wire industrial production process, it is very
necessary for us to determine whether the wire meets


Manuscript received March 18, 2013; revised May 24, 2013. Figure 1. Source image edge is not clear

©2013 Engineering and Technology Publishing 104


doi: 10.12720/ijeee.1.2.104-106
International Journal of Electronics and Electrical Engineering Vol. 1, No. 2, June 2013

B. Color_to_Gray D. Thresholding
Source images obtained are generally color but as we Thresholding or binarization is a conversion from a
know grayscale images are very common and entirely color image to a bi-level one. This is the first step in
sufficient for the task discussed in the paper. So there is several image processing applications. This process can
no need to use more complicated and harder-to-process be understood as a classification between objects and
color images. For facilitating processing, color image will background in an image. It does not identify objects; just
be usually converted to grayscale [4]. A grayscale digital separate them from the background [6]. In order to obtain
image is a single sample, that is, it carries only intensity the information that we have to deal as much as possible,
information. Images of this sort, also known as we use the image binarization processing [7]. In the
black-and-white, are composed exclusively of shades of process of thresholding, it is very important for us to set
gray, varying from black at the weakest intensity to white the correct threshold value which will determine a pixel
at the strongest. Often, the gray scale intensity is stored as as object or background, that is to say the binarization
an 8-bit integer giving 256 possible different shades of image presents pixels whose gray level of 0 indicates the
gray from black to white. If the levels are evenly spaced value of the pixels is less than the set threshold value and
then the difference between successive graylevels is a gray level of 1 denotes the value of the pixels is more
significantly better than the graylevel resolving power of than the predefined threshold value. In the paper, for a
the human eye. Opencv offers us cvCvtColor function to micro wire picture, the object can be seen as the copper
convert the color image to grayscale image. The effect of core, and the other is the background. The results of
RGB to GrayScale image is well demonstrated in the Fig. thresholding can retain structural characteristics of copper
2. core information. For the target of separating copper core
from background as much as possible, we use Opencv's
cvThreshold function to segment copper core. We can see
the result of image after thresholding in Fig. 4.

Figure 2. RGB to GrayScale image

C. Median Filter
At the same time, because of the noise interfering to
the detection accuracy, it is necessary for us to do Figure 4. The image after thresholding
denoising for the captured images. Blurring image is the
modest process in image processing [5]. Blur, is a process III. MORPHOLOGICAL PROCESSING
done to reduce noise. As this can be achieved in different Mathematical morphology examines the geometrical
ways, this paper demonstrates a basic filter structure of an image by probing it with small patters,
method-median filter. Median filtering method is a kind called ‘structuring elements’ of varying size and shape.
of nonlinear smoothing technique, and the gray value of This procedure results in nonlinear image operators
its every pixel is set to a middle value of all the gray
which are well-suited to exploring geometrical and
value of the pixel in a neighboring window. Median
topological structures. A succession of such operators is
filtering is very effective to remove salt and pepper noise.
applied to an image in order to make certain features
OpenCV includes a Median filter that can be applied to
an image by calling the cvSmooth function. The image apparent, and distinguish meaningful information from
after smooth processing is as Fig. 3. irrelevant distortions, by reducing it to a sort of caricature
(skeletonization). Mathematical morphology [8] has four
kinds of basic operations: expansion, corrosion, opening
and closing operation. Expansion causes the goal pixels
to increase, but, corrosion can reduce the target pixels.
Corrosion has the specific role to eliminate boundary
pixels in goal field, which causes image border to shrink
into internal field. Opening can achieve corrode firstly,
then expand. On the contrary, the first expansion, then,
corrosion, will realize closing. According to the
characteristics of image, firstly, we use corrosions to
eliminate the boundary and separate the copper core
Figure 3. Image after smooth processing clearly. Secondly, using expansion to expand, then target

©2013 Engineering and Technology Publishing 105


International Journal of Electronics and Electrical Engineering Vol. 1, No. 2, June 2013

information can be restored. Finally we use opening to difficulty of detection and the programming code. With
smooth the target image contour and to sharper image the help of Opencv, C++ Builder 6.0 and using image
border. Fig. 5 shows the effect of the image after processing theory, firstly we use cvCvtColor, cvSmooth,
morphological processing. and cvThreshold to preprocess the target image, secondly
we use morphological method to process it to make the
boundary of the copper core segment and clearly, finally
by using of contour tracking we can clearly distinguish
the exact number of the copper core, so we realize our
goal. Through the practice test, we found that the method
introduced in the paper has greately improved the
accuracy of the product test and the work efficiency.

ACKNOWLEDGEMENTS
The research is partially supported by the Combination
of the Ministry of education project in Guangdong
Figure 5. Morphological processing image Province: 2010B090400, 2011B090400269 ,
2011A091000028 , 2012B091000089 ,
IV. CONTOUR TRACKING 2012B091100383, 2012A080103010, 2011A091000046,
The idea of contour tracking, also known as boundary 2012A080107007
following or edge tracking, is to traverse the border of a
region completely and without repetition.The result of the REFERENCES
contour tracking is to obtain a boundary points sequence [1] G. Sezer, A. Ertüzün, A. Erçil, “Independent component analysis
[9]. Just as its name implies, contour tracking is through for texture defect detection,” in Proc. 6th German-Russian
the order to find out the boundary of the edge points to Workshop OGRW-6-2003, Novosibirsk, Nov. 2003, pp. 210-213
[2] A. Kumar, “Computer-vision-based fabric defect detection: a
track. The key of the contour tracking is to judge the next survey,” Industrial Electronics, IEEE Transactions on, vol. 55, pp.
boundary point according to the adjacent points in binary 348–363, Jan. 2008.
image [10]. Contour tracking is widely used in the fields [3] C. Beirão, M. Figueiredo, “Defect detection in textile images
of image processing, image restoration and image using Gabor filters,” in Proc. ICIAR'2004, LNCS, Springer Verlag,
vol. 3212, pp. 841-848, 2004.
recognition. In the image processing, there are a lot of [4] A. Koschan, "A Comparative Study on Color Edge Detecton", in
contour tracking algorithms, some of them have high IEEE Proc. ACCV'95, Singapore, 1995, pp 478-545,
accuracy and efficiency. Opencv offers cvFindContours [5] R. S. Deepthi and S. Snakaraiah, “Implementation of mobile
function to realize contour tracking, which retrives platform using Qt and OpenCV for image processing applications,”
in 2011 IEEE Conference on Open Systems, 2011, pp 290-295,
contour from the binary image, and return the number of [6] Mello, A. B. Carlos, Costa, H. M. Antonio, “Image thresholding
the detected contour. By using this method, we can of historical documents using entropy and ROC curves,” Lecture
clearly distinguish the boundary of the copper core, so we Notes in Computer Science, vol. 3773, pp 905-916, 2005.
can accurately determine the exact number of copper core. [7] X. J. Jia, “Fabric defect detection based on open source computer
vision library OpenCV,” 2010 2nd International Conference on
The effect of contour tracking is as Fig. 6 from which we Signal Processing Systems, Dalian, 5-7 July 2010, pp.
can clearly distinguish the exact number of the copper V1342-V1345
core in the wire. [8] F. Wang, G. T. Jiao, and Y. Du, “Method of fabric defectdetect in
based on mathematical morphology,” Journal of test and
measurement technology, vol. 21, pp. 515-518, 2007.
[9] M. W. Ren, J. Y. Yang, and H. Sun, "Tracing boundary contours
in a binary image[j]," Image and Vision Computing, vol. 20,
pp125-131, 2002
[10] J. Rao, J. Lin, S. Xu, and S. J. Lin, “A new intelligent contour
tracking algorithm in binary image,” in Proc. 4th International
Conference on Digital Home, 2012, pp 18-22

Guobo Xie received B.S degree in electric and


mechanic and master degree in computing in 2000 and
in 2004, and the Ph.D from the school of automation
from Guangdong University of technology, Guang Zhou
China in 2012. His major field is internet of things and
cloud computing. Now, he is the DIRECTOR of the
Figure 6. The effect of contour tracking
High-end Kitchen appliance enterprises key laboratory in Guangdong
province and the DEPUTY DIRECTOR of the department of computer
V. CONCLUSION engineering of Guangdong University of technology. Prof. Xie is a
member of Computer Engineering Research Center.
Computer vision technology has gradually been
applied to the detection of industrial product Wen Lu received bachelor degree in management from
specifications, which greatly improve the test efficiency Hunan University of art and science in 2012. His major
field is internet of things and big data. Now, he is
of industry production. Opencv offers many image studying as a postgraduate in the school of computer of
processing functions, which to some extent reduces the Guangdong University of technology. Mr lu is a
member of Computer Engineering Research Center.

©2013 Engineering and Technology Publishing 106

You might also like