A New Method for Appearance Quality Detection of Lens Module Based on Machine Vision

TELKOMNIKA, Vol.14, No.2A, June 2016, pp. 343~350
ISSN: 1693-6930, accredited A by DIKTI, Decree No: 58/DIKTI/Kep/2013
DOI: 10.12928/TELKOMNIKA.v14i2A.4345



343

A New Method for Appearance Quality Detection of
Lens Module Based on Machine Vision
1

Zhang Jian-zhong* , He Yong-yi

2

School of Mechatronics Engineering and Automation, Shanghai University, Shanghai 200072,China
*Corresponding author, e-mail: 1zjzfirst@aliyun.com, 2heyongyi@shu.edu.cn

Abstract
The lens module is widely used in many types of equipment, such as mobile phone, image

recognition product, iPad, computer camera module, security product, car rear view module, industrial
endoscope and medical endoscope product. In the process of appearance quality inspection of lens
module, it is a problem that the inspection accuracy depends mainly on manual workers. To save the time
and amount of this quality detection labor, it’s necessary for us to design the lens module’s appearance
quality automatic inspection system. This paper proposes a subpixel-accurate edge detection algorithm
based on wavelet transform with the cubic spline interpolation for the lens module’s appearance quality
inspection system. Firstly, calculate the wavelet modulus maximum, and detect a pixel-accurate edge.
Then apply the cubic spline interpolation to obtain subpixel-accurate edge at the side of the pixel-accurate
edge. Finally, an industrial measurement method using this subpixel-accurate edge detection algorithm is
studied, and some experiments are conducted to demonstrate the effectiveness of the lens module’s
appearance quality inspection system. Comparing with the traditional methods, the lens module’s
appearance quality inspection system has a good anti-noise performance and stable inspection accuracy.
Keywords: Spline interpolation; Wavelet transform; Subpixel, edge detection
Copyright © 2016 Universitas Ahmad Dahlan. All rights reserved.

1. Introduction
The lens module consists of BARREL, LENS, filter and HOLDER part. The general
structure of the lens module is composed of several plastic or glass lenses.The lens structure
can be divided into 1P, 2P, 1G1P, 1G3P, 2G2P, 4G type. A typical lens module is shown in
Figure 1.


(a) Lens structure

(b) LENS and BARREL

Figure 1. Lens module

Quality inspection of lens module usually consists of three items:
1) Appearance of structure detection
Detection including the total lens module’s height, LENS diameter, PCB image module
length and width, thickness of FPC etc. The surface besides the lens’s light hole cannot be
2
scratched and dirty, dot area is less than or equal to 0.2mm , the edges and corners of
HOLDER can not be injured etc.
2) Function test
Including light leakage, TV resolution test, visual angle, color characteristics etc.
Received January 17, 2016; Revised April 26, 2016; Accepted May 12, 2016

344




ISSN: 1693-6930

3) Reliability test
Including strength test (base adhesion, LENS torque), life test, environment test etc.
The quality detection task of appearance and the structure is an important step of qulity
detection for lens module. In this paper, machine vision is applied and the algorithm of the
wavelet transform with the cubic spline interpolation for the lens module’s measurement system
is studied, which consists of three parts:
1) Detection of BLOB based on morphology,
2) Detection of lens size,
3) Detection of lens height.
2. Methods
2.1. Theory of Wavelet Transform Edge Detection
In lens module’s appearance quality automatic inspection system, it’s a basic task to
measure the lens module’s size, and so it’s necessary to detect the edge of a lens module’s
digital image. The edge consists of the key points which gradiant value is significantly changed
in gradient image [1].
We can partly obtain the whole characteristic of an image by the classical image pixelaccurate processing algorithms, such as Sobel operator, Roberts operator, Canny operator [2,

3]. The localization of Sobel operator is pixel-accurate, which is particularly suitable for a much
noisy image. Roberts operator extracts an image and obtains the coarse edge, therefore the
edge location is not accurate, Roberts operator is suitable for a low noisy image.The Canny
operator is an effective edge detection algorithm, which is not easily interfered by the
noise.Canny operator, using two different thresholds, respectively detects strong edges and
weak edges. When the weak edge and the strong edge is connected, the weak edge will
be included in the output edges. Therefore, Canny operator is easier to detect the real edge.
As early as 1987, Mallat applied wavelet analysis technology into image’s edge
detection [4], and presented the corresponding edge detection algorithm. Studies show the
wavelet transform not only has a good localization property in the time domain and the
frequency domain, but also the signal singularity analysis is useful to detect the edge better.
Regarding to multi-scale factor, the wavelet analysis is a good and effective way to
extract the edge of a workpiece’s image [5]. When a large scale factor is applied, we can get
stable edge with higher anti-noise performance. When a small scale factor is applied, we can
get more information on an edge with higher localization performance.
Firstly, smooth the image with filter function. Assume that  (u,v) is a 2-D Gaussian
function with  (u, v)dudv  0 , then take the mother wavelet function as following function (1).

 (1) (u , v ) 


 (u , v )
 (u , v)
