Machine Vision and Applications (2012) 23:197–215 DOI 10.1007/s00138-011-0354-8
ORIGINAL PAPER
An algorithm to estimate the crown patterns of diamonds based on machine vision Zhiguo Ren · Jiarui Liao · Lilong Cai
Received: 25 February 2009 / Revised: 3 March 2011 / Accepted: 16 June 2011 / Published online: 29 October 2011 © Springer-Verlag 2011
Abstract In this paper, we describe an algorithm that estimates the cut quality of the crown patterns of diamonds based on machine vision. To accurately extract the features of the edges of diamonds in complicated diamond images, a strategy based on multi-scale decomposition is employed. Using an enhanced Eigen space method, the orientation of the diamond can be roughly estimated. From the traditional least squares distance method, we derive the conditions of the least squares distance weighted by wavelet transform modulus. Then, the problem of diamond-edge feature extraction is transformed into a virtual control process through building a virtual girder truss model (VGTM) and a virtual attraction field (VAF). Using two stages, rough feature extraction and refined feature extraction, all the desired diamond edges can be accurately located by the virtual beams in the VGTM. Then, the cut quality of the diamond’s crown pattern can be effectively estimated according to the feature extraction results. The algorithm is demonstrated with a real machine vision system. Keywords Diamond measurement · Linear feature extraction · Least squares distance · Virtual control system
1 Introduction Natural diamonds usually need to be cut into exact shapes and proportions before they can be resplendent with brilliance, Z. Ren (B) · J. Liao · L. Cai Department of Mechanical Engineering, Hong Kong University of Science and Technology, Clear Water Bay, Kowloon, Hong Kong e-mail:
[email protected] L. Cai e-mail:
[email protected]
scintillation and even patterns of bright and dark fields. Because of the inherent inaccuracy of diamond cutting, diamonds need to be graded according to their cut quality. Although there are various criteria for diamond cut grading, the proportion and symmetry of a diamond remain the two most important factors in diamond cut grading. At present, diamond cut grading often depends on complicated manual operations. To estimate the cut quality of a diamond, some optical measurements can be conducted by means of special equipment like a Brilliancescope, Firescope, Hearts and Arrows View, and Idealscope. However, manual cut grading has a number of drawbacks, including the subjectivity of the grader, the grader’s poor perception of integrity, and the process’s low efficiency and high cost. Developing an automated measuring system with high reliability and precision for diamond cut grading is, therefore, an important research topic. However, almost no significant methods or mature technologies that can automatically implement diamond cut grading are found or reported. As charge-coupled devices (CCD) can obtain abundant information about the color and light intensity of inspected objects, they have been widely used in various inspection systems. To design a diamond auto-grading system based on machine vision technologies may be a feasible approach to replace current manual operation. The crown pattern of a diamond is the geometrical structure of the top projection of a diamond on a parallel plane. The crown pattern is essential to a diamond’s appearance, and the quality of the crown pattern greatly affects the grading of the cut. Here, we focus our investigation on how to estimate the cut quality of the crown pattern of a standard round diamond using machine vision. The cut quality of the crown pattern of a diamond refers to the proportion, coherence and the symmetry of the facets in a diamond’s crown projection. It can be estimated using the
123
198
geometrical properties of the facet projections. As an ideal diamond crown is a polyhedron composed of 33 facets, the crown pattern can be represented by the most distinct features, the linear edges of the diamond. We, therefore, first extract the linear features of the desired edges in a diamond image before estimating the pattern’s cut quality. During the last 30 years, various edge detection methods have been extensively analyzed in image processing and computer vision studies [1–3]. Among these methods, the classical edge detection scheme of the Canny Operator provides the best performance in most cases. Since an edge on the crown is the intersecting line of two adjoining facets, it can be represented by a line segment. Hence, the major problem we face can be reduced to linear feature extraction of desired edges in a diamond image. Line detection is an important task in identifying linear features in images. The Hough Transform (HT) method is one of the most widely used techniques for locating straight lines in a binary digital image [4–6]. It has been enhanced with the addition of other sophisticated methods [7–12]. Based on HT, Duda and Hart developed a standard method to detect lines in a binary image [7]. This method transforms pixels belonging to an object image onto a parameter space. Employing the “voting” principle, every pixel can be considered as a “feature” that contributes one vote to a given bin, called an “accumulator” cell. Thus, peaks in the parameters space can be thought of as the straight lines in the image domain. Line fitting is another important method in detecting linear features in images [13–15]. The conventional least squares distance method can fit a straight line to a set of data points through minimizing the average squared distance of the points to the line when there are no points far from the line. Assuming the noise to be uniform over the image, Weiss proposed an approach for line fitting [13]. The approach can estimate the noise using the maximum likelihood method and remove most of it. By estimating the underlying probability density function (pdf) of the data set, Qjidaa and Radouane presented another method for line fitting [14]. In their method, the points corresponding to the maxima of the pdf can be selected as the real points of the line, and other points will be removed as noise for line fitting. Least squares linear template matching is also applied in linear feature extraction [16–18]. The image matching can be expressed as vv = min, and v is the grey-difference between the two image blocks of a feature template and a matched image. When the template is designed with linear features, the linear feature in the matched image can be exactly extracted through minimizing the squared sum of the grey-difference. At present, these linear feature extraction methods have been widely applied in various measurements of industrial parts. Depending on the known precise CAD model, the ideal projections of desired linear edges in the acquired image can
123
Z. Ren et al.
be calculated and can be thought of as the primary estimation of the extracted linear features. Then, by applying line fitting or least squares linear template matching, desired linear feature can be extracted independently. However, diamond images are very different from these images of ordinary opaque artificial objects. Diamonds are complex, transparent polyhedrons that make the optical characteristics of reflection and refraction extremely complicated and that create numerous uncertain bright fields and dark fields. All the visual characteristics including the edges, various defects, surface abrasions and fractures, etc. will be over-projected onto a single image and will make the features of the desired edges blurred, uneven and discontinuous in an image. In addition, some diamonds are cut with large errors due to the complicated cutting procedure or to yield larger weight. All the properties make the problem about automatic linear extraction of edges very challenging. Although conventional linear feature extraction methods can detect the most clear straight lines in the images of industrial parts, they often fail to correctly extract all the desired linear features of edges in a diamond image. The methods based on HT often lack enough robustness or accuracy. Line fitting and least squares linear template matching usually need the best initial values and greatly depend on highly localized information. Therefore, how to accurately extract the linear features of the desired edges with high robustness is the central issue in estimating the cut quality of the crown pattern of a diamond based on machine vision. In this paper, we propose a measurement scheme to accurately estimate the cut quality of the crown patterns of diamonds. Besides the enhanced Eigen space method to estimate the diamond’s orientation, the major contribution of this paper is to transform the problem of how to accurately extract linear features in a complicated diamond image into a virtual problem of non-linear motion control. Virtual non-linear motion control depends on not only the localized information but also the global information of the extracted features. Using the feature extraction strategy from roughness to fineness, all the desired linear edges can be accurately located with high robustness. Then, the cut quality of the crown pattern can be conveniently estimated according to the obtained linear features of the desired edges. The algorithm proposed in this paper is not limited to diamond measurements. It can be used to measure other artificial objects that can be represented by various line segments in complicated images. This paper is organized as follows. We briefly introduce the proposed methodology through a flowchart in the next section, and the pre-processing and multi-scale decomposition in Sect. 3. In Sect. 4, we present the estimation algorithm to detect a diamond’s orientation. Then, we illustrate the details of the proposed rough linear feature extraction algorithm and refined linear feature extraction algorithm, respectively, in Sects. 5 and 6. Section 7 reports various
An algorithm to estimate the crown patterns of diamonds
experimental results to verify the proposed algorithm. In the last section, we summarize the algorithm and give our conclusions on the proposed algorithm.
2 Overview the proposed algorithm A standard round diamond is composed of a crown, a girdle and a pavilion (Fig. 1). A diamond’s crown pattern can be obtained through projecting the diamond crown on a parallel plane. Using a special image acquisition system, the diamond crown can be perpendicular projected onto the center of a CCD. We can then consider the obtained images as the diamond’s crown pattern if we ignore the effect of crown height, which is extremely tiny compared with the focus length. The acquired diamond images contain various visual characteristics of a scene. The geometrical features, such as topological structure, shape and size, can be observed through optical characteristics, which may be edges, texture, graylevel, colors, etc. As a diamond crown is composed of 33 small facets that include one table facet, eight star facets, eight upper-main facets, and 16 upper-girdle facets (Fig. 2), any two adjoining facets will intersect on a linear edge. Clearly, all the geometrical features of a standard crown pattern can be represented by these linear edges.
199
As linear diamond-edge feature extraction is a complicated process, we employ an extraction strategy from roughness to fineness. Then, using the proposed algorithm, we obtain all the linear features of the desired edges. By combining the calibration results of the machine vision system, we can accurately calculate the position of every extracted linear edge, and reconstruct the entire geometrical structure of the diamond’s crown pattern. Furthermore, we propose an integrated method to accurately estimate the cut quality of the obtained diamond crown pattern. Our proposed algorithm includes three main sections: image pre-processing and multi-scale decomposition, linear feature extraction, and estimating the cut quality of the crown pattern. Clearly, accurately extracting the linear features of desired edge is the most important section. Because of the complex reflection and refraction of the optical characteristics, the different facets on a diamond image or the different parts of a facet may show different gray levels. Edges mean the discontinuity of gray in an image and can be detected through searching the singular gradient. We can employ wavelet transform to decompose the diamond images and obtain the modulus images that can show the gradient at different scales. The modulus images at large scales have high signal-to-noise ratio (SNR) and large phase shifts, and those at small scale have low SNR and small phase shifts. Therefore, based on the wavelet transform modulus images, the feature extraction strategy from roughness to fineness can be easily carried out. In this paper, the feature extraction of linear edges can be divided into three distinct stages: estimation of the diamond’s orientation, rough linear feature extraction, and refined linear feature extraction. Figure 3 shows the flow chart of the proposed algorithm. In the following, we will briefly introduce the main steps in our proposed algorithm.
Fig. 1 Structural model of a diamond profile
2.1 Pre-processing and wavelet transform
Fig. 2 Structural model of a crown pattern
After acquiring a diamond image, the first step is to segment the object area in the original image. Then, the segmented image will be decomposed into different scales by wavelet transform. Wavelets, as a mathematical tool for hierarchical decomposition in the frequency domain by preserving the information in the spatial domain, are very feasible to be used to accurately locate a discontinuous position in a given signal. A combination of wavelet transform and multi-scale technology can effectively detect the edges in an image. Based on this method, Mallat and Zhong proposed the multi-scale edge representation of images through calculating the multi-scale gradient maxima [19,20]. At every level of the scales, the modulus image can be calculated depending on the two decomposition components
123
200
Z. Ren et al.
Fig. 3 Flow chart of the proposed algorithm
along the X and Y directions, respectively. These modulus images include abundant potential information about desired edges at different scales and can be used in the following stages for linear feature extraction.
2.2 Estimation of the orientation of a diamond The orientation of a diamond is random with the table down when an image is acquired by the image acquisition system, and there are often large errors among diamond table sizes (or table proportions). We, therefore, first estimate the azimuth angle and table size of the diamond. Since the Eigen space algorithm has been successfully applied to estimate the position and pose of an object in the investigation of 3D object recognition [21,22], it can also be employed to estimate the orientation of a diamond. Considering that diamond images are complicated and diversity, we improve the Eigen space method and apply it to the wavelet transform modulus image at a large scale. Then, the azimuth angle and table size of the diamond can be roughly estimated. The details of the method are described in Sect. 4.
2.3 Rough linear edge feature extraction Using the obtained diamond orientation and known model of standard crown pattern, we can roughly locate the pattern position in the image of a diamond. Then, combining the global information of desired edges, an algorithm for linear feature extraction is proposed based on virtual girder truss model (VGTM) and virtual attraction field (VAF), which are built according to the standard diamond crown pattern and the wavelet transform modulus image respectively. Under the control of a proposed non-linear controller for the virtual system, all the virtual beams in the VGTM can harmoniously converge to the balanced positions in the VAF. These positions of the virtual beams can form the rough estimation of extracted linear features. A description of the proposed algorithm is given in Sect. 5.
123
2.4 Refined linear edge feature extraction Because of manufacturing errors, real adjoining edges of a diamond often do not intersect on a common point. In this section, to continuously improve the precision of the linear edge feature extraction, the virtual joints connecting the proposed VGTM are removed, and the VAF is re-built in the modulus image at the smallest scale. Then, based on the results of rough linear edge feature extraction, the updated controller can drive all the beams to move continuously towards the positions of the desired edges independently. The final positions of all the beams can accurately locate all the desired linear edges. The results of linear feature extraction can satisfy the least squares distance weighted by the wavelet transform modulus. Furthermore, according to multi-plane intersection theory, we can exactly reconstruct the entire diamond crown pattern. 2.5 Estimation of the cut quality of the crown pattern of a diamond In the last step, using the results of the machine vision system calibration and the reconstruction of the diamond crown pattern, we propose a method to accurately estimate the cut quality of the diamond crown pattern through transforming the coordinates of the vertexes of the main facets in the obtained pattern.
3 Preprocessing and multi-scale decomposition Before correctly analyzing a diamond image, we firstly segment the diamond area from an original image acquired by the developed image acquisition system. The global optimal gray threshold can be calculated by minimizing the intra-class variance of the black and white pixels [23]. Then, depending on the obtained threshold and simple morphology methods, the exact diamond area can be segmented from the background easily, and the size of the segmented object image can be notated as N × N .
An algorithm to estimate the crown patterns of diamonds
201
Using wavelet transform, the 2D image signal can be decomposed into multi-scale. The wavelet transform of f (x, y) at scale 2 j for point (x, y) has two components along the x and y directions, respectively, and can be given by j j Wx2 f (x, y) = f (x, y)∗ψx2 (x, y) , (1) j j W y2 f (x, y) = f (x, y)∗ψ y2 (x, y) where * denotes the convolution operation and ψ(x, y) represents the basic wavelet. Therefore, at the scale 2 j , the modulus of the wavelet transform can be given by j j j M 2 f (x, y) = |Wx2 f (x, y)|2 + |W y2 f (x, y)|2 . (2) Although many wavelets or other methods can be used to decompose diamond images at different scales, we will adopt B-spline wavelets in the algorithm. It has some special advantages for edge detection and has been applied widely [24–26]. As wavelet functions are derived from the scaling function, an image can be decomposed into finer and finer details. In this paper, we decompose a diamond image into three different scales. According to (2), we can obtain the three modulus images with the size of N × N at scale I ( j = 1), N /2 × N /2 at scale II ( j = 2), and N /4 × N /4 at scale III ( j = 3). As the modulus images have high SNR and large phase shifts at large scales, and they have low SNR and small phase shifts at small scales, we can apply the three modulus images from the larger scale to the smaller scale to the feature extraction strategy from roughness to fineness.
4 Estimation of the orientation of a diamond As the measured diamonds are round, when a diamond is placed into the inspection system with the table facet down, the azimuth angle of the diamond in the image is random. In addition, there are often large errors in the table sizes (or table proportions) among different diamonds. Therefore, we need to design an algorithm to estimate the azimuth angle, θ , and the table size (denoted by r ) of the diamond, which are shown in Fig. 4a. As the Eigen space algorithm has been successfully applied to estimate the position and pose of an object in the investigation of 3D object recognition, we can estimate the azimuth angle and table size of the diamond by enhancing this method. Because the wavelet transform modulus at large scale can remove the noise well, the modulus image at scale III will be used to act as the input in the algorithm. Since there are various differences among real diamonds, instead of taking images from different orientations of different diamonds, we design a series of imitational wavelet transform modulus images of standard diamond crown projections with different azimuth angles and table sizes. They have the ideal common characteristics of the real input images. Figure 4b shows one of the imitational wavelet transform
Fig. 4 (a)The azimuth angle, θ, and the table circumradius, r , of a diamond; (b) one of the imitational wavelet transform modulus images of a standard diamond crown projection
modulus images of standard diamond crown projections. Using these images, we can construct the necessary Eigen space and project them into it. Then, the input modulus image of the measured diamond can be projected into the Eigen space. In the Eigen space, we can find the nearest imitational modulus image from the input image. The azimuth angle and table size of the nearest imitational modulus image will be the estimated parameters of the measured input image. To construct the Eigen space, a series of imitational standard modulus images can be constructed with equal azimuth angle differences, θ , and equal table circumradius difference, r . There are n imitational standard modulus images to construct the Eigen space, and each of them has M × M pixels. Firstly, we rearrange the image matrix into a normalized vector with a zero mean. For the ith imitational standard modulus image, the normalized vector, xi , can be given by xi = [ pi1 , pi2 , pi3 , . . . , pi(M×M) ]T − ai (i = 1, 2, . . ., n) (3) M M 1 where ai = M×M x=1 y=1 pi (x, y), and pi (x, y) is the value of pixel (x, y) of the ith standard modulus image. Then, we can arrange all the normalized vectors into a new (M × M) × n matrix: X = [x1 , x2 , x3 , . . . , xn ].
(4)
Furthermore, we can calculate the covariance matrix, Q = X X T , and its Eigen equation: λ j e j = Qe j ,
(5)
where λ denotes the Eigen values and e denotes the Eigen vectors that can be calculated off line. The Eigen space can be constructed by the Eigen vectors which are also called basis vectors. To reduce the dimensions of the space, we select k Eigen vectors in respect to the k largest Eigen values and project the image vectors, xi , into the Eigen space spanned by
123
202
Z. Ren et al.
the k basis vectors. The projection result can be represented by pointz i with k dimensions: z i = [e1 , e2 , e3 , . . . , ek ]T xi .
(6)
The real wavelet transform modulus images usually have uneven and discontinuous pattern with various disturbances. According to the approximate symmetry about the multiaxis of a real diamond crown pattern, the wavelet transform modulus image can be enhanced by ⎛ I =
1⎝ 1+ 8
7
⎞ Rot(Z , jπ/8)⎠ I0 ,
Fig. 5 Relationship between point Pi and the fitting line
(7)
j=1
where I0 denotes the input image, and I denotes the enhanced image, and Rot(Z , ∗) represents the rotation operation about the Z axis, which is perpendicular to the image plane and through its center. The approximately symmetrical desired signal can, therefore, be enhanced, and most of the random noise can be weakened. Then, the enhanced input image can be normalized and rearranged with unified size and zero mean according to (3). Furthermore, the normalized input image can be projected into the point g in the Eigen space g = [e1 , e2 , e3 , . . . , ek ] y, T
(8)
where y is the measured normalized input vector. The distance between g and z i in the Eigen space can be calculated by di = ||g − z i ||.
(9)
Then, the set di can be rearranged into a 2D matrix and can be represented by d(θ, r ), where θ = uθ and r = r0 + vr (u = 0, 1, 2, . . . , U ; v = 0, 1, 2, . . . , V ). We can then find the nearest point to g, where d(θ, r ) has the minimum value. Obviously, the azimuth angle, θ , and the table size (or circumradius proportion), r , of the obtained nearest point will be the estimated parameters of the measured input image. Furthermore, to improve the robustness of the method, we define: V d(uθ, r0 + vr ) d(θ ) = V1 v=1 . (10) U 1 d(r ) = d(uθ, r + vr ) U
u=1
0
Then, by minimizing d(θ )and d(r ), we can get the estimated azimuth angle, θe , and circumradius, re , respectively, from
θe = θ |d(θe )=min(d(θ)) . re = r |d(re )=min(d(r ))
123
(11)
The obtained parameters, θe , and re , will be used in the next section. 5 Rough linear edge feature extraction Based on the least squares distance, the conventional line fitting methods can fit a straight line to a set of data points through minimizing the average squared distance of the points to the line. The average squared distance can be represented by S=
N 1 2 D (Pi , L(ϕ, b)), N
(12)
i=1
where Pi and L(ϕ, b)denote the ith point in the given N points and the fitting line, respectively. D(Pi , L(ϕ, b)) represents the perpendicular distance from the point, Pi , to the line, L(ϕ, b), which can be represented by interceptb and angle ϕ(−π/2 < ϕ ≤ π/2) between the X axis and the fitting line. The condition for Sto be a minimum is that ∂S ∂S | S=min = 0 and | S=min = 0, or ∂b ∂ϕ N ∂ D(Pi ,L(ϕ,b)) | S=min = 0 i=1 D(Pi , L(ϕ, b)) ∂b . (13) N ∂ D(Pi ,L(ϕ,b)) | S=min = 0 i=1 D(Pi , L(ϕ, b)) ∂φ According to the definition of partial differentiation, we can get ⎧ ,L(ϕ,b)) ⎨D(Pi ,L(ϕ,b+b))−D(Pi ,L(ϕ,b)) b→0 = ∂ D(Pi ∂b b (14) ∂ D(Pi ,L(ϕ,b)) ⎩D(Pi ,L(ϕ+ϕ,b))−D(Pi ,L(ϕ,b)) ϕ→0 = ϕ ∂ϕ Figure 5 shows the relationship between point Pi and the fitting line, L(ϕ, b). Hence, we can get ∂ D(P ,L(ϕ,b)) i = sign(Pi , L(ϕ, b)) cos(ϕ) ∂b , (15) ∂ D(Pi ,L(ϕ,b)) = sign(Pi , L(ϕ, b))l ∂ϕ where l is the distance from point Pi to the intercept intersection along the lineL(ϕ, b) (Fig. 5). sign(Pi , L(ϕ, b)) can be defined as
An algorithm to estimate the crown patterns of diamonds
sign(Pi , L(ϕ, b)) =
203
−1 Pi above the line L (16) 1 Pi on or below the line L
Then, according to (13) and (15), we can get N i=1 sign(Pi , L(ϕ, b))D(Pi , L(ϕ, b)) | S=min = 0 . N i=1 sign(Pi , L(ϕ, b))D(Pi , L(ϕ, b))l | S=min = 0 (17) Clearly, when the condition in (17) is met, the lineL(a1 , a2 ) will be the best-fitting line to the given set of data points. Unfortunately, the points far away from the line often have significant effects on the fitting line, but they may be noise or undesired data points. When there is large disturbance in the fitted data points or large errors in the initial positions of the fitting line, the conventional methods often fail to extract the desired linear features. Although using weighted distance can weaken the effect of the points far away from the line, it is difficult to estimate the weights. To extract all the linear features of the desired edges accurately, we propose a method that can be derived from (17). As wavelets have a natural capability to remove noise and highlight the edge signal in an image, the modulus of wavelet transform can be used as the input data. Therefore, the final fitting lines in the proposed method will satisfy N 2j i=1 M f (x, y)sign(Pi , L(ϕ, b))D(Pi , L(ϕ, b)) = 0 , N 2j i=1 M f (x, y)sign(Pi , L(ϕ, b))D(Pi , L(ϕ, b))l = 0 (18) where N is the number of pixels in the final fitting window. Apparently, the condition described in (18) can minimize SW =
N 1 2j M f (x, y)D 2 (Pi , L(ϕ, b)). N
(19)
i=1
Although (refeq18) can ensure the precision of the fitting line in a reasonable narrow fitting window, how we reliably locate the desired linear edges is another difficulty. In this paper, we employ the global information of desired edges to enhance the reliability and robustness of linear feature extraction. The ideal edges are a grid structure, and the adjoining diamond-edges can intersect on a common point. Therefore, the topological structure of the desired edges can provide effective constraints to the fitting lines. To clearly demonstrate the proposed method, we transform the problem of how to extract the linear features in a complicated diamond image into a virtual process of nonlinear motion control in a virtual system. In the virtual system, the fitting lines are imagined as virtual beams, and the pixels with the value of the wavelet transform modulus can be imagined as virtual attraction sources. According to the standard diamond crown pattern and the wavelet transform modulus, we can build a VGTM and a VAF. In the VGTM, all the beams are connected by
virtual joints. When the VGTM is placed in the VAF with the estimated azimuth angle, all the beams will be attracted by the virtual attraction sources. Under the control of the proposed non-linear controller, they can move towards the corresponding linear edge. When all the beams exactly move onto the desired edges and the virtual resultant force on each beam converges to zero, the beams will locate all the desired linear edges. In the following subsections, we introduce the VGTM, the VAF and the non-linear motion controller for the virtual system. 5.1 Modeling the virtual girder truss Depending on the segmented image of diamond area, we can calculate the radius of the diamond using the following equation: N N 1 I (x, y), (20) R= π y=1 x=1
where I (x, y) is the binary image of the diamond area segmented from the original image. According to the standard diamond crown pattern, with the obtained azimuth angle,θe , the circumradius, re , of table facet, the diamond’s diameter, R, and the mass center, of diamond area, we can construct the ideal projection of the diamond’s crown. Since the ideal projection of the diamond’s crown can produce a linear grid structure including 48 line segments, we can consider the projection of the edges as a VGTM that is built by 48 virtual beams and 32 virtual joints (Fig. 6). In the VGTM, every beam represents a fitting line for a desired linear edge. These beams can be denoted as Bai , Bbi , Bci , and Bdi . Each of them has joint holes at its two ends, which are denoted as (Bai+ , Bai− ), (Bbi+ , Bbi− ), (Bci+ , Bci− ), and (Bdi+ , Bdi− ). When these beams are subjected to an external force, we assume that they can be stretched or compressed without bending.
Fig. 6 A virtual girder truss model (VGTM)
123
204
Z. Ren et al.
5.2 Modeling the virtual attraction field Using the wavelet transform modulus image at scale II, we can build a VAF, in which every pixel is a virtual attraction source. By rewriting (2), the intensity, G(x, y), of the virtual attraction source can be defined as (21) G(x, y) = |W21j f (x, y)|2 + |W22j f (x, y)|2 . When the VGTM is put into the VAF with the obtained orientation, all the beams will be attracted by the virtual attraction sources. To ensure the effectiveness of the algorithm, we limit the attraction source in a valid range beside the beam, in which the perpendicular distance from the valid attraction source to the beam will be limited by the width, W . Distinctly, in a reasonable range, the narrower the valid area of attraction is, the more accurate the feature extraction. To keep high accuracy and robustness, the width of the valid range can be defined by k−1 π + W0 , (22) W = Wv 1 + cos NC − 1 where NC is the total motion time (or the total amount of sampling period in a discrete system) and k is the current time. Wv is a constant and W0 is the smallest width of the valid range. In the virtual system, the attraction is perpendicular to the beams and is in direct proportion to the intensity of the virtual attraction source described in (21). This rule ensures that the beams can converge to the edges that have the strongest intensity. In addition, we also assume that the attraction is in direct proportion to the perpendicular distance from the attraction source to the beam, as in a spring system. This law will ensure that the beams can quickly move towards far object positions. Therefore, for anyone of these beams, the subjected force distribution on it in local frame can be represented by W f(l) =
G(x, y)D(x, y)dw,
(23)
−W
where G(x, y) denotes the intensity of the attraction source in (x, y) and D(x, y) denotes the perpendicular vector of distance from the attraction source in (x, y) to the beam. l denotes the relative position on the beam from the end point (Bai+ ). The attraction distribution on a beam (Bai ) is shown in Fig. 7. According to the principle of structure mechanics, the distribution of force on each beam can be transformed into a couple of equivalent forces on the two end points of the beam by (1−α)L f(l)(L − l)dl Fai+ = L1 αL , (24) 1 (1−α)L f(l)ldl Fai− = L αL
123
Fig. 7 The distribution of attraction on a beam
Fig. 8 The force status on a joint
where L denotes the length of the beam and α(α = 0.05 in the paper) denotes the length coefficient of the beam for which the force distribution will be ignored to avoid the disturbance from other attraction sources belonging to adjoining beams. Using the same method, we can calculate each couple of equivalent forces on the end points of all the beams. As a virtual joint connects several adjoining beams (Fig. 6), we can calculate the resultant force on every joint. For example, for joint (Pai ), we can obtain F(Pai ) = Fai+ + Fa(i+1)− + Fbi+ + Fb(i+1)− ,
(25)
where Fai+ , Fa(i+1)− , Fbi+ , and Fb(i+1)− are the resultant forces on the end points of beams Bai , Ba(i+1) , Bbi , and Bb(i+1) , respectively. Figure 8 illustrates the force status on the joint (Pai ). Furthermore, using similar equations, we can obtain every resultant force on all joints. 5.3 Non-linear motion control In this section, we design an effective controller to stably control the motion of the VGTM in the VAF. It can ensure that all the beams quickly and reliably move towards the object positions of the desired linear edges. In the proposed control system, we suppose that the motion of the VGTM can be absolutely controlled according to the virtual attraction. The displacement of the joints in a
An algorithm to estimate the crown patterns of diamonds
205
period of time, t, can be defined by: t S(P) =
K V F(P)dt,
(26)
0
where K V is the virtual motion coefficient. Hence, in the discrete control system with sampling periodt, the displacement of the ith joint can be calculated by S(Pi ) =
n
K S F(Pi ),
(27)
k=1
where K S is the displacement coefficient. F(Pi ) is the resultant force on the ith joint Pi , and it can be calculated by (25) or similar equations. Although the virtual attraction can push the beam to move towards the positions of the desired linear edges, the movement of all the beams is extremely complicated due to the unevenness of the VAF and the interaction among the beams through the joints. To control the motion of the beams and improve the adaptability of the virtual system, we propose a non-linear control system. Figure 9 shows the frame chart of the control system. In the virtual system, some beams bear strong attraction, while others bear weak attraction. This will make the movement of the VGTM unstable. To ensure that all the beams can quickly converge to balanced positions, the non-linear controller can be designed by ⎧ F(Pi ) ⎪ ⎪ ⎨ Smax |F(Pi )| ( |K S F(Pi )| >Smax ) S(Pi ) =
K S F(Pi ) , ⎪ ⎪ ⎩ Smin F(Pi ) ( |K S F(Pi )| Smax ) , (31) Si = K S Fi ⎪ ⎩ Fi Smin |Fi | (|K S Fi |