Distribution line insulator defect detection method and system based on LBP algorithm improved by gradient direction
By combining the improved LBP algorithm and the KNN model, the problem of the accuracy of insulator defect detection and low recognition rate of multiple types of defects in the prior art is solved, and efficient detection in complex environments is achieved.
Patent Information
- Application Number
- CN202411723975.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-28
- Publication Date
- 2025-08-19
- Estimated Expiration
- 2044-11-28
AI Technical Summary
When detecting insulator defects in the distribution line, the prior art has problems such as difficulty in collecting defect images, few detections of multiple defect types, low recognition accuracy in complex environments, and insufficient detection accuracy of lightweight models.
The LBP algorithm based on the improvement of gradient direction is adopted, by sorting the central pixel points and neighboring pixel points, the encoding starting position is determined using the gradient maximum value, and classified detection is performed in combination with the KNN model to extract the insulator texture features.
It improves the accuracy and recognition rate of insulator defect detection, especially the ability to identify multiple defect types in complex environments.
Smart Images

Figure CN119649119B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image processing, and in particular to a method and system for detecting defects in insulators of distribution lines based on a gradient-direction-improved LBP algorithm. Background Art
[0002] Insulators in power transmission line systems are prone to breakage and flashover due to prolonged exposure to harsh natural environments. These problems can lead to regional power outages and catastrophic accidents. Regular insulator inspection is crucial for the proper operation of power systems. Manual insulator inspections are time-consuming and intensive, subject to environmental influences, lack flexibility, and pose risks. With the development of smart grids, intelligent devices such as drones and inspection robots can effectively replace manual inspections. These devices use cameras to capture images and visual algorithms to detect defective components, making them efficient and flexible, and have been widely researched and implemented.
[0003] In recent years, various methods have been introduced to detect component defects, such as traditional image processing and deep learning algorithms. Traditional image processing typically involves two steps: identifying the target component and detecting defects using mathematical models. This method can accurately detect component defects, but requires the establishment of corresponding feature extraction algorithms and defect discrimination models for each type of defect, making it less practical. Since the rise of deep learning, image semantic segmentation technology has been applied by many scholars to various fields. This technology performs pixel-level classification and greatly improves the accuracy of defect detection. Compared with traditional image processing methods and deep learning algorithms, one of the main advantages of deep learning is that it does not require manually designed feature extraction, making it effective for detection tasks with different target features and complex image backgrounds, while also having better robustness and stronger model generalization capabilities.
[0004] Although deep learning has made progress in detecting defective components, several challenges remain. First, due to the relatively small number of defective insulator components on transmission lines, defect images are scarce and difficult to acquire. Second, because most studies focus on only one type of insulator defect, there are few methods for detecting and identifying multiple defect types. Finally, transmission lines are located in complex environments, such as foggy days; the size of defective components appearing in images is small compared to the complex background, especially insulator flashover defects, which reduces the accuracy of defect identification. Furthermore, current deep learning algorithms have low detection accuracy for lightweight models, making them difficult to meet engineering requirements. While models with larger parameters have some detection accuracy, they are too large to be easily deployed in practice. Summary of the Invention
[0005] In response to the defects of the existing technology, the embodiments of the present invention provide a distribution line insulator defect detection method and system based on the LBP algorithm improved by gradient direction, which can more accurately extract the texture features of the insulator image and improve the accuracy of insulator defect detection.
[0006] The present invention is achieved through the following technical solutions:
[0007] In a first aspect, an embodiment of the present invention provides a method for detecting defects in distribution line insulators based on a gradient-directed improved LBP algorithm, comprising the following steps:
[0008] Acquire an image of the insulator to be inspected;
[0009] Preprocessing the acquired image of the insulator to be inspected to obtain a preprocessed image;
[0010] Obtain all pixels from the preprocessed image, use the improved LBP algorithm to extract LBP features from the preprocessed image, perform statistics on the LBP features of all pixels, and complete feature vectorization;
[0011] The LBP feature vector is input into the trained KNN model for classification detection to obtain the insulator defect detection results.
[0012] In a second aspect, an embodiment of the present invention provides a distribution line insulator defect detection system based on a gradient-directed improved LBP algorithm, comprising: an image acquisition module, a preprocessing module, a feature extraction module, and a classification detection module, wherein the image acquisition module is used to acquire an image of an insulator to be detected;
[0013] The preprocessing module is used to preprocess the acquired image of the insulator to be inspected to obtain a preprocessed image;
[0014] The feature extraction module is used to obtain all pixels from the preprocessed image, extract LBP features from the preprocessed image using an improved LBP algorithm, perform statistics on the LBP features of all pixels, and complete feature vectorization;
[0015] The classification detection module is used to input the LBP feature vector into the trained KNN model for classification detection to obtain the insulator defect detection result.
[0016] In a third aspect, an embodiment of the present invention provides an intelligent terminal, comprising a processor, an input device, an output device and a memory, wherein the processor is connected to the input device, the output device and the memory respectively, the memory is used to store a computer program, the computer program includes program instructions, and the processor is configured to call the program instructions to execute the method described in the above embodiment.
[0017] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, wherein the computer program includes program instructions, and when the program instructions are executed by a processor, the processor executes the method described in the above embodiment.
[0018] Compared with the prior art, the present invention has the following advantages and beneficial effects:
[0019] The present invention provides a method, system, terminal, and medium for detecting defects in distribution line insulators based on a gradient-directed LBP algorithm. This improves upon the traditional LBP algorithm by first sorting the center pixel value and the values of eight pixels in the surrounding area, replacing the original center pixel value with the intermediate value to address situations where the center pixel may not be the actual pixel. Secondly, since the gradient magnitude often represents the rate of change of an image, the maximum gradient value is used to determine the encoding starting position, allowing for more accurate extraction of features such as insulator texture. A KNN model is then used to classify, detect, and identify texture features, improving the accuracy of identifying different types of insulator defects. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] In order to more clearly illustrate the technical solutions of the exemplary embodiments of the present invention, the following briefly introduces the drawings required for use in the examples. It should be understood that the following drawings only illustrate certain embodiments of the present invention and should not be considered as limiting the scope. A person of ordinary skill in the art can also derive other relevant drawings based on these drawings without inventive effort. In the drawings:
[0021] Figure 1 A flowchart of a method for detecting defects in insulators of distribution lines based on a gradient-direction-improved LBP algorithm provided by the first embodiment of the present invention;
[0022] Figure 2 Flowchart of the improved LBP algorithm in the first embodiment of the present invention;
[0023] Figure 3 is the original pixel block image;
[0024] Figure 4 is the new pixel block image;
[0025] Figure 5 is the image of the insulator to be inspected;
[0026] Figure 6 This is an image of insulator texture features extracted using the traditional LBP algorithm;
[0027] Figure 7 To extract the texture features of insulator using the improved LBP algorithm;
[0028] Figure 8 This is a comparison chart of recognition accuracy;
[0029] Figure 9 A structural block diagram of a distribution line insulator defect detection system based on a gradient-direction-improved LBP algorithm provided by another embodiment of the present invention;
[0030] Figure 10 This is a structural block diagram of an intelligent terminal provided by another embodiment of the present invention. DETAILED DESCRIPTION
[0031] In order to make the objectives, technical solutions and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with examples and drawings. The exemplary embodiments of the present invention and their descriptions are only used to explain the present invention and are not intended to limit the present invention.
[0032] Example 1
[0033] like Figure 1 FIG. 1 is a flowchart of a method for detecting defects in insulators of a distribution line based on a gradient-directed improved LBP algorithm according to a first embodiment of the present invention. The method comprises the following steps:
[0034] Acquire an image of the insulator to be inspected;
[0035] Preprocessing the acquired image of the insulator to be inspected to obtain a preprocessed image;
[0036] Obtain all pixels from the preprocessed image, use the improved LBP algorithm to extract LBP features from the preprocessed image, perform statistics on the LBP features of all pixels, and complete feature vectorization;
[0037] The LBP feature vector is input into the trained KNN model for classification detection to obtain the insulator defect detection results.
[0038] The improved LBP algorithm is based on the traditional algorithm. Since the traditional LBP algorithm only considers the size relationship between the center pixel and the area pixel, it does not consider the intrinsic relationship between the center pixel and the area pixel, and ignores the direction information of the sampling point. Based on this deficiency, the embodiment of the present invention improves the traditional LBP algorithm, such as Figure 2As shown in the figure, the preprocessed image is first divided into several small blocks, and LBP feature extraction is performed on each block. During feature extraction, the initial center pixel of the pixel block is determined, and the initial center pixel value and the values of the neighboring pixels in a cross shape are calculated. The center pixel value and the values of the neighboring pixels in the cross shape are sorted, and the median is determined. The median replaces the original center pixel value and serves as the new center pixel value. The median is averaged with the initial center pixel value to determine the center threshold. The eight pixels in the cross shape of the neighboring pixels are compared with the center threshold. Values greater than or equal to the threshold are encoded as 1, and values less than the threshold are encoded as 0. Next, the magnitude of each gradient direction in the new pixel block is calculated, and the maximum gradient direction is selected as the encoding starting position. This fully considers the directional characteristics of the pixel block, and completes LBP encoding and binary conversion. The initial center pixel value and the values of the eight neighboring pixels are sorted, and the median replaces the original center pixel value. This can resolve situations where the center pixel value may not be the true pixel. Secondly, the gradient size often represents the rate of change of the image. Using the maximum gradient value to determine the encoding starting position can more accurately extract features such as insulator texture.
[0039] The improved LBP calculation method is as follows:
[0040] The new center pixel value g'(x c ,y c ) is calculated as follows:
[0041]
[0042] Where x c -x-coordinate value of the center pixel, y-coordinate value c -Y coordinate value of the center pixel, f(x c ,y c ) represents the center pixel value in the 3*3 neighborhood of the original image, g(x c ,y c ) represents the center point threshold.
[0043] Figure 3 In the example, 5 data are compared and the middle value is assigned to g'(x c ,y c ),go through The new center pixel value is obtained by calculating . The new pixel block is represented by g(x,y). Compared with the original pixel block, only the center pixel value of the new pixel block changes. Figure 4 is a new pixel block, and its gradient size is calculated as follows:
[0044]
[0045]
[0046] The base conversion calculation formula is as follows:
[0047]
[0048] in: When M(x,y) is maximum, p=8.
[0049] In this embodiment, supervised learning methods are used to implement classification. A training dataset is used to train the model, and a validation dataset is used to validate the model. A sample belongs to the training sample category if it is closest to the most common training sample among its k nearest neighbors in the feature space. Regarding the k value, an initial value is given, and then the sample data is divided into a training dataset and a validation dataset according to a certain ratio. A small k value is initially selected, and then the k value is continuously increased. The classification error rate in the validation dataset is calculated. The parameter k of the KNN model is adjusted based on the model evaluation results. Typically, as the k value increases, the classification error rate initially decreases, then increases. The k value that minimizes the classification error rate is thus selected.
[0050] The specific method of model training is as follows:
[0051] Input: training data sample set, T = {y1,y2,…,y N )}, the classification label is
[0052] Output: The class to which the test sample x belongs.
[0053] Steps: 1) Calculate the distance from the sample to be tested x to each sample in T according to the given distance metric.
[0054]
[0055] 2) According to the distance D p The values arrange y from large to small:
[0056] y1 <y2<……<y n。
[0057] 3) Select the first k training samples with the smallest distance to the test sample x: y1, y2..., y k。
[0058] 4) The formula for determining the category of the sample x to be tested according to the decision rule is as follows:
[0059]
[0060] Among them, q represents the class label, S() is the indicator function,
[0061] Model Evaluation:
[0062] Use appropriate evaluation metrics to evaluate model performance. For classification problems, commonly used evaluation metrics include accuracy, precision, recall, F1 score, and confusion matrix. In this example, accuracy is used as the evaluation metric.
[0063] The calculation formula of accuracy ACC is:
[0064]
[0065] Where TP is the number of true positive examples, TN is the number of true negative examples, FP is the number of false positive examples, and FN is the number of false negative examples.
[0066] Model optimization:
[0067] Based on the evaluation results, return and adjust the parameter k value of the K-NN model to obtain better performance.
[0068] Analyze the classification results to determine the model's ability to identify insulator defects. In order to better illustrate the detection effect of the distribution line insulator defect detection method based on the gradient direction improved LBP algorithm in the embodiment of the present invention, the defective insulator image is detected. Figure 5 To obtain the image of the insulator to be inspected, Figure 6 For images that extract features using the traditional LBP algorithm, Figure 7 An image with features extracted using the improved LBP algorithm provided in an embodiment of the present invention, Figure 8 The figure shows a comparison of the recognition accuracy of the traditional LBP algorithm and the improved LBP algorithm. The comparison results show that the detection method provided by the embodiment of the present invention has a higher accuracy rate in detecting different defects of distribution line insulators than the existing technology.
[0069] An embodiment of the present invention provides a method for detecting defects in distribution line insulators based on an LBP algorithm with an improved gradient orientation. This improves the traditional LBP algorithm by first sorting the center pixel value and the eight pixel values in the area, and replacing the original center pixel value with the intermediate value to address the situation where the center pixel may not be a true pixel. Secondly, the gradient magnitude often represents the rate of change of the image. Therefore, the maximum gradient value is used to determine the encoding starting position, allowing for more accurate extraction of features such as insulator texture. Combining the improved LBP algorithm with the KNN nearest neighbor method improves the accuracy of identifying different types of insulator defects.
[0070] Example 2
[0071] like Figure 9As shown, a structural block diagram of a distribution line insulator defect detection system based on a gradient-direction improved LBP algorithm provided by another embodiment of the present invention is shown. The system includes: an image acquisition module, a preprocessing module, a feature extraction module, and a classification detection module. The image acquisition module is used to acquire an insulator image to be detected; the preprocessing module is used to preprocess the acquired insulator image to be detected to obtain a preprocessed image; the feature extraction module is used to acquire all pixel points from the preprocessed image, extract LBP features from the preprocessed image using the improved LBP algorithm, perform statistics on the LBP features of all pixel points, and complete feature vectorization; the classification detection module is used to input the LBP feature vector into a trained KNN model for classification detection to obtain an insulator defect detection result.
[0072] The feature extraction module includes an improved LBP unit, which is used to calculate the initial center pixel value and the neighborhood "cross" direction pixel value, sort the initial center pixel value and the neighborhood "cross" direction pixel value, determine the median, use the median to replace the original center point pixel value as the new center pixel value, use the median and the initial center pixel value to average to obtain the center point threshold, compare the 8 pixels in the neighborhood "cross" direction with the center point threshold, encode those greater than or equal to the threshold as 1, and encode those less than the threshold as 0, calculate the size of each gradient direction in the new pixel block, obtain the maximum gradient value direction, take the maximum gradient value direction as the encoding starting position, and complete LBP encoding and binary conversion.
[0073] The system also includes a model training module, which uses a training data set to train a KNN model. The preprocessing module includes a grayscale processing unit, which is used to perform grayscale conversion on the image of the insulator to be detected.
[0074] An embodiment of the present invention provides a distribution line insulator defect detection system based on a gradient-directed LBP algorithm. This improves upon the traditional LBP algorithm by first sorting the center pixel value and the eight pixel values within the domain, and replacing the original center pixel value with the intermediate value to address situations where the center pixel may not be the actual pixel. Secondly, the gradient magnitude often represents the rate of change of the image. Therefore, the maximum gradient value is used to determine the encoding starting position, allowing for more accurate extraction of features such as insulator texture. A KNN model is used to classify, detect, and identify texture features, improving the accuracy of identifying different types of insulator defects.
[0075] Example 3
[0076] like Figure 10As shown, a structural block diagram of an intelligent terminal according to another embodiment of the present invention is shown, the terminal includes a processor, an input device, an output device and a memory, the processor is connected to the input device, the output device and the memory respectively, the memory is used to store a computer program, the computer program includes program instructions, and the processor is configured to call the program instructions to execute the method described in the above embodiment.
[0077] It should be understood that in the embodiments of the present invention, the processor referred to may be a central processing unit (CPU), and the processor may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor, etc.
[0078] Input devices may include a touchpad, a fingerprint sensor (for collecting the user's fingerprint information and fingerprint direction information), a microphone, etc. Output devices may include a display (LCD, etc.), a speaker, etc.
[0079] The memory may include read-only memory and random access memory, and provides instructions and data to the processor. A portion of the memory may also include non-volatile random access memory. For example, the memory may also store information about the device type.
[0080] In specific implementations, the processor, input device, and output device described in the embodiments of the present invention can execute the implementation methods described in the method embodiments provided by the embodiments of the present invention, and can also execute the implementation methods of the system embodiments described in the embodiments of the present invention, which will not be repeated here.
[0081] Example 4
[0082] In another embodiment of the present invention, an embodiment of a computer-readable storage medium is provided. The computer-readable storage medium stores a computer program. The computer program includes program instructions. When the program instructions are executed by a processor, the processor executes the method described in the above embodiment.
[0083] The computer-readable storage medium may be the internal storage unit of the terminal described in the aforementioned embodiment, such as the hard disk or memory of the terminal. The computer-readable storage medium may also be an external storage device of the terminal, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped on the terminal. Furthermore, the computer-readable storage medium may also include both the internal storage unit of the terminal and an external storage device. The computer-readable storage medium is used to store the computer program and other programs and data required by the terminal. The computer-readable storage medium may also be used to temporarily store data that has been output or is to be output.
[0084] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the above description has generally described the composition and steps of each example according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0085] Those skilled in the art will clearly understand that, for the convenience and brevity of description, the specific working processes of the terminals and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0086] In the several embodiments provided in this application, it should be understood that the disclosed terminals and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of the units is merely a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, or can be electrical, mechanical or other forms of connection.
[0087] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the above embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the above embodiments, or make equivalent replacements for some or all of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the scope of the technical solutions of the embodiments of the present invention, and they should all be included in the scope of the claims and description of the present invention.
Claims
1. A method for detecting defects in insulators of distribution lines based on the LBP algorithm with improved gradient direction, characterized in that: The following steps are involved: Acquire an image of the insulator to be inspected; Preprocessing the acquired image of the insulator to be inspected to obtain a preprocessed image; Obtain all pixels from the preprocessed image, use the improved LBP algorithm to extract LBP features from the preprocessed image, perform statistics on the LBP features of all pixels, and complete feature vectorization; The LBP feature vector is input into the trained KNN model for classification detection to obtain the insulator defect detection results; The improved LBP method specifically includes: Calculate the initial center pixel value and the neighborhood "cross" direction pixel value; Sort the initial center pixel value and the neighborhood "cross" direction pixel values, determine the median, and use the median to replace the original center point pixel value as the new center pixel value; The center point threshold is obtained by averaging the median value and the initial center pixel value; Compare the eight pixels in the cross-shaped direction of the neighborhood with the center point threshold. If the pixels are greater than or equal to the threshold, the code is 1, and if the pixels are less than the threshold, the code is 0. Calculate the magnitude of each gradient direction in the new pixel block and obtain the direction of the maximum gradient value; The maximum value in the gradient direction is taken as the encoding starting position to complete LBP encoding and binary conversion.
2. The method according to claim 1, characterized in that Before the LBP feature vector is input into the trained KNN model for classification prediction, the KNN model is trained using the training data set, specifically including: Input training data set T = {(x1,y1),(x2,y2),…,(x N, y N )}, where there are N samples in total and the classification labels are j=1,2,…M; output the class to which the sample to be tested x belongs, and calculate the distance D from the sample to be tested x to each sample in T according to the set distance metric p ; According to the distance D p The values arrange y from large to small: y1 <y2<……<y n ; Select the first k training samples with the smallest distance to the test sample x: y1, y2..., y k ; The formula for determining the category of the sample x to be tested according to the decision rule is as follows: Among them, q represents the class label, S() is the indicator function, 3. The method according to claim 1, characterized in that The specific method of preprocessing the acquired insulator image to be inspected includes: converting the acquired insulator image into a grayscale image.
4. A distribution line insulator defect detection system based on the LBP algorithm improved by gradient direction, characterized in that: include: An image acquisition module, a preprocessing module, a feature extraction module and a classification detection module, wherein the image acquisition module is used to acquire an image of the insulator to be detected; The preprocessing module is used to preprocess the acquired image of the insulator to be inspected to obtain a preprocessed image; The feature extraction module is used to obtain all pixels from the preprocessed image, extract LBP features from the preprocessed image using an improved LBP algorithm, perform statistics on the LBP features of all pixels, and complete feature vectorization; The classification detection module is used to input the LBP feature vector into the trained KNN model for classification detection to obtain the insulator defect detection result; The feature extraction module includes an improved LBP unit, which is used to calculate the initial center pixel value and the neighborhood "cross" direction pixel value, sort the initial center pixel value and the neighborhood "cross" direction pixel value, determine the median, use the median to replace the original center point pixel value as the new center pixel value, use the median and the initial center pixel value to average to obtain the center point threshold, compare 8 pixels in the neighborhood "cross" direction with the center point threshold, encode those greater than or equal to the threshold as 1, and encode those less than the threshold as 0, calculate the size of each gradient direction in the new pixel block, obtain the maximum gradient value direction, take the maximum gradient value direction as the encoding starting position, and complete LBP encoding and binary conversion.
5. The system according to claim 4, characterized in that The system also includes a model training module, which uses a training data set to train a KNN model.
6. The system according to claim 4, characterized in that The pre-processing module includes a grayscale processing unit, and the grayscale processing unit is used to perform grayscale conversion on the image of the insulator to be detected.
7. An intelligent terminal comprising a processor, an input device, an output device, and a memory, wherein the processor is connected to the input device, the output device, and the memory respectively, and the memory is used to store a computer program, wherein the computer program comprises program instructions, and wherein: The processor is configured to call the program instructions and execute the method according to any one of claims 1 to 3.
8. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, wherein the computer program includes program instructions, and when the program instructions are executed by a processor, the processor is caused to perform the method according to any one of claims 1 to 3.
Citation Information
Patent Citations
Fungal keratitis image identification method based on AMBP improved algorithm
CN105809188A
Photovoltaic cell panel defect detection method and device based on improved LBP algorithm
CN117474846A