,  ( 2 ) (u , v ) 
v
u

(1)

u v
1
1 (1) u v
( 2)
 ( , ) and   (u, v)  2  ( 2 ) ( , ) , then the wavelet transform
 
2
 

is computed as follow equation (2).

(1)

If   (u , v) 

function

,

Wa1 f ( x, y )  f ( x, y ) * a1
 2
Wa f ( x, y )  f ( x, y ) * a2
At the scale factor

2 , function

(2)
,

is computed as follow equation (3).


d

W 21j f ( x, y )
 ( f *  2 j ( x, y )) 

j dx

2 
  2 j ( f *  2 j ( x, y ))
2
d
W2 j f ( x, y ) 
 ( f *  j ( x, y ))
2

 dy

TELKOMNIKA Vol. 14, No. 2A, June 2016 : 343 – 350

(3)

TELKOMNIKA




ISSN: 1693-6930
1

2

2j

j

345

Where W f ( x, y ) and W2 f ( x, y ) are two differential functions in the horizon and vertical
direction at the scale factor   2 j , which reflect the different edge property along the horizon
direction and vertical direction. And so W f ( x, y) and W f ( x, y) are two sections of a gradient vector.
The module and the phase of the gradient vector are computed by equation (4).
1


2j

2
2j


2
2
M 2 j f ( x, y )  W 21j f ( x, y )  W 22j f ( x, y )


W 2 f ( x, y )
 A j f ( x, y )  tan 1[ 2 j
]
 2
W 21j f ( x, y )


(4)


From above, the local gradient vector’s wavelet modulus maximum M f ( x, y) in the
direction A2 f ( x, y) indicates the corner of the smoothen image f * 2 ( x, y ) , so that the multi-scale
factor edges of the image can be extracted by the local wavelet modulus maximum. In order to
avoid the fake edge, a threshold T is selected, the local wavelet modulus maximum should be
larger than T.
The measurement effect with wavelet modulus maximum algorithm (WMMA) is shown
in Figure 2.
2j

j

j

(a) BARREL

(b) LENS

Figure 2. Measurement effect with wavelet modulus maximum algorithm
2.2. Theory of the Cubic Spline Interpolation
In recent years, a wide variety of approaches of the subpixel technology have been

taken in size measurement system. There are several subpixel-accurate edge detection
algorithms as follows [2, 6].
● Gemetry character: the algorithm is always used to analyze the image with regular
shape (circular, triangle, square shape).
● Interpolation: the algorithm is used to analyze the image with less time and higher
accuracy in localization of an edge, which includes linear interpolation, spline interpolation,
bilinear interpolation, bi-cubic B-Spline surface interpolation.
● Moment estimation: the algorithm is used to analyze an image with higher accuracy in
localization of an edge, but usually take longer time, such as Zernike moment.
Compared with the other two algorithms, spline interpolation is an algorithm with high
accuracy and good anti-noise performance.
It’s necessary to select the right rank of the spline. If there is an image mixed with much
noise, we should deal with the image by the lower rank spline. When we apply the higher rank
spline interpolation, it needs longer time to calculate or probably lead to no computing result.
When we apply the lower rank spline interpolation, it is easy to make the first or second
derivative discontinuous at the end or start point. Therefore the cubic spline interpolation is
mostly applied.
The cubic spline interpolation fits the points of the pixel-accurate edge with a cubic
spline surface [7-10]. The subpixel interpolated points are also considered as a combination
with the points neighborhood around them. Study shows the cubic spline interpolation algorithm

A New Method for Appearance Quality Detection of Lens Module Based … (Zhang Jian-zhong)

346



ISSN: 1693-6930

produces a smoother surface than linear interpolation algorithm. As an example, the cubic
spline subpixel interpolation of a row of pixels is shown in Figure 3 [10-12].

