# Automatic Defect Detection in Spring Clamp Production via Machine Vision

Authors: Xia Zhu; Renwen Chen; Yulin Zhang
Journal: Abstract and Applied Analysis
 (2014)

---

## Abstract

There is an increasing demand for automatic online detection system and computer vision plays a prominent role in this growing field. In this paper, the automatic real-time detection system of the clamps based on machine vision is designed. It hardware is composed of a specific light source, a laser sensor, an industrial camera, a computer, and a rejecting mechanism. The camera starts to capture an image of the clamp once triggered by the laser sensor. The image is then sent to the computer for defective judgment and location through gigabit Ethernet (GigE), after which the result will be sent to rejecting mechanism through RS485 and the unqualified ones will be removed. Experiments on real-world images demonstrate that the pulse coupled neural network can extract the defect region and judge defect. It can recognize any defect greater than 10 pixels under the speed of 2.8 clamps per second. Segmentations of various clamp images are implemented with the proposed approach and the experimental results demonstrate its reliability and validity.


---

## Body

## 1. Introduction

With the increasing demands on production quality, system performance, and economic requirement, modern industrial processes are more complicated both in structure and automation degrees. The reliability and safety issues on these complicated industrial processes become the most critical aspects for system design and are receiving considerably increasing attention nowadays [1, 2]. The spring clamp detection system in this paper talks about also facing the problems mentioned above.A spring clamp is rounded by pressing spring steel, with two ears left around the circle. When to be clamped, tight ears need to hold down firmly, making larger set into the inner tube, and then you can loosen the grip of the hand, which is very simple to use, and these are the simple steps for using a spring clamp. The adopted material has high flexibility, good physical properties, and strong firmness, which makes the clamp suit the connection of pipe systems of vehicle cooling, heating, and ventilating. The high elasticity of the clamp compensates the pipe shrinks caused by the change of temperature or the degradation of the pipe. In natural state, the clamp does not have the clamping force. It happens only when exerted to a larger pipe. The clamp can guarantee the reliability of the connection by generating a permanent distortion through the uniform pressure around the circle, which protects the fastness and time within a reasonable range.The clamp detected in this paper is widely used. It is one of the essential accessory substances applied in fixing the vehicle pipes. Its quality, security, and service life are of utmost importance to the vehicle performance. As a result, the clamp detection is a well-concerned problem of the manufacturers. The detection is still relied on manual detecting at present, which causes problems such as labor intensive, low speed, and misdetection. Some foreign institutes started the relevant research to solve the problems above more than 10 years ago and have now made some progress, such as bottle defect detection, fabrication defect detection, vehicle headlamp lenses defect detection, and web defect detection. Our country began to research the automatic detecting technology at the 1990s, such as the detection of presswork quality and detection of float glass fabrication.The pipeline system introduced in this paper is in a nonclosed space, which makes the spot light infected by the natural light and the house illumination; in the meantime, serious background noise will be produced. According to the above peculiarities, we designed a spring clamp real-time detection system based on machine vision. Built on both sides of the production line, this system consists of a special light source to weaken the light interference, a camera with high resolution, an external trigger device which will trigger the camera to acquire an image, a host computer which has program to extract an image, recognize it, give a YES/NO judgment, and display the final results on the screen, and a rejecting mechanism which is used to reject nonconforming products. This system could make it possible to automatically detect the spring clamps and greatly improve the rate of defect identification and defect removal, thereby achieving the goals of increasing the quality of the products and avoiding the actual loss.


## 2. Problem Descriptions

