A method for identifying pests using insect-killing lamps based on image processing
By using image processing technology on the insecticidal lamp, vertical texture and connected domain analysis are obtained to accurately distinguish pest areas and leaf areas, solving the problem of misjudgment of pest areas in traditional methods, and achieving pest coverage in high-voltage power grid surface images. Accurately calculate and clean operations.
Patent Information
- Application Number
- CN202410774352.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-17
- Publication Date
- 2024-08-27
- Estimated Expiration
- 2044-06-17
AI Technical Summary
It is difficult for traditional insecticidal lamps to accurately distinguish pest areas and leaf areas in high-voltage power grid surface images, resulting in inaccurate calculation of pest coverage and affecting cleaning efficiency.
By obtaining the vertical texture in the high-voltage power grid surface image, connected domain analysis and gray balance, calculate the probability that each connected area belongs to the pest area, distinguish the pest area from the leaf area, and remotely control the insect cleaning device to clean according to the area of the pest area .
It improves the calculation accuracy of pest coverage in high-voltage power grid surface images, ensures effective cleaning operations of pest cleaning devices, and improves the pest killing efficiency of insecticidal lamps.
Smart Images

Figure CN118365966B
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image processing, and more specifically, to a method for identifying pests using an insecticidal lamp based on image processing. Background Art
[0002] The harm of pests to crops is commonly known as insect pests, which is a major hidden danger in agricultural production. Traditional methods of pest control mainly rely on manual observation and pesticide spraying, which is not only time-consuming and inefficient, but also leads to problems such as increased pest resistance and pesticide residues on the surface of crops, which have adverse effects on people's health. With the popularization of insecticidal lamps, it is not only efficient and labor-saving, but also greatly avoids the problems of increased pest resistance and pesticide residues on the surface of crops. The pests killed by the high-voltage power grid of the insecticidal lamp may stick to the high-voltage power grid. Long-term work may cause more and more killed pests to stick to the high-voltage power grid, thereby reducing the insecticidal efficiency of the insecticidal lamp. Since the planting range of crops is generally large, and considering the living habits of pests, insecticidal lamps are generally installed at higher places. Limited by their high position, it is difficult to clean the high-voltage power grid of the insecticidal lamp in time by manual labor, which is easy to have an adverse effect on crop pest control. Therefore, a device for automatically cleaning the surface of the high-voltage power grid is used as shown in the Chinese patent document with the authorization announcement number CN111685091B.
[0003] The patent application document with the publication number CN110120042A currently discloses a method for extracting pest and disease areas from crop images based on SLIC superpixels and automatic threshold segmentation. By utilizing the principle that the texture of normal areas and pest and disease areas in the image is quite different, an automatic threshold iteration is set to separate the pest and disease areas from the normal areas, and the method has high extraction accuracy and efficiency.
[0004] When setting the threshold value to segment the pest area according to the above method, and then obtaining the pest coverage degree of the high-voltage power grid surface image and clearing the pests, the pest area is easily misjudged as the crop area (leaf area) due to the dense distribution of the high-voltage power grid of the insecticidal lamp and the influence of the insecticidal lamp as a light source, resulting in inaccurate segmented pest area, thereby affecting the accuracy of the calculation of the pest coverage degree of the high-voltage power grid surface image. Summary of the invention
[0005] In order to distinguish between the pest area and the leaf area, so that the value of the pest coverage degree of the high-voltage power grid surface image is more accurate, the present invention proposes a method for identifying pests with an insecticidal lamp based on image processing, the method comprising the following steps:
[0006] Collect high-voltage power grid surface images;
[0007] Each pixel point in the first row of the high-voltage power grid surface image is recorded as a target pixel point; a number of vertical textures of each target pixel point are obtained; and the probability that each vertical texture of each target pixel point does not belong to a metal wire is obtained. ,in, Represents the length of the mth vertical texture of the i-th target pixel; The main vertical texture length representing the metal wire; based on the probability that each vertical texture of each target pixel does not belong to the metal wire, obtaining the pixel point to be analyzed, wherein the pixel point to be analyzed is a pixel point of the leaf area or the pest area;
[0008] Perform connected domain analysis on the pixels to be analyzed to obtain each connected area; obtain the probability that each connected area belongs to the pest area ,in, Represents the edge sharpness of the jth connected region; Represents the gray balance degree of the jth connected region; Represents the number of pixels in the jth connected region; represents the probability that the vertical texture where the s-th pixel point in the j-th connected area is located does not belong to the metal wire; based on the probability of belonging to the pest area, the pest area is obtained;
[0009] Based on the area of the pest area, the pest coverage degree of the high-voltage power grid surface image is obtained; based on the pest coverage degree, the pest cleaning device is remotely controlled to clean the high-voltage power grid surface.
[0010] The innovation of the present invention lies in obtaining the probability that each connected area belongs to the pest area, and then obtaining the pest area. Finally, according to the area of the pest area, the pest coverage of the original image is obtained, and then the insect cleaning device is remotely controlled to clean the surface of the high-voltage power grid. The connected area represents the leaf area or the pest area. According to the probability that each connected area belongs to the pest area, the pest area can be distinguished from the leaf area, so as to avoid misjudging the pest area as the leaf area, thereby affecting the accuracy of the calculation of the pest coverage of the surface image of the high-voltage power grid. Furthermore, the connected area is obtained by performing a connected domain analysis on the pixel points to be analyzed. The acquisition of the pixel points to be analyzed is based on the characteristics that the grayscale value difference of the metal wire of the high-voltage power grid in the vertical direction of the image is small and the texture is formed to form a long, and each vertical texture of each target pixel point is obtained. Through the characteristics of the metal wire texture, the leaf area texture and the pest area texture, the probability that each vertical texture of each target pixel point does not belong to the metal wire is obtained, and then the pixel points to be analyzed are obtained, so as to distinguish the leaf area and the pest area only based on the pixel points to be analyzed.
[0011] Preferably, the step of obtaining a plurality of vertical textures of each target pixel point includes:
[0012] The vertical downward direction of the pixel point at the upper left corner of the high-voltage power grid surface image is recorded as the longitudinal axis direction;
[0013] Taking each target pixel as a starting point, traverse all pixel points along the longitudinal axis direction to obtain all vertical textures of each target pixel point; the average of the absolute values of the grayscale differences between all adjacent pixel points in each vertical texture is greater than a preset grayscale threshold, and the vertical textures are connected end to end.
[0014] Preferably, the main vertical texture length of the metal wire is obtained by:
[0015] The number of pixels in each vertical texture of each target pixel is recorded as the length of each vertical texture of each target pixel, and the vertical texture corresponding to the maximum length is recorded as the main vertical texture of each target pixel; the average length of the main vertical texture of all target pixels is recorded as the main vertical texture length of the metal wire.
[0016] Preferably, obtaining the pixel points to be analyzed includes:
[0017] A probability threshold is preset, and when the probability that any vertical texture of any target pixel does not belong to a metal wire is greater than or equal to the probability threshold, all pixels on the vertical texture of the target pixel are recorded as pixels to be analyzed, and all pixels to be analyzed are obtained.
[0018] According to the characteristics that the grayscale value difference of the metal wire of the high-voltage power grid in the vertical direction of the image is small and the texture is long, the probability that each vertical texture of each target pixel does not belong to the metal wire is obtained, and then the pixel to be analyzed is obtained, so that the leaf area and the pest area can be distinguished only based on the connected areas of the pixel to be analyzed.
[0019] Preferably, the step of obtaining the grayscale balance degree of each connected region includes:
[0020] Obtain the grayscale variance of each edge point of each connected region, the grayscale variance corresponding to the maximum number of edge points in each connected region, and the maximum number of edge points in each connected region;
[0021] ;
[0022] In the formula, Represents the gray balance degree of the jth connected region; Represents the maximum value of the grayscale variance of all edge points in the jth connected region; Represents the grayscale variance corresponding to the maximum number of edge points in the j-th connected region; Represents the maximum number of edge points in the jth connected region; Represents the number of edge points of the j-th connected area; A represents the first weight; B represents the second weight; exp() represents an exponential function with a natural constant as the base.
[0023] Affected by the central light source of the insecticidal lamp, the leaf area and the pest area have different light transmittances. The grayscale distribution of the leaf area in the surface image of the high-voltage power grid is relatively balanced, while the grayscale distribution of the pest area in the surface image of the high-voltage power grid is uneven due to the light transmittance of the pest wings. By obtaining the grayscale balance degree of the connected area, it is convenient to distinguish between the leaf area and the pest area in the subsequent process.
[0024] Preferably, the step of obtaining the grayscale variance of each edge point of each connected region, the grayscale variance corresponding to the maximum number of edge points of each connected region, and the maximum number of edge points of each connected region includes:
[0025] In the opposite direction of the gradient direction of the kth edge point of the jth connected region, obtain the variance of the grayscale values of all pixels belonging to the jth connected region, recorded as the grayscale variance of the kth edge point of the jth connected region, and obtain the grayscale variance of each edge point of each connected region;
[0026] For all edge points of the j-th connected region, the edge points with the same grayscale variance are classified into one category, and the number of edge points in each category is obtained. The grayscale variance corresponding to the maximum number of edge points of all categories is recorded as the grayscale variance corresponding to the maximum number of edge points of the j-th connected region; the maximum number of edge points of all categories is recorded as the maximum number of edge points of the j-th connected region.
[0027] Preferably, obtaining the edge sharpness of the connected region includes:
[0028] Obtaining the adjacent group differences of the first target combination, the left adjacent target combination, and the right adjacent target combination of each connected region;
[0029] ;
[0030] In the formula, Represents the edge sharpness of the jth connected region; represents the difference between adjacent groups of the first target combination of the jth connected region; Represents the difference between adjacent groups of the left adjacent target combination of the jth connected region; Represents the difference between adjacent groups of the right adjacent target combination of the jth connected region; Represents the normalization function.
[0031] The edge sharpness of the leaf area is smaller, that is, the degree of change in the edge gradient direction is smaller, and the edge sharpness of the pest area is larger, that is, the degree of change in the edge gradient direction is larger. Therefore, the edge sharpness of each connected area is obtained to facilitate the subsequent distinction between the leaf area and the pest area.
[0032] Preferably, the step of obtaining the adjacent group differences of the first target combination, the left adjacent target combination, and the right adjacent target combination of each connected region includes:
[0033] Obtain the intra-group difference value of each edge point combination of each connected area;
[0034] Obtain the adjacent group differences of each edge point combination of each connected region: take the absolute value of the difference between the intra-group difference values of the cth edge point combination and the c+1th edge point combination as the adjacent group difference of the cth edge point combination; among all edge point combinations of each connected region, take the combination with the largest adjacent group difference as the first target combination of each connected region; take the left adjacent combination of the first target combination as the left adjacent target combination of each connected region; take the right adjacent combination of the first target combination as the right adjacent target combination of each connected region.
[0035] Preferably, obtaining the intra-group difference value of each edge point combination of each connected region includes:
[0036] Acquire multiple edge point combinations of each connected area, wherein each edge point combination contains three adjacent edge points and edge pixel points contained in different edge point combinations are different;
[0037] The intra-group difference value of each edge point combination of each connected region is obtained, and the intra-group difference value is the average of the absolute values of the gradient direction degree differences between all adjacent edge points in each edge point combination.
[0038] Preferably, the step of obtaining the pest coverage degree of the high-voltage power grid surface image; and remotely controlling the insect cleaning device to clean the high-voltage power grid surface based on the pest coverage degree includes:
[0039] ;
[0040] Where Q represents the pest coverage of the high-voltage power grid surface image; The total area of the pest area representing the surface image of the high-voltage power grid; represents the area of the surface image of the high-voltage power grid; exp() represents an exponential function with a natural constant as the base; a coverage threshold is preset. When the pest coverage of the surface image of the high-voltage power grid is greater than or equal to the coverage threshold, the high-voltage power grid of the insecticidal lamp is powered off, and the insect cleaning device is started to clean the surface of the high-voltage power grid.
[0041] According to the accurate pest area, the pest coverage of the acquired image is more accurate, thereby making it effective to remotely control the insect cleaning device to clean the surface of the high-voltage power grid according to the pest coverage.
[0042] The present invention has the following beneficial effects: the probability that each connected area belongs to a pest area is obtained, and then the pest area is obtained. Finally, according to the area of the pest area, the pest coverage of the original image is obtained, and then the pest cleaning device is remotely controlled to clean the surface of the high-voltage power grid. The connected area represents a leaf area or a pest area. According to the probability that each connected area belongs to the pest area, the pest area can be distinguished from the leaf area, so as to avoid misjudging the pest area as a leaf area, thereby affecting the accuracy of the calculation of the pest coverage of the surface image of the high-voltage power grid. Furthermore, the connected area is obtained by performing a connected domain analysis on the pixel points to be analyzed. The acquisition of the pixel points to be analyzed is based on the characteristics that the grayscale value difference of the metal wire of the high-voltage power grid in the vertical direction of the image is small and the texture is formed to be long, and each vertical texture of each target pixel point is obtained. Through the characteristics of the metal wire texture, the leaf area texture and the pest area texture, the probability that each vertical texture of each target pixel point does not belong to the metal wire is obtained, and then the pixel points to be analyzed are obtained, so that the leaf area and the pest area can be distinguished only based on the pixel points to be analyzed. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] The above and other objects, features and advantages of the exemplary embodiments of the present invention will become readily understood by reading the detailed description below with reference to the accompanying drawings. In the accompanying drawings, several embodiments of the present invention are shown in an exemplary and non-limiting manner, and the same or corresponding reference numerals represent the same or corresponding parts, wherein:
[0044] Figure 1 The present invention is a flowchart of the steps of a method for identifying pests using an insecticidal lamp based on image processing according to an embodiment of the present invention. DETAILED DESCRIPTION
[0045] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0046] The specific embodiments of the present invention are described in detail below with reference to the accompanying drawings.
[0047] See also Figure 1 , which shows a flowchart of a method for identifying pests with an insecticidal lamp based on image processing provided by an embodiment of the present invention, the method comprising the following steps:
[0048] S001. Collect high-voltage power grid surface images.
[0049] In an embodiment of the present invention, a camera is installed on the insecticidal lamp to capture an RGB image of the surface of the high-voltage power grid. To facilitate subsequent analysis, the collected RGB image of the surface of the high-voltage power grid is grayed and recorded as the surface image of the high-voltage power grid.
[0050] It should be noted that since the insecticidal lamp works for a long time at night, the camera installed on the insecticidal lamp needs to run for a long time to collect the surface image of the high-voltage power grid. When the camera is running for a long time, the metal components inside the camera will heat up, which will cause the collected surface image of the high-voltage power grid to have noise, thereby reducing the quality of the surface image of the high-voltage power grid, and further interfering with subsequent image analysis. Therefore, in an embodiment of the present invention, spatial domain filtering is used to remove noise in the surface image of the high-voltage power grid, and sharpening technology is used to enhance the edges in the surface image of the high-voltage power grid.
[0051] S002. Obtain target pixels, and according to the gray value difference between pixels in the longitudinal direction of each target pixel, obtain a number of vertical textures of each target pixel; according to the length of each vertical texture of each target pixel, obtain the probability that each vertical texture of each target pixel does not belong to a metal wire, and screen out pixels to be analyzed.
[0052] It should be noted that the high-voltage power grid area is composed of several vertical metal wires. The characteristics of these metal wires and irrelevant background pixels (light source area and black background area) in the high-voltage power grid surface image are that the grayscale value difference in the vertical direction is small and the texture formed is long. For the leaf area or the pest area, there will be a large difference in the grayscale value in the vertical direction and the texture formed is short. Therefore, firstly, according to the grayscale value difference of the pixel points in the vertical direction, several vertical textures of each target pixel point are obtained.
[0053] In the embodiment of the present invention, each pixel point in the first row of the high-voltage power grid surface image is recorded as a target pixel point, and the vertical downward direction of the pixel point in the upper left corner of the high-voltage power grid surface image is recorded as the longitudinal axis direction;
[0054] Obtain several vertical textures of the ith target pixel: preset a grayscale threshold T, take the ith target pixel as the starting point, record the adjacent pixel in the longitudinal direction of the ith target pixel as the first pixel, obtain the absolute value of the grayscale value difference between the ith target pixel and the first pixel, record the adjacent pixel in the longitudinal direction of the first pixel as the second pixel, obtain the absolute value of the grayscale value difference between the first pixel and the second pixel, record the average of the absolute value of the grayscale value difference between the ith target pixel and the first pixel and the absolute value of the grayscale value difference between the first pixel and the second pixel as the first mean, and when the first mean is greater than the grayscale threshold T, record the ith target pixel, the first pixel and the second pixel as the first vertical texture of the ith target pixel;
[0055] When the first mean is less than or equal to the grayscale threshold T, the adjacent pixel point in the longitudinal direction of the second pixel point is recorded as the third pixel point, the absolute value of the grayscale value difference between the second pixel point and the third pixel point is obtained, and the average of the absolute value of the grayscale value difference between the i-th target pixel point and the first pixel point, the absolute value of the grayscale value difference between the first pixel point and the second pixel point, and the absolute value of the grayscale value difference between the second pixel point and the third pixel point is recorded as the second mean value, and the second mean value is compared with the grayscale threshold T, and so on, until the M-th mean value is greater than the grayscale threshold T, and all the pixels between the i-th pixel point to the N-th pixel point are recorded as the first vertical texture of the i-th target pixel point;
[0056] Taking the adjacent pixel points in the longitudinal direction of the Nth pixel point as the starting point, obtain the second vertical texture of the i-th target pixel point according to the method for obtaining the first vertical texture of the i-th target pixel point; and so on, stop when there are no pixels in the longitudinal direction of the i-th target pixel point, and obtain several vertical textures of the i-th target pixel point.
[0057] Obtain the main vertical texture of the i-th target pixel: record the number of pixels in each vertical texture of the i-th target pixel as the length of each vertical texture, and record the vertical texture corresponding to the maximum length as the main vertical texture of the i-th target pixel; similarly, obtain the main vertical texture of each target pixel. In the embodiment of the present invention, the grayscale threshold T=30 is preset. In other embodiments, the implementer can set the grayscale threshold value according to the specific implementation situation.
[0058] The average length of the main vertical texture of all target pixels is recorded as the main vertical texture length of the metal wire.
[0059] It should be noted that several vertical textures are obtained for each target pixel. It is known that the longer the length of the vertical texture, the greater the probability that the vertical texture does not belong to the metal wire. Therefore, according to the length of each vertical texture of each target pixel and the main vertical texture length of the metal wire, the probability that each vertical texture of each target pixel does not belong to the metal wire is obtained, and the pixels to be analyzed, namely the pixels in the pest area and the leaf area, are screened out.
[0060] In this embodiment of the present invention, the probability that each vertical texture of each target pixel does not belong to a metal wire is obtained: ;
[0061] In the formula, represents the probability that the mth vertical texture at the i-th target pixel does not belong to a metal wire; Represents the length of the mth vertical texture of the i-th target pixel; Represents the main vertical texture length of the metal wire; norm() represents the normalization function, which uses a linear normalization function to normalize the vertical texture of each target pixel. The value of; || represents the absolute value symbol; The absolute value of the difference between the length of the mth vertical texture of the i-th target pixel and the length of the main vertical texture of the metal wire. The larger the value, the less likely the mth vertical texture of the i-th target pixel is to be the metal wire texture. The larger it is, the greater the probability that the mth vertical texture of the ith target pixel does not belong to the metal wire, that is, the mth vertical texture of the ith target pixel is more likely to belong to the leaf area or the pest area pixel.
[0062] A probability threshold T1 is preset. When the probability that the mth vertical texture of the ith target pixel does not belong to the metal wire is greater than or equal to the probability threshold, the mth vertical texture of the ith target pixel is recorded as the pixel to be analyzed, and all the pixels to be analyzed are obtained. In an embodiment of the present invention, the probability threshold T1 is preset to 0.5. In other embodiments, the implementer may preset the value of the probability threshold T1 according to the specific implementation method.
[0063] S003. According to the pixel points to be analyzed, several connected regions are obtained; according to the gray value distribution of the pixel points in the connected region, the gray balance degree of each connected region is obtained; according to the gradient direction change between the edge points of the connected region, the edge sharpness of each connected region is obtained; according to the gray balance degree of the connected region and the edge sharpness of the connected region, the probability that each connected region belongs to the pest region is obtained, and several pest regions are screened out.
[0064] It should be noted that, it is known that due to the influence of the central light source of the insecticidal lamp, the light transmittance of the leaf area and the pest area is different. Therefore, the light transmittance of the leaf area is poor. The grayscale distribution of the leaf area in the surface image of the high-voltage power grid is relatively balanced. Pests generally collide with the high-voltage power grid in a flying state, which makes the grayscale distribution of the pest area in the surface image of the high-voltage power grid uneven due to the light transmittance of the pest wings. Therefore, the probability of each connected area belonging to the leaf area can be judged according to the grayscale balance degree of each connected area composed of the pixel points to be analyzed. The greater the grayscale balance degree of any connected area, the greater the possibility that the connected area belongs to the leaf area, and the smaller the possibility that it belongs to the pest area. The smaller the grayscale balance degree of any connected area, the smaller the possibility that the connected area belongs to the leaf area, and the greater the possibility that it belongs to the pest area.
[0065] In an embodiment of the present invention, a connected domain analysis is performed on the pixel points to be analyzed in the surface image of the high-voltage power grid to obtain multiple connected areas; in the opposite direction of the gradient direction of the kth edge point of the jth connected area, the variance of the grayscale values of all pixel points belonging to the jth connected area is obtained, which is recorded as the grayscale variance of the kth edge point of the jth connected area. Similarly, the grayscale variance of each edge point of each connected area is obtained.
[0066] For all edge points of the j-th connected region, the edge points with the same grayscale variance are classified into one category, and the number of edge points in each category is obtained. The grayscale variance corresponding to the maximum number of edge points of all categories is recorded as the grayscale variance corresponding to the maximum number of edge points of the j-th connected region; the maximum number of edge points of all categories is recorded as the maximum number of edge points of the j-th connected region.
[0067] Get the grayscale balance degree of each connected region:
[0068] ;
[0069] In the formula, Represents the gray balance degree of the jth connected region; Represents the maximum value of the grayscale variance of all edge points in the jth connected region; Represents the grayscale variance corresponding to the maximum number of edge points in the j-th connected region; Represents the maximum number of edge points in the jth connected region; represents the number of edge points of the jth connected region; A represents the first weight; B represents the second weight; in the embodiment of the present invention, the first weight A=0.6 and the second weight B=0.4 are preset; in other embodiments, the implementer may preset the values of the first weight and the second weight according to the specific implementation situation; as well as The larger the value of , the larger the grayscale variance of the edge points of the j-th connected area, and the larger the grayscale variance of a large number of edge points, indicating that the grayscale distribution of pixels in the j-th connected area is uneven, so the grayscale balance degree of the j-th connected area is relatively small. exp() represents an exponential function with a natural constant as the base. In the embodiment of the present invention, the exp(-x) model is used to present an inverse proportional relationship. x represents the input of the model. The implementer can set the inverse proportional function according to the actual implementation situation.
[0070] It should be noted that, due to the influence of the high-voltage power grid, pests may be incomplete, such as having only a trunk but no wings. Under the influence of the central light source of the insecticidal lamp, this type of pest may not have good light transmittance like the leaf area. Therefore, when judging whether the connected area belongs to the pest or leaf area only based on the grayscale balance of each connected area, the pest area may be misjudged as the leaf area, which will make the calculation of the pest coverage of the surface image of the high-voltage power grid inaccurate. If the connected area belongs to the leaf area, the sharpness of the edge of the connected area is small, that is, the gradient direction between the edge points of the connected area changes less. If the connected area belongs to the pest area, the sharpness of the edge of the connected area is large, that is, the gradient direction between the edge points changes more. Therefore, according to the gradient direction change between the edge points of each connected area, the edge sharpness of each connected area is obtained.
[0071] In an embodiment of the present invention, multiple edge point combinations are obtained for each connected area, each edge point combination contains three adjacent edge points and the edge pixel points contained in different edge point combinations are different; it should be noted that in the process of obtaining the combination, if the number of edge points in the combination does not meet three, a zero-filling operation is performed on it.
[0072] The intra-group difference value of each edge point combination of each connected region is obtained, and the intra-group difference value is the average of the absolute values of the gradient direction degree differences between all adjacent edge points in each edge point combination.
[0073] Obtain the adjacent inter-group differences of each edge point combination of each connected region: take the absolute value of the difference between the intra-group difference values of the cth edge point combination and the c+1th edge point combination as the adjacent inter-group difference of the cth edge point combination.
[0074] Among all edge point combinations of each connected region, the combination with the largest difference between adjacent groups is used as the first target combination of each connected region; the left adjacent combination of the first target combination is used as the left adjacent target combination of each connected region; and the right adjacent combination of the first target combination is used as the right adjacent target combination of each connected region.
[0075] Get the edge sharpness of the jth connected region:
[0076] ;
[0077] In the formula, Represents the edge sharpness of the jth connected region; represents the difference between adjacent groups of the first target combination of the jth connected region; Represents the difference between adjacent groups of the left adjacent target combination of the jth connected region; Represents the difference between adjacent groups of the right adjacent target combination of the jth connected region; when the mean value of the difference between adjacent groups corresponding to the first target combination of the jth connected region and the left and right adjacent target combinations of the first target combination is larger, it means that the edge sharpness of the jth connected region is greater, and the possibility that the jth connected region belongs to the pest area is greater. The larger the value is, the sharper the edge of the j-th connected region is, and the greater the possibility that the j-th connected region belongs to the pest area. Represents the normalization function.
[0078] It should be noted that the greater the edge sharpness of the known connected area and the smaller the grayscale balance of the connected area, the greater the possibility that the connected area belongs to the pest area. Combined with the probability that the vertical texture of each pixel in the connected area does not belong to the metal wire, the probability that each connected area belongs to the pest area is obtained, and several pest areas of the high-voltage power grid surface image are obtained.
[0079] In this embodiment of the present invention, the probability that each connected area belongs to the pest area is obtained:
[0080] ;
[0081] In the formula, represents the probability that the jth connected area belongs to the pest area; Represents the edge sharpness of the jth connected region; Represents the gray balance degree of the jth connected region; Represents the number of pixels in the jth connected region; represents the probability that the vertical texture of the sth pixel in the jth connected area does not belong to the metal wire; when the edge sharpness of the jth connected area is greater and the grayscale balance of the jth connected area is smaller, the probability that the jth connected area belongs to the pest area is greater; when the mean value of the probability that the vertical texture of all pixels in the jth connected area does not belong to the metal wire is greater, it means that the probability that the jth connected area belongs to the pest area is greater, norm() represents the normalization function, using a linear normalization function, and the normalization object is all connected areas. The value of .
[0082] A pest probability threshold T2 is preset. When the probability that the jth connected area belongs to a pest area is greater than or equal to the pest probability threshold T2, the jth connected area is a pest area. Several pest areas of the high-voltage power grid surface image are obtained. In an embodiment of the present invention, the pest probability threshold T2 is preset to 0.6. In other embodiments, the implementer may preset the value of the pest probability threshold T2 according to the specific implementation situation.
[0083] S004. According to a plurality of pest areas of the high-voltage power grid surface image, the pest coverage degree of the high-voltage power grid surface image is obtained, and according to the pest coverage degree of the high-voltage power grid surface image, a pest cleaning device is remotely controlled to clean the high-voltage power grid surface.
[0084] It should be noted that, after obtaining several pest areas of the surface image of the high-voltage power grid, it is necessary to obtain the pest coverage degree of the surface image of the high-voltage power grid based on the ratio of the areas of the several pest areas of the surface image of the high-voltage power grid to the area of the surface image of the high-voltage power grid, and then remotely control the insect cleaning device to clean the surface of the high-voltage power grid based on the pest coverage degree of the surface image of the high-voltage power grid.
[0085] In an embodiment of the present invention, the number of pixels in all pest areas of the high-voltage power grid surface image is recorded as the total area of the pest areas of the high-voltage power grid surface image; the number of pixels in the high-voltage power grid surface image is recorded as the area of the high-voltage power grid surface image.
[0086] Obtain pest coverage of high voltage power grid surface images:
[0087] ;
[0088] Where Q represents the pest coverage of the high-voltage power grid surface image; The total area of the pest area representing the surface image of the high-voltage power grid; Represents the area of the high-voltage power grid surface image; exp() represents an exponential function with a natural constant as the base, which is used to Perform normalization.
[0089] A coverage threshold T3 is preset. When the pest coverage of the surface image of the high-voltage power grid is greater than or equal to the coverage threshold T3, the high-voltage power grid of the insecticidal lamp is powered off, and the insect cleaning device is started to clean the surface of the high-voltage power grid in time. After the cleaning is completed, the high-voltage power grid of the insecticidal lamp continues to be powered on to maintain the efficient operation of the insecticidal lamp. In an embodiment of the present invention, the coverage threshold T3 is preset to 0.7. In other embodiments, the implementer may preset the value of the coverage threshold T3 according to the specific implementation situation.
[0090] Beneficial effects of the present invention: The purpose of the present invention is to obtain the probability that each connected area belongs to a pest area, and then obtain the pest area, and finally obtain the pest coverage of the original image according to the area of the pest area, and then remotely control the insect cleaning device to clean the surface of the high-voltage power grid, the connected area represents a leaf area or a pest area, and the pest area can be distinguished from the leaf area according to the probability that each connected area belongs to the pest area, so as to avoid misjudging the pest area as a leaf area, thereby affecting the accuracy of the calculation of the pest coverage of the surface image of the high-voltage power grid. Furthermore, the connected area is obtained by performing a connected domain analysis on the pixel points to be analyzed, and the acquisition of the pixel points to be analyzed is based on the characteristics that the grayscale value difference of the metal wire of the high-voltage power grid in the vertical direction of the image is small and the texture is formed to form a long, and each vertical texture of each target pixel point is obtained, and the probability that each vertical texture of each target pixel point does not belong to the metal wire is obtained through the characteristics of the metal wire texture and the leaf area texture and the pest area texture, and then the pixel points to be analyzed are obtained, so as to facilitate the distinction between the leaf area and the pest area based only on the pixel points to be analyzed.
[0091] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the principles of the present invention should be included in the protection scope of the present invention.
Claims
1. A method for identifying pests using an insecticidal lamp based on image processing, characterized in that: include: Collect high-voltage power grid surface images; Each pixel point in the first row of the high-voltage power grid surface image is recorded as a target pixel point; Get several vertical textures of each target pixel; get the probability that each vertical texture of each target pixel does not belong to a metal wire ,in, Represents the length of the mth vertical texture of the i-th target pixel; The main vertical texture length representing the metal wire; based on the probability that each vertical texture of each target pixel does not belong to the metal wire, obtaining the pixel point to be analyzed, wherein the pixel point to be analyzed is a pixel point of the leaf area or the pest area; Perform connected domain analysis on the pixels to be analyzed to obtain each connected area; obtain the probability that each connected area belongs to the pest area ,in, Represents the edge sharpness of the jth connected region; Represents the gray balance degree of the jth connected region; Represents the number of pixels in the jth connected region; represents the probability that the vertical texture where the s-th pixel point in the j-th connected area is located does not belong to the metal wire; based on the probability of belonging to the pest area, the pest area is obtained; Based on the area of the pest area, the pest coverage degree of the high-voltage power grid surface image is obtained; based on the pest coverage degree, a remotely controlled insect cleaning device is used to clean the surface of the high-voltage power grid; Get the gray balance degree of each connected area, including: Obtain the grayscale variance of each edge point of each connected region, the grayscale variance corresponding to the maximum number of edge points in each connected region, and the maximum number of edge points in each connected region; ; In the formula, Represents the gray balance degree of the jth connected region; Represents the maximum value of the grayscale variance of all edge points in the jth connected region; Represents the grayscale variance corresponding to the maximum number of edge points in the j-th connected region; Represents the maximum number of edge points in the jth connected region; represents the number of edge points of the jth connected region; A represents the first weight; B represents the second weight; exp() represents an exponential function with a natural constant as the base; The acquisition of the edge sharpness of the connected region includes: Obtaining the adjacent group differences of the first target combination, the left adjacent target combination, and the right adjacent target combination of each connected region; ; In the formula, Represents the edge sharpness of the jth connected region; represents the difference between adjacent groups of the first target combination of the jth connected region; Represents the difference between adjacent groups of the left adjacent target combination of the jth connected region; Represents the difference between adjacent groups of the right adjacent target combination of the jth connected region; Represents the normalization function.
2. The method for identifying pests using an insecticidal lamp based on image processing according to claim 1, characterized in that: The step of obtaining a plurality of vertical textures of each target pixel point includes: The vertical downward direction of the pixel point at the upper left corner of the high-voltage power grid surface image is recorded as the longitudinal axis direction; Taking each target pixel as a starting point, traverse all pixel points along the longitudinal axis direction to obtain all vertical textures of each target pixel point; the average of the absolute values of the grayscale differences between all adjacent pixel points in each vertical texture is greater than a preset grayscale threshold, and the vertical textures are connected end to end.
3. The method for identifying pests using an insecticidal lamp based on image processing according to claim 1, characterized in that: The main vertical texture length of the metal wire is obtained, comprising: The number of pixels in each vertical texture of each target pixel is recorded as the length of each vertical texture of each target pixel, and the vertical texture corresponding to the maximum length is recorded as the main vertical texture of each target pixel; the average length of the main vertical texture of all target pixels is recorded as the main vertical texture length of the metal wire.
4. The method for identifying pests using an insecticidal lamp based on image processing according to claim 1, characterized in that: The step of obtaining the pixel to be analyzed includes: A probability threshold is preset, and when the probability that any vertical texture of any target pixel does not belong to a metal wire is greater than or equal to the probability threshold, all pixels on the vertical texture of the target pixel are recorded as pixels to be analyzed, and all pixels to be analyzed are obtained.
5. The method for identifying pests using an insecticidal lamp based on image processing according to claim 1, characterized in that: The step of obtaining the grayscale variance of each edge point of each connected region, the grayscale variance corresponding to the maximum number of edge points of each connected region, and the maximum number of edge points of each connected region includes: In the opposite direction of the gradient direction of the kth edge point of the jth connected region, obtain the variance of the grayscale values of all pixels belonging to the jth connected region, recorded as the grayscale variance of the kth edge point of the jth connected region, and obtain the grayscale variance of each edge point of each connected region; For all edge points of the j-th connected region, the edge points with the same grayscale variance are classified into one category, and the number of edge points in each category is obtained. The grayscale variance corresponding to the maximum number of edge points of all categories is recorded as the grayscale variance corresponding to the maximum number of edge points of the j-th connected region; the maximum number of edge points of all categories is recorded as the maximum number of edge points of the j-th connected region.
6. The method for identifying pests using an insecticidal lamp based on image processing according to claim 1, characterized in that: The step of obtaining the adjacent group differences of the first target combination, the left adjacent target combination, and the right adjacent target combination of each connected region includes: Obtain the intra-group difference value of each edge point combination of each connected area; Obtain the adjacent group differences of each edge point combination of each connected region: take the absolute value of the difference between the intra-group difference values of the cth edge point combination and the c+1th edge point combination as the adjacent group difference of the cth edge point combination; among all edge point combinations of each connected region, take the combination with the largest adjacent group difference as the first target combination of each connected region; take the left adjacent combination of the first target combination as the left adjacent target combination of each connected region; take the right adjacent combination of the first target combination as the right adjacent target combination of each connected region.
7. The method for identifying pests using an insecticidal lamp based on image processing according to claim 6, characterized in that: The obtaining of the intra-group difference value of each edge point combination of each connected region includes: Acquire multiple edge point combinations of each connected area, wherein each edge point combination contains three adjacent edge points and edge pixel points contained in different edge point combinations are different; The intra-group difference value of each edge point combination of each connected region is obtained, and the intra-group difference value is the average of the absolute values of the gradient direction degree differences between all adjacent edge points in each edge point combination.
8. The method for identifying pests using an insecticidal lamp based on image processing according to claim 1, characterized in that: The pest coverage degree of the high voltage power grid surface image is obtained; Based on the degree of pest coverage, the remote controlled insect removal device cleans the surface of the high voltage power grid, including: ; Where Q represents the pest coverage of the high-voltage power grid surface image; The total area of the pest area representing the surface image of the high-voltage power grid; Represents the area of the high-voltage power grid surface image; exp() represents an exponential function with a natural constant as the base; A coverage threshold is preset. When the pest coverage of the high-voltage power grid surface image is greater than or equal to the coverage threshold, the high-voltage power grid of the insecticidal lamp is powered off, and the insect cleaning device is started to clean the surface of the high-voltage power grid.