Figure 3. Subpixel cubic spline interpolation of a row of pixels

The cubic spline interpolation formula is given by equation (5).
S i(x )  C i  1

C h 2 (x  x i  1 )
C h 2 (x  x )
(x i  x )3
(x  x i  1 )3
 Ci
 (y i  1  i  1 i ) i
 (y i  i i )
hi
hi
6hi
6hi
6
6

(5)

Where hi=xi-xi-1, xi is the horizon direction or vertical direction coordinate of subpixelaccurate edge point. yi is the grayscale value of the pixel-accurate edge point. C0~Cn are
computed by the following matrix equation (6).
 2

 1
 0








a0

0

2

a1

2

2

2

n  1
0

an  2
2

n

 d0 
 C 0 




C
1
 d1 


 d2 
 C 2 




      
d 
0  C n  2 
 n 2


an  1  C n  1 
d n  1 
d 
2   C n 
 n 

(6)

Where
ai 

hi 1
;
hi 1  hi

 i  1  ai 
di 

hi
;
hi 1  hi

y  y i y i  y i 1
6
( i 1
).

hi 1  hi
hi 1
hi

If we detect the above subpixel-accurate boundary, we can select a first point on the
detected pixel-accurate edge, construct the cubic spline function with the search of
neighborhood points (left and right, left and right). The function Si (x) is given by equation (7).
 S1 ( x)
 S ( x)

2
Si ( x )  

S1022 ( x)

( x1 , x2 )
( x2 , x3 )

( x1022 , x1023 )

TELKOMNIKA Vol. 14, No. 2A, June 2016 : 343 – 350

(7)

TELKOMNIKA



ISSN: 1693-6930

347

Where the point’s light intensity function is maximized, there is a desired subpixelaccurate edge point, and so we can obtain all the subpixel-accurate boundary points by
calculating the extremum of the function S i (x ) point by point. As usual, we can obtain the
extremum by calculating that the second derivative of Si (x) with respect of x is zero.
From above, the pixel-accurate edge of an image is obtained at the position where the
wavelet modulus is maximized. The experimental process description of cubic spline subpixel
edge detection algorithm is shown in Figure 4.

Start

(1)
( 2)
Select the filter function  (u , v ), (u , v ) ,smooth the image

Reset the storage area ,define the cycle variables

Calculate the two-dimensional wavelet coefficients

Calculate the module and phase of the gradient vector

  2 j 1
N
Is it a maximum?

Y

Y
Next point
Eliminate the weak edge point

Y
N
The last point?
Y

Y

The largest scale?

N
Y
Edge detection
Spline interpolation , obtain subpixel edge,calculate the size of a
workpiece

End

Figure 4. Experimental process description of the cubic spline subpixel edge detection algorithm
3. Results
Install the experimental device and detect the appearance quality for lens module with
machine vision.The experimental equipment is shown in Figure 5. The resolution of this
industrial camera is 1280×1024 pixels.

A New Method for Appearance Quality Detection of Lens Module Based … (Zhang Jian-zhong)

348



ISSN: 1693-6930

Figure 5. Experimental equipment

Besides the coordinates with the two subpixel-accurate measurement edges of the
image, we can measure the subpixel-accurate size of the LENS. The local size measurement
effect at a different wavelet scale is shown in Figure 6. Some experiments are carried out to test
this method. The LENS’s size deviation with different edge detection algorithms is shown in
Table 1.

(a) j=1

(b) j=2

Figure 6. Local measurement effect at a different scale

Table 1. The LENS’s size deviation with different edge detection algorithms (unit:mm)
NO.
1
2
3
4
5
6
7
8
9
10

Canny
-0.01947
-0.02617
0.10133
-0.01947
-0.02617
0.09463
-0.02617
-0.02617
-0.02617
-0.02617

Wavelet spline subpixel algorithm
-0.000335
0.000335
0.000335
0.000335
0.000335
-0.000335
-0.000335
-0.000335
0.000335
-0.000335

Wavelet modulus maximum algorithm
-0.00306
0.01194
0.01454
-0.00566
-0.00566
-0.00226
-0.00226
-0.00226
-0.00306
-0.00226

Compared with the pixel-accurate edges, subpixel-accurate edges can more accurately
reflect the true LENS’s size. The LENS’s size deviation graph with different edge detection
algorithms is shown in Figure 7.

TELKOMNIKA Vol. 14, No. 2A, June 2016 : 343 – 350

