Photovoltaic panel edge segmentation method based on unmanned aerial vehicle infrared image
Technical Field
The invention belongs to a photovoltaic panel image processing method in the field of computer vision and image analysis, and particularly relates to a photovoltaic panel edge segmentation method based on an unmanned aerial vehicle infrared image, which is mainly used for image segmentation processing in infrared image processing.
Background
In a power plant, solar modules are typically installed in a wide, sunny area. The shielding objects such as flying birds, dust, fallen leaves and the like are difficult to fall on for a long time, the shielding objects form shadows on the solar cell module, and the current and the voltage of certain single cells in the solar cell module are changed due to the existence of local shadows. As a result, the product of the local current and voltage of the solar cell module increases, and a local temperature rise occurs in the solar cell module. Defects of certain cell single sheets in the solar cell module can also cause the module to generate heat locally during operation, and the phenomenon is called a 'hot spot effect'. The hot spot effect of the photovoltaic panel and how to detect the existence of the hot plate are important research subjects for ensuring the normal work of the photovoltaic panel.
The detection of the boundary of the photovoltaic panel can provide the most basic position information for the thermal panel detection. In recent years, with the development of unmanned aerial vehicle technology and the development of infrared imaging devices, the price of an infrared sensor is lower and lower, the resolution is gradually improved, the image resolution of 640X512 can be achieved in M300 RTK, and the infrared image detection based on the unmanned aerial vehicle provides basic guarantee for all-weather hot spot detection.
In the process of acquiring the infrared image, due to adverse effects of factors such as uneven heating, infrared radiation of the environment and equipment, uneven surface and internal structure of the tested piece and the like, the acquired defect information in the thermal wave image is submerged by a large amount of irrelevant noise.
Disclosure of Invention
Aiming at the problems in the prior art, the invention provides an infrared image boundary segmentation method for a photovoltaic panel under the view angle of an unmanned aerial vehicle, which overcomes the defects of the traditional method, well improves the photovoltaic panel and the background and the region with larger contrast, improves the segmentation precision, realizes multi-scene segmentation and improves the flexibility of positioning the photovoltaic panel of a power plant.
As shown in fig. 1, the object of the present invention is achieved by:
(1) acquiring an infrared image of the photovoltaic panel by an unmanned aerial vehicle, preprocessing the image and converting the image into gray scale, as shown in fig. 2;
(2) optimizing iterative processing of segmentation threshold T aiming at infrared image to obtain first optimal segmentation threshold TOtsu;
(3) Calculating probability distribution aiming at infrared image divided regions to obtain second optimal segmentation threshold value TKsw;
(4) Dividing the second optimal division threshold value TKswAnd a first optimal segmentation threshold TOtsuAnd performing weighting calculation to obtain a final segmentation threshold, and segmenting the infrared image according to the final segmentation threshold to obtain the edge of the photovoltaic panel, as shown in fig. 3.
The unmanned aerial vehicle on install infrared camera, unmanned aerial vehicle flies to the sky above the solar field, infrared camera is to shooting the photovoltaic panel subassembly in the solar field downwards and obtain infrared image.
The step (2) is specifically as follows:
(2.1) initially setting a segmentation threshold t to be 1; in specific implementation, the value range of the segmentation threshold t is 0-255, 0 is pure black, and 255 is pure white.
(2.2) classifying the pixels of the infrared image smaller than the segmentation threshold t as a background part C0, otherwise classifying the pixels as a target part C1, wherein the gray level range of the background part C0 is 0-t-1, the gray level range of the target part C1 is t-L-1, and L is a preset maximum value of the gray level;
(2.3) calculating the probability, the mean gray value, the intra-class variance and the number of pixels of the background part C0 and the target part C1 respectively;
(2.4) calculating the feature parameter δ from the probabilities, mean gray-scale values, intra-class variances, and pixel counts of the background portion C0 and the target portion C12(k);
(2.5) if t < L, making t equal to t +1, and returning to step (2.2);
(2.6) if t is more than or equal to L, correspondingly obtaining all characteristic parameters delta according to the change of t from 0 to L-12(T) finding a division threshold T in which the maximum value of the characteristic parameter corresponds to the maximum value as a first optimum division threshold TOtsu。
In the step (2.4), the characteristic parameter delta is calculated according to the following formula2(t):
δ2(t)=(ω0(u-u0)+ω1(u-u1))*(cnt0-cnt1)
Wherein, w0Probability of background portion C0, w1Is the probability, u, of the target portion C10Is the mean gray value of the background portion C0, u1Is the average gray value, v, of the target portion C10Within class variance, v, of background component C01The intra-class variance of the target portion C1 is denoted by cnt0 as the total number of pixels in the background portion C0 and cnt1 as the total number of pixels in the target portion C1.
According to the invention, the infrared image of the photovoltaic panel is acquired by the unmanned aerial vehicle, and then the infrared image is processed to obtain a purer image and a more accurate detection and segmentation result.
In the present invention, the infrared image I is represented by f (x, y)MXNThe gray value at the (x, y) position is a gray image, the gray level L of which is 256, f (x, y) belongs to [0, L-1 ]]。
Probability p of occurrence of a pixel with a gray level iiComprises the following steps:
wherein p isiEach represents the probability of occurrence of a pixel having a gray level i, i being 0,1iRepresenting the total number of pixels at the same gray level i; m, N respectively indicate the number of pixels in length and width of the input image, where M × N is the total number of pixels in the image.
In the steps (2.3) and (2.4), the average gray value u is calculated as:
wherein i represents the number of gray levels, piRespectively, the occurrence probability of a pixel having a gray level i.
The step (2.4) comprises the following steps:
(2.41) probability w of background portion C00And the probability w of the target portion C11The calculation is as follows:
w0+w1=1
wherein, w0Probability of background portion C0, w1Probability of being the target portion C1;
(2.42) average grayscale value u of background portion C0 image0And the average gray value u of the image of the target portion C11The calculation is as follows:
the step (3) is specifically as follows:
(3) setting the gray scale range of an image as {0,1,2.,. L-1}, dividing the image into T, B two regions according to a preset segmentation threshold k, wherein the region T is a distribution of i ∈ {0, 1.,. k }, and the region B is a distribution of i ∈ { k + 1.,. L-1}, and the specific form is as follows:
wherein, PiRepresenting the probability of occurrence of a pixel with a gray level i;
computing total entropy of an image using entropy of probability distributions of two regions
Comprises the following steps:
solving the total entropy of an image
Division threshold of maximum valuek as the first optimal segmentation threshold f
KswI.e. expressed as:
in the above (4), the second optimal division threshold value T is setKswWith a first optimal segmentation threshold TOtsuWeighting to obtain the final segmentation threshold TFinal:
TFinal=α×TOtsu+β×TKsw
Wherein alpha and beta respectively represent a first weight coefficient and a second weight coefficient, the values of the weight coefficients alpha and beta are between (0 and 1), alpha is 0.7, and beta is 0.6.
Optimal threshold T obtained by maximum entropy methodKswAnd the optimal threshold value T obtained in the maximum characteristic parameter Otsu methodOtsuAnd (5) carrying out threshold weighting to determine the optimal threshold of the final segmentation.
The method is mainly used for image segmentation processing in infrared image processing of the photovoltaic panel.
Compared with the prior art, the invention has the beneficial effects that:
because the contrast ratio of the infrared image is low, the gray level range is narrow, and the target cannot be well segmented by using the maximum characteristic parameter method.
The invention considers the influence of the image gray level, the image background pixel number and the target pixel number on the segmentation, improves the existing image processing and method, can better make up for the defect that the infrared image segmentation algorithm cannot obtain better segmentation effect under the conditions of exposure and lower contrast between the background and the target by combining the maximum entropy method, and can better segment the region with higher contrast between the target and the background, thereby better segmenting the target.
The method better considers the influence of the image gray level, the background and the number of the target pixels, carries out weighting calculation by combining a maximum entropy method, has stronger robustness of the algorithm, and thus obtains better segmentation effect. The invention improves the traditional method, so that the image segmentation effect can be good under the conditions of high exposure and low contrast.
Drawings
FIG. 1 is a flow chart of an infrared image segmentation algorithm of the present invention.
Fig. 2 is an infrared image to be measured of the photovoltaic panel under the view angle of the unmanned aerial vehicle in the embodiment of the invention.
FIG. 3 is a diagram illustrating the results of an infrared image segmentation algorithm according to an embodiment of the present invention.
Detailed Description
The invention is described in more detail below with reference to the accompanying drawings:
as shown in fig. 1, the embodiment of the method of the present invention and its implementation are as follows:
(1) acquiring an infrared image of the photovoltaic panel by an unmanned aerial vehicle, as shown in fig. 2;
install infrared camera on the unmanned aerial vehicle, unmanned aerial vehicle flies to the sky above the solar field, and infrared camera is downwards to the photovoltaic panel subassembly in the solar field shoot and obtain infrared image.
(2) Optimizing iterative processing of segmentation threshold T aiming at infrared image to obtain first optimal segmentation threshold TOtsu;
(2.1) initially setting a segmentation threshold t to be 1; in specific implementation, the value range of the segmentation threshold t is 0-255, 0 is pure black, and 255 is pure white.
(2.2) classifying the pixels of the infrared image smaller than the segmentation threshold t as a background part C0, otherwise classifying the pixels as a target part C1, wherein the gray level range of the background part C0 is 0-t-1, the gray level range of the target part C1 is t-L-1, and L is a preset maximum value of the gray level;
(2.3) calculating the probability, the average gray value and the number of pixels of the background part C0 and the target part C1 respectively;
(2.4) calculating the characteristic parameter δ from the probabilities, mean gray values and number of pixels of the background part C0 and the target part C12(t);
(2.41) probability w of background portion C00And the probability w of the target portion C11The calculation is as follows:
w0+w1=1
wherein, w0Probability of background portion C0, w1Probability of being the target portion C1;
(2.42) average grayscale value u of background portion C0 image0And the average gray value u of the image of the target portion C11The calculation is as follows:
the invention improves the traditional maximum characteristic parameter (Otsu) method, considers the relation between the background gray scale and the target gray scale and the number of pixels of the background and the target part, and can ensure that the region with larger contrast ratio has better segmentation effect compared with the traditional method.
In step (2.4), the characteristic parameter δ is calculated according to the following formula2(t):
δ2(t)=(ω0(u-u0)+ω1(u-u1))*(cnt0-cnt1)
Wherein, w0Probability of background portion C0, w1Is the probability, u, of the target portion C10Is the mean gray value of the background portion C0, u1The cnt0 is the total number of pixels in the background portion C0, and the cnt1 is the total number of pixels in the target portion C1, which is the average gray scale value of the target portion C1.
In the present invention, the infrared image I is represented by f (x, y)MXNGray value at the (x, y) position, the image being a gray image, the gray level L of which=256,f(x,y)∈[0,L-1]。
Probability p of occurrence of a pixel with a gray level iiComprises the following steps:
wherein p isiEach represents the probability of occurrence of a pixel having a gray level i, i being 0,1iRepresenting the total number of pixels at the same gray level i; m, N respectively indicate the number of pixels in length and width of the input image, where M × N is the total number of pixels in the image.
(2.5) if t < L, making t equal to t +1, and returning to step (2.2);
(2.6) if t is more than or equal to L, correspondingly obtaining all characteristic parameters delta according to the change of t from 0 to L-12(T) finding a division threshold T in which the maximum value of the characteristic parameter corresponds to the maximum value as an optimum division threshold TOtsu。
(3) Setting the gray scale range of an image as {0,1,2.,. L-1}, dividing the image into T, B two regions according to a preset segmentation threshold k, wherein the region T is a distribution of i ∈ {0, 1.,. k }, and the region B is a distribution of i ∈ { k + 1.,. L-1}, and the specific form is as follows:
wherein, PiRepresenting the probability of occurrence of a pixel with a gray level i;
computing total entropy of an image using entropy of probability distributions of two regions
Comprises the following steps:
solving the total entropy of an image
The division threshold k of the maximum value is used as the first optimal division threshold f
KswI.e. expressed as:
in the step (4), the step (c),
firstly, a second optimal segmentation threshold value T is obtainedKswWith a first optimal segmentation threshold TOtsuWeighting to obtain the final segmentation threshold TFinal:
TFinal=α×TOtsu+β×TKsw
Wherein alpha and beta respectively represent a first weight coefficient and a second weight coefficient, the values of the weight coefficients alpha and beta are between (0 and 1), alpha is 0.7, and beta is 0.6.
Then, a binary image obtained after the infrared image f (x, y) is segmented is recorded as g (x, y), and an infrared image binarization algorithm is shown as the following formula:
wherein g (x, y) represents when the gray level of the original image is greater than TFinalWhen the gray value is 255 and less than TFinalWhen this is the case, the gray value is 0. The image is segmented to obtain the edge of the photovoltaic panel, and the segmentation result is shown in fig. 3.
The algorithm of the embodiment completes the segmentation of the photovoltaic panel in the infrared image under the view angle of the unmanned aerial vehicle, compared with the traditional infrared image segmentation method, the method has great improvement on the precision, the edge segmentation is obviously due to the traditional image processing method, and the method has the greatest advantages of overcoming the problems that the boundary is not easy to distinguish due to continuous infrared image hot zones and the segmentation effect is poor when the contrast of the background and the target is high. The method can be applied to the fields of photovoltaic panel positioning, defect detection and the like under the infrared scene under the visual angle of the unmanned aerial vehicle.