A kind of municipal rail train pantograph pan edge detection method
Technical field
The invention belongs to bow failure detection technique field, especially a kind of municipal rail train pantograph pan edge detection
Method.
Background technique
With the promotion of train speed and the increase of operation mileage, the security performance of train is more and more important.Pantograph one
As be mounted at the top of train, in the process of running with contact line sliding contact, electric energy is obtained from contact net, is that train is being run
The important component of firm energy is obtained in the process.Carbon slipper is the key component that train pantograph system obtains electric energy, in train
During operation, for carbon slipper vulnerable to abrasion, abrasion are once more than that warning value will cause serious traffic accident.
John F.Canny proposes Canny edge detection operator, and this method belongs to multistage edge detection algorithm, by seeking
Optimal detection, oplimal Location and unique response is looked for obtain the edge of image.But Canny edge detection has the drawback that (1)
During first step gaussian filtering, marginal information is also weakened while filtering out picture noise, it is unconspicuous to miss some features
Edge;(2) it is calculated in amplitude and gradient procedure in second step, gradient and amplitude, this method pair is calculated using 2 × 2 fields
Noise is very sensitive, easily detects pseudo-edge;(3) the 4th step be arranged dual threshold during, the selection of dual threshold to edge most
Determination has a significant impact eventually, is difficult to select an optimal value.After threshold value is arranged in artificial experience method, cannot adaptively it be schemed according to every
Piece information selected threshold again.
Summary of the invention
The purpose of the present invention is to provide the good municipal rail train pantograph pan edge detections of a kind of accuracy height, real-time
Method eliminates safe hidden trouble to adopt an effective measure in time.
Realizing the technical solution of the object of the invention is: a kind of municipal rail train pantograph pan edge detection method, base
In improved Canny operator, specifically includes the following steps:
Step 1, pantograph pan gray image signals are obtained, the Gaussian convolution core of picture signal and adaptive size is used
Convolution algorithm is carried out, filtered image is obtained;
Step 2, gradient magnitude and the direction by filtered image are calculated with gradient operator in 8 neighborhoods of 3*3;
Step 3, non-maxima suppression is carried out to gradient magnitude, using the extracted in self-adaptive of dual threshold, carries out edge connection,
Obtain pantograph pan edge image.
Further, acquisition pantograph pan gray image signals described in step 1, use picture signal and adaptive ruler
Very little Gaussian convolution core carries out convolution algorithm, specific as follows:
Gray image signals, and the Gauss with adaptive size are converted by the pantograph pan colour picture signal of acquisition
Convolution kernel carries out convolution algorithm, sets the size of the Gaussian convolution core of adaptive size as m*n, image pixel is ω * h, then certainly
The calculation formula for adapting to the Gaussian convolution core of size is as follows:
Further, the ladder by filtered image is calculated with gradient operator in 8 neighborhoods of 3*3 described in step 2
Amplitude and direction are spent, specific as follows:
The Directional partial derivative and difference formula of 8 neighborhoods of 3*3 are as follows:
Wherein, G (i, j) is the gray value of image of (i, j) point on image, Px(i, j) is the partial derivative in the direction x, Py(i,j)
For the partial derivative in the direction y, P45(i, j) is the partial derivative in 45 ° of directions, P135(i, j) is the partial derivative in 135 ° of directions, fx(i, j) is
Use the image gradient in the direction x that calculus of differences obtains, fy(i, j) is the image gradient in the direction y obtained using calculus of differences;
Then gradient formula are as follows:
Wherein, M (i, j), θ (i, j) are respectively the gradient magnitude and gradient direction of (i, j) point.
Further, non-maxima suppression is carried out to gradient magnitude described in step 3, using adaptively mentioning for dual threshold
It takes, carries out edge connection, obtain pantograph pan edge image, specific as follows:
Step 3.1, the adjacent greatest gradient value for obtaining the point along the gradient direction of point (i, j) using linear interpolation, if
The gradient value is greater than the gradient value of point (i, j), then the gray value of point (i, j) is set to 0;Conversely, the then gray scale of retention point (i, j)
Value;
Step 3.2 defines mean μ in classiAnd variance
Wherein, if the sum that gray value is the pixel of j is nj, pjThe ratio of entire image sum of all pixels is accounted for for it;I is root
According to the subscript for the different gray value intervals that entire image is divided, the gray value interval sum divided is equal to according to whole pictures
The classification number that vegetarian refreshments gradient magnitude divides;
Image after step 3.3, non-maxima suppression, gradient magnitude are divided into 3 classes: C0For non-edge point pixel, gradient width
Being worth range is [0,1 ..., k];C1For marginal point pixel, gradient magnitude range is [k+1, k+2 ..., m];C2For doubtful marginal point
Pixel, gradient magnitude range are [m+1, m+2 ..., l-1];
Define the evaluation function J that high-low threshold value and gradient amplitude histogram are adaptively determined based on minimum interclass variance
(k, m) are as follows:
Formula (7) are substituted into formula (8) and are derived by:
Wherein, gained solution k, m are pixel gradient magnitude threshold value;Image border is carried out with m using k to connect, and can be obtained
To pantograph pan edge image.
Compared with prior art, the present invention its remarkable advantage is: (1) improved Canny operator is based on, using adaptive height
When this accounting method carries out noise reduction filtering, the actual size in target detection is preferably obtained;(2) contiguous range is expanded to 3*
38 neighborhoods, so that detection is more accurate;(3) minimum interclass variance and gradient amplitude histogram are used, edge extracting is improved
Detection accuracy, testing result is obvious, and method applicability is strong.
Detailed description of the invention
Fig. 1 is the flow diagram of municipal rail train pantograph pan edge detection method of the present invention.
Fig. 2 is pantograph left-half image in the embodiment of the present invention.
Fig. 3 is that pantograph left-half is schemed through the processing of traditional Canny operator in the embodiment of the present invention.
Fig. 4 is the improved Canny operator processing figure of pantograph left-half in the embodiment of the present invention.
Specific embodiment
The present invention is described in further detail with reference to the accompanying drawing.
In conjunction with Fig. 1, municipal rail train pantograph pan edge detection method of the present invention, first acquisition pantograph pan grayscale image
As signal, convolution algorithm is carried out using the Gaussian convolution core of picture signal and adaptive size;Then it is used in 8 neighborhoods of 3*3
Gradient operator calculates gradient magnitude and direction by filtered image;Non-maxima suppression finally is carried out to gradient magnitude,
Using the extracted in self-adaptive of dual threshold, edge connection is carried out, pantograph pan edge image is obtained, comprising the following steps:
Step 1, pantograph pan gray image signals are obtained, the Gaussian convolution core of picture signal and adaptive size is used
Convolution algorithm is carried out, specific as follows:
Gray image signals, and the Gauss with adaptive size are converted by the pantograph pan colour picture signal of acquisition
Convolution kernel carries out convolution algorithm, sets the size of the Gaussian convolution core of adaptive size as m*n, image pixel is ω * h, then certainly
The calculation formula for adapting to the Gaussian convolution core of size is as follows:
Step 2, gradient magnitude and direction by filtered image, tool are calculated with gradient operator in 8 neighborhoods of 3*3
Body is as follows are as follows:
The Directional partial derivative and difference formula of 8 neighborhoods of 3*3 are as follows:
Wherein, G (i, j) is the gray value of image of (i, j) point on image, Px(i, j) is the partial derivative in the direction x, Py(i,j)
For the partial derivative in the direction y, P45(i, j) is the partial derivative in 45 ° of directions, P135(i, j) is the partial derivative in 135 ° of directions, fx(i, j) is
Use the image gradient in the direction x that calculus of differences obtains, fy(i, j) is the image gradient in the direction y obtained using calculus of differences;
Then gradient formula are as follows:
Wherein, M (i, j), θ (i, j) are respectively the gradient magnitude and gradient direction of (i, j) point.
Step 3, non-maxima suppression is carried out to gradient magnitude, using the extracted in self-adaptive of dual threshold, carries out edge connection,
Pantograph pan edge image is obtained, specific as follows:
Step 3.1, the adjacent greatest gradient value for obtaining the point along the gradient direction of point (i, j) using linear interpolation, if
The gradient value is greater than the gradient value of point (i, j), then the gray value of point (i, j) is set to 0;Conversely, the then gray scale of retention point (i, j)
Value;
Step 3.2 defines mean μ in classiAnd variance
Wherein, if the sum that gray value is the pixel of j is nj, pjThe ratio of entire image sum of all pixels is accounted for for it;I is root
According to the subscript for the different gray value intervals that entire image is divided, the gray value interval sum divided is equal to according to whole pictures
The classification number that vegetarian refreshments gradient magnitude divides;
Image after step 3.3, non-maxima suppression, gradient magnitude are divided into 3 classes: C0For non-edge point pixel, gradient width
Being worth range is [0,1 ..., k];C1For marginal point pixel, gradient magnitude range is [k+1, k+2 ..., m];C2For doubtful marginal point
Pixel, gradient magnitude range are [m+1, m+2 ..., l-1];
Define the evaluation function J that high-low threshold value and gradient amplitude histogram are adaptively determined based on minimum interclass variance
(k, m) are as follows:
Formula (7) are substituted into formula (8) and are derived by:
Wherein, gained solution k, m are pixel gradient magnitude threshold value;Image border is carried out with m using k to connect, and can be obtained
To pantograph pan edge image.
Embodiment 1
Using municipal rail train pantograph pan edge detection method of the present invention, improved edge detection operator is tested
Analysis, Fig. 2 be image capturing system acquisition pantograph left-half image, respectively with tradition Canny operator, adaptively
Canny operator carries out edge detection process, result figure such as Fig. 3, Fig. 4.
It is preferable to the filtration result of noise when using improved Canny operator extraction image border in conjunction with Fig. 3, Fig. 4,
Pseudo-edge in improved edge detection graph is less, and image is apparent, conducive to carrying out image border connection and improving system
Detection accuracy.