TELKOMNIKA



ISSN: 1693-6930

349

Figure 7. The LENS’s size deviation graph with different edge detection algorithms (unit:mm)

In order to clarify the anti-noise performance of this algorithm, we do some other
experiments. Firstly, the BARREL’s image is mixed with salt and pepper noise, shown in Figure
8. When the noise density is greater than 0.33, the measurement with the Sobel operator has
the distinct error. But the wavelet modulus maximum and the subpixel algorithm of wavelet
modulus maximum just take on a slight fluctuation. By changing the wavelet scale, we also can
finish an accurate measurement with the two algorithms.Therefore, the anti-noise characteristics
of wavelet modulus maximum or wavelet spline subpixel algorithm is better than that of Sobel.

(a) Sobel

(b) WMMA

Figure 8. BARREL’s measurement with salt and pepper noise

From the experimental results with the wavelet spline subpixel algorithm, the LENS’s
size relative accuracy is about 0.7 um, which fully meets the needs of the appearance quality
detection of lens module.The accuracy of the size measurement system is significantly better
than that of the pixel-accurate solution method. The LENS’s size measurement system with the
wavelet spline subpixel algorithm also has a good anti-noise performance, and the effectiveness
and usefulness of the proposed subpixel algorithm are confirmed.
4. Conclusions
This paper addresses a new method based on machine vision for the appearance
quality automatic detection of lens module and put forward a new way of lens module’s
measurement based on a wavelet spline subpixel algorithm. In the process of appearance
quality detection of lens module, this method has an important significance to reduce the
amount of labor workers, improve the automation and intelligence degree of the lens module’s
appearance quality detection.

A New Method for Appearance Quality Detection of Lens Module Based … (Zhang Jian-zhong)

350



ISSN: 1693-6930

References
[1]

T Sutikno, M Facta, GRA Markadeh. Progress in Artificial Intelligence Techniques: from Brain to
Emotion. TELKOMNIKA Telecommunication Computing Electronics and Control. 2011; 9(2): 201202.
[2] Manfred H Hueckel. A Local Visual Operator Which Recognizes Edges and Lines. Journal of the
Association for Computing Machinery. 1973; 20(4): 634-647.
[3] Sekhar A, Raghavendrarajan V, Kumar RH, et al. An Interconnected Wind Driven SEIG System
Using SVPWM Controlled TL Z-Source Inverter Strategy for Off-Shore WECS. Indonesian Journal of
Electrical Engineering and Informatics (IJEEI). 2013; 1(3): 89-98.
[4] Ali J Tabatabai, O Robert Mitchell. Edge Location to Subpixel Values in Digital Imagery. IEEE
Transactions on Pattern Analysis and Machine Intelligence. 1984; 6(2): 188-201.
[5] Kris Jensen, Dimitris Anastassiou. Subpixel Edge Localization and the Interpolation of Still Images.
IEEE Transactions on Image Processing. 1995; 4(3): 285-295.
[6] ZHANG Jianzhong, HE Yongyi, LI Jun. Research on Positioning Compensation in the Pick-and-Place
System. JCIT: Journal of Convergence Information Technology. 2013; 8(10): 340-348.
[7] Singh S, Chana I. Cloud Based Development Issues: A Methodical Analysis. International Journal of
Cloud Computing and Services Science. 2013; 2(1): 73.
[8] Jinyu Hu and Zhiwei Gao. Distinction immune genes of hepatitis-induced heptatocellular carcinoma.
Bioinformatics. 2012; 28(24): 3191-3194.
[9] Cui Y, Zhang S, Chen Z, Zheng W. A New Digital Image Hiding Algorithm Based on Wavelet Packet
Transform and Singular Value Decomposition. TELKOMNIKA Indonesian Journal of Electrical
Engineering. 2014; 12(7): 5408-5413.
[10] Lv Z, Li X, Zhang B, et al. Managing Big City Information Based on WebVRGIS. IEEE Access. 2016;
4: 407-415.
[11] Yang J, Lin Y, Gao Z, et al. Quality Index for Stereoscopic Images by Separately Evaluating Adding
and Subtracting. PloS one. 2015; 10(12): e0145800.
[12] Jiang D, Xu Z, Lv Z. A multicast delivery approach with minimum energy consumption for wireless
multi-hop networks. Telecommunication Systems. 2015: 1-12.

TELKOMNIKA Vol. 14, No. 2A, June 2016 : 343 – 350