According to the detection characteristics of the pipeline, the defect detection system is built on both sides of the production line. Online real-time detection device depends on the external trigger device to trigger the camera to acquire an image, which has no influence on the real production line. There are four parts in this system: optical illumination, image acquisition, image processing, and rejecting mechanism.For an irregular circle clamp with a smooth curved surface, the image quality will be affected by the illumination mode. Back lighting makes the clamps contour clear, but it also makes it hard to distinguish details. Front parallel lighting will submerge the defects by forming highlights on the other side of the hollow when the light shines through the hollow in the clamp, as shown in Figure1.Figure 1
Images with various lighting illumination pattern.In order to solve the above problems, a new illumination mode, back lighting combined with lateral lighting, is brought out in this paper, of which the details are as follows: (1) front: a white frosted glass is set as the background and a quadrilateral light source is placed parallelly under the glass; (2) lateral: three cameras are placed parallelly above the glass with a120° angle between each other. Each camera obtains an image of 1/3 of the clamp after fixing the relative position, as is illuminated in Figure 2. Images from these three cameras constitute the entire outside surface of the clamp, after which the capturing process will be finished.Figure 2
The illustrated diagram of the clamps lateral image acquisition.The detection process is exposed in Figure3: when the clamp passes through trigger 1, trigger 1 enables the camera A to capture a backlit image of the clamp. The shape and ears will be detected. When the clamp passes through trigger 2, trigger 2 enables the cameras B, C, and D to catch an image of the clamp, respectively. These three images which can constitute the whole external surface of the clamp are then sent to the computer to detect its color, scratch, height, and so on. Once there appears one defect, signal will be sent to the rejecting mechanism through RS485 to pick away the defective one.Figure 3
The model of the workbench.


## 3. Image Processing Algorithm

Image processing is the core technique in this system. With the development of a corresponding technique, a lot of methods are presented, such as neural network (NN) and wavelet, but the applicability of each algorithm is narrow and just effective to their special scenes. The detection algorithm is the kernel of this system. The process is as follows: read images from those four cameras, respectively, and preprocess the images; detect the high, color, shape, crack, and so on; locate the defects, assess the defects, and display the results in the computer and pick away those with defects by rejecting mechanism.


### 3.1. Image Preprocessing

During the production of the spring clamps, there exists image noise in the original image captured in the limited environmental conditions; as a result, the original images should be preprocessed. The algorithm is utilized to reduce noise and delete the unwanted regions.


#### 3.1.1. Region of Interest (ROI)

The field of view of the captured pictures is definite because the relative position of the camera and the clamp is fixed in mechanical design of the system.In order to increase the detection rate and real-time property of the system, it is necessary to locate ROI before image segmentation. We could judge the image based on abrupt changes in grayscale, which is able to determine the ROI effectively and quickly.Summing the gray values of each column of an image in spatial domain (which is shown in Figure4), we obtain Cj:
(1)Cj=∑i=0N-1‍f(xi,yj),j=0,1,…,M-1,
where f(xi,yj) is the gray value of the pixel in the coordinate position (xi,yj). In a similar way, summing the gray values of each row Ri is obtained:
(2)Ci=∑i=0M-1‍f(xi,yj),i=0,1,…,N-1.Figure 4
A spatial domain of the image.As we can see, abrupt changes in grayscale will cause correspondingly changes ofCj and Ri.Then subtracting two adjacent values ofCj, we obtain
(3)Δj=Cj-Cj-1,j=1,2,…,M-1.Considering the characteristics of the clamp, we set a maximum toleranceΔmax⁡=10 pixel. Set up an array flag [M-1]:
(4)flag[j]={j,if|Δj|>Δmax⁡,0,else,fhdfsj=1,…,M-1.In Figure5, X5 is obtained, the first value that is not zero in the series flag [M-1], and X3 is gotten, the last value that is not zero by applying the above algorithm, which could determine the up and down edges in Figure 5. In a similar way, we can also obtain the left and right edges: Y=Y2 and Y=Y4. Thus, the upper-left corner (X5, Y2) and lower-right corner (X3, Y4) will be generated. Finally the ROI area will be fixed, which is shown in Figure 5.Figure 5
The structure display of an image in spatial domain.


#### 3.1.2. Median Filtering Based on Weight Value

The complicated environment of the factory causes noise in our captured images. Meanwhile, in industrial processes uneven tiny scratches and spots can be also caused. The image filtering will solve the above problems effectively. In order to eliminate noise as well as protect the details of an image, median filter is implemented to change the values of those pixels which have biggish gray difference with the surrounding pixels and then eliminate isolated noise.In order to conquer the drawbacks of simple local median filter, different weight values are given to the pixels involved in the operation, which is weighted median filter. Normally the weight values are determined according to the following principles: (1) assign biggish weight value to the pixel to be processed and smaller values to the rest; (2) determine the weight value of the rest of the pixels according to the distance to the pixel to be processed and the closer, the bigger; (3) determine the weight value of the rest pixels according to the degree of closeness between the pixel to be taken up and the one of the rest.


### 3.2. Height Detection

The height of clamp can be calculated from three lateral images. The detection method is as follows. Firstly, detect the edges with ROI and obtain the straight edge linesL1 and L2 by using straight line fitting method at edge points. Secondly, draw a perpendicular bisector (H) in ROI and calculate the points of intersection between H and L1 and H and L2 ((X1, Y), (X2, Y)). Finally, the height can be calculated by the absolute value of X1 and X2. The site test pattern is displayed in Figure 6. As we can see, this method can calculate not only the height of the clamp, but also the height of the hollow part in the middle of the clamp, which can provide a basis for detailed height detection.The height calculation diagrams of the three lateral images.
(a)
(b)
(c)


### 3.3. Defect Detection

The first step is always location of defect, of which the theory is the same as ROI location. After locating the defects comes defect segmentation and recognition. At present, there are some segmentation methods, such as threshold method, the maximum entropy method, and histogram threshold method [3–5]. Due to the inherent characteristics of the product, defects in the images are of small proportion in the whole image. What kind of algorithm to segment defects and clamps greatly is one of the difficulties in this research.After positioning, we can see that, as in the right image in Figure7, some burrs are removed and the defect area is enlarged, which make it easier to improve the processing speed of the software. In order to get the perfect segmentation effect and improve the defects proportion in a histogram of an image to be segmented, segmentation algorithms based on threshold, region segmentation method, morphological segmentation method, and so forth have been tested in the tests. At the end, the PCNN method is adopted, and some improvement has been put forward based on the original. PCNN (pulse coupled neural network) is derived from Eckhorn et al.’s [6] research on nerve cells in the cat visual cortex. In the PCNN model, neurons with similar input generate impulses at the same time, which is able to reduce local gray level difference as well as making up local minor disconnection in an image. PCNN method is unrivalled by other segmentation methods. This property has also been used in fields such as shadow removal, image denoising, and edge extraction.Figure 7
Schematic defect location.On the basis of Eckhorn’s research, Johnson explained PCNN model with circuit theory, which is illustrated in Figure8. Parameter definition is the same as Johnson and Padgett’s [7].Figure 8
The equivalent circuit of neuron.The formula derivation from the circuit in Figure8 is listed below. In the actual derivation, the same mistakes were found in documents from Johnson and Padgett’s [7] and Yide et al’s [8]. Different part between my formulas and theirs is roughly listed below. For detailed derivation of the formulas, see the Appendix
(5)V˙=M~V+R,
where
(6)V=(V1V2)M~=(-1C1(gm1+g12+F)g12C1g12C1-1C2(gm1+g12+L))R=(1C1(gm1Em+FEs-ΔVY(t))1C2(gm2Em+EsL)),
where V1, V2 are the electrical potentials of their neuron membranes. Equation (5) indicates that pulse signal is not only related to the transfer conductance between synapses gs1, gs2, but also related to the equivalent leakage conductance, the equivalent capacitance, and the intrinsic capacitance, which indicates that whether a neuron can be fired depends on the exterior input of its neighboring neuron, as much as its own internal activity.Pulse functionY(t) will be generated when the neuron potential V1 goes larger than the threshold potential; and there are no signals to be generated when the inner activities achieve balance; that is to say, V is zero.Then the following equation can be derived from (5):
(7)V1=a+bF+cL+dFLe+fF+gL+hFL,
where
(8)a=g12gm2Em+g12gm1Em+gm1gm2Em,b=g12Es+gm2Es,c=g12Es+gm1Em,d=Es,e=g12gm2+g12gm1+gm1gm2,f=g12+gm2,g=g12+gm1,h=1.Equation (7) is actually the functional relation of the neuron membrane potentials in equilibrium. It indicates that the nonlinear multiplying modulating coupling property of PCNN is caused by the conductance between the axon of a neuron (presynaptic) and the axon of a neighboring neuron (postsynaptic). While neurons that input conductance are controlled by the pulse voltage, the characteristics of neuronal synapses with this character are transferred to the adjacent conductance neurons.Each neuron includes 3 parts: dendrite, nonlinear connection modulation, and pulse generation element. The model of a PCNN neuron is illustrated in Figure9 [7]. The dendrite is utilized to receive information from the neighboring neurons through the linear connection input channel and feedback input channel. Nonlinear connection modulation, namely, the internal activities of neurons (U), is obtained by multiplying the linear part which has an offset and the feedback input part. The generation of the pulse depends on whether the inner activities can stimulate the dynamic threshold, and the threshold value (E) will be modified with the output state of the neuron. When E is lower than U, the neuron will be stimulated (Y=1), which is called fired. Next E suddenly increases because of the feedback of the output, and thus the neuron will be suppressed immediately (Y=0). The output will yield a pulse signal which connects to the input of the neighboring neuron with weight coefficient, so as to influence the stimulus state of these neurons.Figure 9
The model of PCNN neuron.The model can be described with discrete functions as follows:(9)Fi=∑j‍(MkiYk(t)⨂Φki(t))+Ii,(10)Li=∑k‍(MkiYk(t)⨂Φki(t))+Ji,(11)Ui=Fi(1+βiLi),(12)Yi(t)=step(Ui-Θi),(13)Θi=-αTΘi+VTYi(t),
where ⨂ is convolution, Θij(t)=Aije-αijt is the temporal responses kernel of the ijth neuron, Mij and Wij are the weight coefficient matrices of the linear connection input channel and the feedback input channel, Ii and Ji are the constant inputs, Fi is the feeding input, Li is the linking input, Ui is the total internal activity, Yi is the output pulse, Θi is the neuron threshold, i,j,k represent different neurons, Aij and αij are the dendrite state parameters, αT and VT are the time constant and magnification coefficient of threshold value, VT is usually set to a larger value which is larger than Ui, and βi is the linking strength coefficient. Under this discrete mode, (9)–(13) must be calculated in sequence in the listed order; and Θi and VT use their values as evaluated at the previous time step.In the light of the inherent characteristics of the clamps, weighted median filter is adopted in image processing in the system. At the same time, PCNN algorithm is used to enhance the filtering effect before segmentation. From (11), the value of β influences the filtering effect. A low-pass filter can be used to constrain internal activities so as to reduce noise. Equation (11) can be slightly modified as follows:
(14)Ui=Fi(1+βLi)-r〈∑cells‍Yi(t)〉lowpass,r∈[0,1].By allowingr changing from 0 to 1, (14) gives a significant decrease in both the temporal and the spatial noise when it is turned on the equilibrium operation of the PCNN. The above idea with PCNN is used to realize the image segmentation on the case in this paper, in which further analysis and modification have also been done.


## 3.1. Image Preprocessing

During the production of the spring clamps, there exists image noise in the original image captured in the limited environmental conditions; as a result, the original images should be preprocessed. The algorithm is utilized to reduce noise and delete the unwanted regions.


### 3.1.1. Region of Interest (ROI)

The field of view of the captured pictures is definite because the relative position of the camera and the clamp is fixed in mechanical design of the system.In order to increase the detection rate and real-time property of the system, it is necessary to locate ROI before image segmentation. We could judge the image based on abrupt changes in grayscale, which is able to determine the ROI effectively and quickly.Summing the gray values of each column of an image in spatial domain (which is shown in Figure4), we obtain Cj:
(1)Cj=∑i=0N-1‍f(xi,yj),j=0,1,…,M-1,
where f(xi,yj) is the gray value of the pixel in the coordinate position (xi,yj). In a similar way, summing the gray values of each row Ri is obtained:
(2)Ci=∑i=0M-1‍f(xi,yj),i=0,1,…,N-1.Figure 4
A spatial domain of the image.As we can see, abrupt changes in grayscale will cause correspondingly changes ofCj and Ri.Then subtracting two adjacent values ofCj, we obtain
(3)Δj=Cj-Cj-1,j=1,2,…,M-1.Considering the characteristics of the clamp, we set a maximum toleranceΔmax⁡=10 pixel. Set up an array flag [M-1]:
(4)flag[j]={j,if|Δj|>Δmax⁡,0,else,fhdfsj=1,…,M-1.In Figure5, X5 is obtained, the first value that is not zero in the series flag [M-1], and X3 is gotten, the last value that is not zero by applying the above algorithm, which could determine the up and down edges in Figure 5. In a similar way, we can also obtain the left and right edges: Y=Y2 and Y=Y4. Thus, the upper-left corner (X5, Y2) and lower-right corner (X3, Y4) will be generated. Finally the ROI area will be fixed, which is shown in Figure 5.Figure 5
The structure display of an image in spatial domain.


### 3.1.2. Median Filtering Based on Weight Value

The complicated environment of the factory causes noise in our captured images. Meanwhile, in industrial processes uneven tiny scratches and spots can be also caused. The image filtering will solve the above problems effectively. In order to eliminate noise as well as protect the details of an image, median filter is implemented to change the values of those pixels which have biggish gray difference with the surrounding pixels and then eliminate isolated noise.In order to conquer the drawbacks of simple local median filter, different weight values are given to the pixels involved in the operation, which is weighted median filter. Normally the weight values are determined according to the following principles: (1) assign biggish weight value to the pixel to be processed and smaller values to the rest; (2) determine the weight value of the rest of the pixels according to the distance to the pixel to be processed and the closer, the bigger; (3) determine the weight value of the rest pixels according to the degree of closeness between the pixel to be taken up and the one of the rest.


## 3.1.1. Region of Interest (ROI)

The field of view of the captured pictures is definite because the relative position of the camera and the clamp is fixed in mechanical design of the system.In order to increase the detection rate and real-time property of the system, it is necessary to locate ROI before image segmentation. We could judge the image based on abrupt changes in grayscale, which is able to determine the ROI effectively and quickly.Summing the gray values of each column of an image in spatial domain (which is shown in Figure4), we obtain Cj:
(1)Cj=∑i=0N-1‍f(xi,yj),j=0,1,…,M-1,
where f(xi,yj) is the gray value of the pixel in the coordinate position (xi,yj). In a similar way, summing the gray values of each row Ri is obtained:
(2)Ci=∑i=0M-1‍f(xi,yj),i=0,1,…,N-1.Figure 4
A spatial domain of the image.As we can see, abrupt changes in grayscale will cause correspondingly changes ofCj and Ri.Then subtracting two adjacent values ofCj, we obtain
(3)Δj=Cj-Cj-1,j=1,2,…,M-1.Considering the characteristics of the clamp, we set a maximum toleranceΔmax⁡=10 pixel. Set up an array flag [M-1]:
(4)flag[j]={j,if|Δj|>Δmax⁡,0,else,fhdfsj=1,…,M-1.In Figure5, X5 is obtained, the first value that is not zero in the series flag [M-1], and X3 is gotten, the last value that is not zero by applying the above algorithm, which could determine the up and down edges in Figure 5. In a similar way, we can also obtain the left and right edges: Y=Y2 and Y=Y4. Thus, the upper-left corner (X5, Y2) and lower-right corner (X3, Y4) will be generated. Finally the ROI area will be fixed, which is shown in Figure 5.Figure 5
The structure display of an image in spatial domain.


## 3.1.2. Median Filtering Based on Weight Value

The complicated environment of the factory causes noise in our captured images. Meanwhile, in industrial processes uneven tiny scratches and spots can be also caused. The image filtering will solve the above problems effectively. In order to eliminate noise as well as protect the details of an image, median filter is implemented to change the values of those pixels which have biggish gray difference with the surrounding pixels and then eliminate isolated noise.In order to conquer the drawbacks of simple local median filter, different weight values are given to the pixels involved in the operation, which is weighted median filter. Normally the weight values are determined according to the following principles: (1) assign biggish weight value to the pixel to be processed and smaller values to the rest; (2) determine the weight value of the rest of the pixels according to the distance to the pixel to be processed and the closer, the bigger; (3) determine the weight value of the rest pixels according to the degree of closeness between the pixel to be taken up and the one of the rest.


## 3.2. Height Detection

The height of clamp can be calculated from three lateral images. The detection method is as follows. Firstly, detect the edges with ROI and obtain the straight edge linesL1 and L2 by using straight line fitting method at edge points. Secondly, draw a perpendicular bisector (H) in ROI and calculate the points of intersection between H and L1 and H and L2 ((X1, Y), (X2, Y)). Finally, the height can be calculated by the absolute value of X1 and X2. The site test pattern is displayed in Figure 6. As we can see, this method can calculate not only the height of the clamp, but also the height of the hollow part in the middle of the clamp, which can provide a basis for detailed height detection.The height calculation diagrams of the three lateral images.
(a)
(b)
(c)


## 3.3. Defect Detection

The first step is always location of defect, of which the theory is the same as ROI location. After locating the defects comes defect segmentation and recognition. At present, there are some segmentation methods, such as threshold method, the maximum entropy method, and histogram threshold method [3–5]. Due to the inherent characteristics of the product, defects in the images are of small proportion in the whole image. What kind of algorithm to segment defects and clamps greatly is one of the difficulties in this research.After positioning, we can see that, as in the right image in Figure7, some burrs are removed and the defect area is enlarged, which make it easier to improve the processing speed of the software. In order to get the perfect segmentation effect and improve the defects proportion in a histogram of an image to be segmented, segmentation algorithms based on threshold, region segmentation method, morphological segmentation method, and so forth have been tested in the tests. At the end, the PCNN method is adopted, and some improvement has been put forward based on the original. PCNN (pulse coupled neural network) is derived from Eckhorn et al.’s [6] research on nerve cells in the cat visual cortex. In the PCNN model, neurons with similar input generate impulses at the same time, which is able to reduce local gray level difference as well as making up local minor disconnection in an image. PCNN method is unrivalled by other segmentation methods. This property has also been used in fields such as shadow removal, image denoising, and edge extraction.Figure 7
Schematic defect location.On the basis of Eckhorn’s research, Johnson explained PCNN model with circuit theory, which is illustrated in Figure8. Parameter definition is the same as Johnson and Padgett’s [7].Figure 8
The equivalent circuit of neuron.The formula derivation from the circuit in Figure8 is listed below. In the actual derivation, the same mistakes were found in documents from Johnson and Padgett’s [7] and Yide et al’s [8]. Different part between my formulas and theirs is roughly listed below. For detailed derivation of the formulas, see the Appendix
(5)V˙=M~V+R,
where
(6)V=(V1V2)M~=(-1C1(gm1+g12+F)g12C1g12C1-1C2(gm1+g12+L))R=(1C1(gm1Em+FEs-ΔVY(t))1C2(gm2Em+EsL)),
where V1, V2 are the electrical potentials of their neuron membranes. Equation (5) indicates that pulse signal is not only related to the transfer conductance between synapses gs1, gs2, but also related to the equivalent leakage conductance, the equivalent capacitance, and the intrinsic capacitance, which indicates that whether a neuron can be fired depends on the exterior input of its neighboring neuron, as much as its own internal activity.Pulse functionY(t) will be generated when the neuron potential V1 goes larger than the threshold potential; and there are no signals to be generated when the inner activities achieve balance; that is to say, V is zero.Then the following equation can be derived from (5):
(7)V1=a+bF+cL+dFLe+fF+gL+hFL,
where
(8)a=g12gm2Em+g12gm1Em+gm1gm2Em,b=g12Es+gm2Es,c=g12Es+gm1Em,d=Es,e=g12gm2+g12gm1+gm1gm2,f=g12+gm2,g=g12+gm1,h=1.Equation (7) is actually the functional relation of the neuron membrane potentials in equilibrium. It indicates that the nonlinear multiplying modulating coupling property of PCNN is caused by the conductance between the axon of a neuron (presynaptic) and the axon of a neighboring neuron (postsynaptic). While neurons that input conductance are controlled by the pulse voltage, the characteristics of neuronal synapses with this character are transferred to the adjacent conductance neurons.Each neuron includes 3 parts: dendrite, nonlinear connection modulation, and pulse generation element. The model of a PCNN neuron is illustrated in Figure9 [7]. The dendrite is utilized to receive information from the neighboring neurons through the linear connection input channel and feedback input channel. Nonlinear connection modulation, namely, the internal activities of neurons (U), is obtained by multiplying the linear part which has an offset and the feedback input part. The generation of the pulse depends on whether the inner activities can stimulate the dynamic threshold, and the threshold value (E) will be modified with the output state of the neuron. When E is lower than U, the neuron will be stimulated (Y=1), which is called fired. Next E suddenly increases because of the feedback of the output, and thus the neuron will be suppressed immediately (Y=0). The output will yield a pulse signal which connects to the input of the neighboring neuron with weight coefficient, so as to influence the stimulus state of these neurons.Figure 9
The model of PCNN neuron.The model can be described with discrete functions as follows:(9)Fi=∑j‍(MkiYk(t)⨂Φki(t))+Ii,(10)Li=∑k‍(MkiYk(t)⨂Φki(t))+Ji,(11)Ui=Fi(1+βiLi),(12)Yi(t)=step(Ui-Θi),(13)Θi=-αTΘi+VTYi(t),
where ⨂ is convolution, Θij(t)=Aije-αijt is the temporal responses kernel of the ijth neuron, Mij and Wij are the weight coefficient matrices of the linear connection input channel and the feedback input channel, Ii and Ji are the constant inputs, Fi is the feeding input, Li is the linking input, Ui is the total internal activity, Yi is the output pulse, Θi is the neuron threshold, i,j,k represent different neurons, Aij and αij are the dendrite state parameters, αT and VT are the time constant and magnification coefficient of threshold value, VT is usually set to a larger value which is larger than Ui, and βi is the linking strength coefficient. Under this discrete mode, (9)–(13) must be calculated in sequence in the listed order; and Θi and VT use their values as evaluated at the previous time step.In the light of the inherent characteristics of the clamps, weighted median filter is adopted in image processing in the system. At the same time, PCNN algorithm is used to enhance the filtering effect before segmentation. From (11), the value of β influences the filtering effect. A low-pass filter can be used to constrain internal activities so as to reduce noise. Equation (11) can be slightly modified as follows:
(14)Ui=Fi(1+βLi)-r〈∑cells‍Yi(t)〉lowpass,r∈[0,1].By allowingr changing from 0 to 1, (14) gives a significant decrease in both the temporal and the spatial noise when it is turned on the equilibrium operation of the PCNN. The above idea with PCNN is used to realize the image segmentation on the case in this paper, in which further analysis and modification have also been done.


## 4. System Implementation

According to the design idea, we build this detection system. In the present machine vision, mostly, CCD camera is the main module to capture images. Java Advanced Imaging (JAI) company concentrates on providing customs with abundant products from line scanning to area scanning, from analog to digital technology, and from Camera Link to gigabit Ethernet (Gig E) vision. This research applied a digital camera with the type JAI CM-030GE/CB-030GE, which adopts a Sony IC424 CCD sensor with a size of 1/3′′, effective pixels656*494, the max frame rate 90fps under the max resolution and continuous acquisition mode, and a Gig E interface to communicate. The load of a Gig E camera is 656*494*1*90=28 MByte/s, while the maximum load of Gig E link is 120 MByte/s. Therefore, 4 cameras which are applied in this research meet the load requirement.For the purpose of testing the accuracy of this algorithm, one thousand clamps are detected randomly, among which 100 are unqualified and the other 900 are qualified. Four images of each clamp were captured by the image acquisition system which was triggered by an external trigger and then conveyed to the host computer for defect detection. The process time of each image is 0.087 s, which means the time to detect one clamp is 0.348 s. The results show that there are no misjudgments in one year’s debugging.A two-dimensional image with size ofN*M can be considered as a PCNN network whose number of neuron is N*M, and each pixel corresponds to a unique neuron input. In the first step, the internal activity is equal to the external stimulus. If the output of the neuron is 1, it is naturally fired. At the same time, the threshold value will increase sharply and decay exponentially with time. It is obvious that if the corresponding pixels of the neighboring neuron and the fired neuron at the last iteration are of the same intensity, the neighboring neuron is easier to be captured and fired. This shows that the natural fire of one neuron can lead to a collective fire to the similar neurons around. Image segmentation could be realized based on the property that the neuron groups formed by the naturally fired neuron and a small area in the image have similar characteristics. The above idea with PCNN is used to realize the image segmentation on the case in this paper, in which further analysis and modification have also been done.In the right image of Figure10, it is obvious that even small detailed information like the wrinkle on the inner side of the clamp in the lower right corner of the image and the trail at the overlap region in the center-left of the image are segmented clearly and completely. Without doubt, the segmentation results of the middle image in Figure 10 using the threshold segmentation method are also good except that some details are missed in this case. The reason why PCNN method can realize the ideal edge detection is that it includes two significant characteristics: firstly, the output of PCNN is binary; secondly, the output is an area with single gray level, which ensures the successful detection of the real image edges and provides basis for segmentation.The original image (a), the output image after threshold segmentation (b), and the output image after PCNN segmentation (c).
(a)
(b)
(c)Figure11 shows several segmentation images with different r in (14), where the edges are similar. The value of the middle image is 0.3. The value of the right image is 0.8. We can find that the middle image is already good enough. More interesting results could be obtained by decreasing of r. The image will be segmented further based on the former coarse segmentation with the fire in different iteration of PCNN. However, it is also found that excessive segmentation will increase the difficulty in target recognition (the middle image of Figure 11). Thus, the number of iteration determines the capacity of PCNN to recognize edges with different gray levels.The original image (a), the output image based on original PCNN segmentation (b), and the output image based on our PCNN segmentation (c).
(a)
(b)
(c)Derived from the research on the target recognition mechanism of the mammalian visual neurons, the PCNN model can extract the edge and region information only after a few iterations instead of plenty of image training processes. Figure12 shows several segmentation images with different iteration numbers, where the edges are similar. The number of Figures 12(b)~12(f) is 4, 6, 7, 9, and 10. We can find that Figure 12(d) is already good. More interesting results could be obtained by increasing the number of iteration. The image will be segmented further based on the former coarse segmentation with the fire in different iteration of PCNN. However, it is also found that excessive segmentation will increase the difficulty in target recognition (Figures 12(e), and 12(f)). Thus, the number of iteration determines the capacity of PCNN to recognize edges with different gray levels.The original image (a) and segmentation images with different iteration numbers (b–f).
(a)
(b)
(c)
(d)
(e)
(f)


## 5. Conclusions

A spring clamp detection system based on machine vision is built in this paper, which is built on both sides of the production line. This system could detect accurately under the speed 2.8 clamps per second and detect any defect over 10 pixels. The rates of defect recognition and defective removal have reached a high level, which can achieve the goals of improving the overall quality of the products manufactured and avoid actual loss. The major work of this paper is as below: (1) an automatic location algorithm ROI is designed, which can fast locate the ROI in an image; (2) the most concise geometric principle is used in height detection algorithm design, which can achieve fast measurement on the premise that the angle between camera and detecting object is90° or 0°; (3) some mistakes of the equivalent circuit in Johnson and MA Yi-des documents are corrected; (4) it helps us to improve the original PCNN algorithm and apply it in this detection. This system is the application of machine vision in online detection of the spring clamp, which is capable of automatically detecting the surface of the clamp. Of course, the detection system also needs to be optimized in a lot of aspects, for example, the distortion-free source coding problems such as how to remove unimportant information in an image during transmission in order to save cost and improve compression effect, which will be the next key point in further research.



---

*Source: 164726-2014-07-09.xml*