Research on Image Segmentation Algorithms for Solar Panels in Infrared Images under Uneven Color Distribution

In this thesis, I focus on the problem of segmenting photovoltaic solar panels from aerial infrared images captured by unmanned aerial vehicles (UAVs), especially when the images suffer from uneven color distribution, blurred boundaries, and low contrast. These challenges significantly degrade the performance of existing segmentation algorithms. To address these issues, I propose two novel segmentation approaches: one combining guided filter enhancement with line detection, and another integrating saliency detection with skeleton extraction. Through extensive experiments on real datasets, I demonstrate that both methods achieve higher accuracy and robustness than several state-of-the-art algorithms. Throughout this work, the central object is always the solar panels, and the goal is to precisely extract their regions to facilitate subsequent defect detection.

Segmentation of Solar Panels in Uneven Infrared Images

1. Introduction

Solar panels are the core devices that convert light energy into electrical energy. When the surface of a solar panel is damaged, its energy conversion efficiency drops significantly. Therefore, detecting defects such as cracks, hotspots, or contamination on solar panels is crucial for maintaining their performance. Manual inspection is labor-intensive and inefficient, especially for large-scale photovoltaic farms. UAV-based infrared thermography provides a fast and cost-effective solution. The infrared images reveal temperature differences: defective areas emit more heat and appear brighter than normal regions. However, the acquired images often contain uneven color distributions due to varying solar irradiation, heat dissipation, and UAV motion, which makes accurate segmentation of solar panels a challenging task. In this thesis, I investigate robust segmentation algorithms that can precisely delineate the boundaries of solar panels under such adverse conditions.

The main contributions of my work are summarized as follows:

  • I propose a guided filter enhancement method to improve edge information and contrast of infrared solar panel images.
  • I combine line segment detection with K-means clustering to eliminate background noise and irrelevant lines, achieving accurate contour extraction.
  • I introduce a boundary correction step to reduce background areas around the extracted solar panels, improving precision.
  • I develop a saliency detection approach based on gradient magnitude and pixel color to highlight panel edges while removing connecting rods between adjacent solar panels.
  • I integrate skeleton extraction to thin the extracted contours, thereby reducing background inclusion and improving segmentation accuracy.

2. Background and Related Work

Infrared thermography is widely used in non-destructive testing. For solar panels, the thermal images are acquired by a thermal camera mounted on a UAV. The temperature distribution over the panel surface reflects the health status of the solar panel. Cracks or defects alter the local thermal conductivity, leading to hotspots that appear as bright regions in the infrared image. Therefore, the first step in automatic defect detection is to segment the solar panel region from the background. Many image segmentation algorithms exist, but they often assume relatively uniform color or intensity. In practice, the infrared images of solar panels exhibit significant intensity inhomogeneity due to the angle of sunlight, weather conditions, and the reflective properties of the panel surface. This makes segmentation particularly challenging.

Classical methods such as thresholding, edge detection, and region growing fail to handle uneven illumination. Graph-based methods like GrabCut and graph-cut require user interaction or prior shape information. Level-set methods are computationally intensive and sensitive to initialization. Recent deep learning methods require large labeled datasets and may not generalize well to different scenarios. Therefore, I aim to design unsupervised or weakly supervised approaches that exploit the geometric structure of solar panels, which are typically rectangular and arranged in a regular grid. The two proposed methods leverage image enhancement, line detection, clustering, saliency, and morphological operations to achieve robust segmentation of solar panels.

3. Method 1: Guided Filter Enhancement and Line Detection Based Segmentation

This method is motivated by the observation that solar panels have clear straight boundaries. However, the boundaries are often blurred in infrared images. I first enhance the image using a guided filter, which is an edge-preserving smoothing filter. Then, I detect line segments using a Line Segment Detector (LSD). To remove noise and irrelevant lines, I apply K-means clustering based on the line orientations. Finally, I perform dilation and contour analysis to extract the solar panel regions.

3.1 Guided Filter Enhancement

The guided filter is a local linear model that uses a guidance image to produce a filtered output. Let the input image be \(I\) and the guidance image be \(G\). The filtering output \(Q\) is assumed to be a linear transform of \(G\) in a local window \(w_k\):

$$ Q_i = a_k G_i + b_k, \quad \forall i \in w_k, $$

where \(a_k\) and \(b_k\) are constant coefficients in the window \(w_k\). These coefficients are obtained by minimizing the following cost function:

$$ E(a_k, b_k) = \sum_{i \in w_k} \left( (a_k G_i + b_k – I_i)^2 + \epsilon a_k^2 \right), $$

where \(\epsilon\) is a regularization parameter that prevents large \(a_k\). The solution is given by linear regression:

$$ a_k = \frac{\frac{1}{|w|}\sum_{i \in w_k} G_i I_i – \mu_k \bar{I}_k}{\sigma_k^2 + \epsilon}, \quad b_k = \bar{I}_k – a_k \mu_k, $$

where \(\mu_k\) and \(\sigma_k^2\) are the mean and variance of \(G\) in \(w_k\), \(|w|\) is the number of pixels, and \(\bar{I}_k\) is the mean of \(I\) in the window.

To enhance the edges, I combine the original image \(I\) and the filtered output \(Q\) as:

$$ A = I + \lambda (I – Q), $$

where \(\lambda\) is a positive weighting factor. The term \((I – Q)\) contains high-frequency components such as edges and noise. By adding a scaled version of this difference, the edges are amplified. However, noise may also be amplified. Therefore, I apply a Gaussian filter to the enhanced image \(A\) to suppress the noise. This step significantly improves the detection of panel boundaries.

3.2 Line Detection and K-Means Clustering

After enhancement, I use the Canny edge detector to obtain a binary edge map. Then, the LSD algorithm is employed to detect line segments from the edge map. LSD computes the gradient magnitude and orientation at each pixel. It groups pixels with similar orientations into line-support regions and approximates them with rectangles. The number of false alarms (NFA) is used to validate each line segment. For a candidate line region \(r\), the NFA is defined as:

$$ \mathrm{NFA}(r) = (NM)^{5/2} \sum_{j=k}^{n} \binom{n}{j} p^j (1-p)^{n-j}, $$

where \(N\) and \(M\) are the dimensions of the image, \(n\) is the number of pixels in the rectangle, \(k\) is the number of aligned points, and \(p\) is the probability of an aligned point. Only lines with \(\mathrm{NFA} \leq 1\) are accepted. This provides a reliable set of line segments.

In the infrared images, the detected lines come from three sources: the horizontal and vertical boundaries of solar panels, and the background noise or connecting rods. The orientations of the panel boundaries are usually clustered into two dominant directions (approximately horizontal and vertical). The noise lines have random orientations. To remove the noise, I apply K-means clustering to the line angles. Let the angle of each line be \(\theta \in (-\pi/2, \pi/2]\). I set the number of clusters to 3. After clustering, I discard the cluster with the fewest lines, as it typically corresponds to background noise or connecting rods. The remaining two clusters represent the horizontal and vertical boundary lines of the solar panels.

3.3 Morphological Operations and Contour Selection

The remaining line segments are usually discontinuous. To form closed contours, I first perform a dilation operation on the line image. Dilation enlarges the lines and connects nearby segments. Then, I find all the connected components (contours). For each contour, I check whether it contains at least four sub-contours with an area greater than a threshold (e.g., 1000 pixels). The presence of such sub-contours indicates that the contour is likely the boundary of a solar panel, because a solar panel has multiple grid cells that appear as inner edges. I keep only those contours that satisfy this criterion.

Once the solar panel contours are obtained, I extract the minimum enclosing rectangle for each contour. This rectangle is the final segmented region. However, due to small alignment errors, the rectangle may include some background pixels at the border. I therefore apply a boundary correction step.

3.4 Boundary Correction

To remove the background pixels at the boundaries, I first rotate the extracted rectangle so that the solar panel is aligned with the horizontal axis. The rotation angle is determined by the longest line found in the previous step. Let \( \phi \) be the angle of the longest line with respect to the horizontal axis. The rotation angle is:

$$ \alpha = \begin{cases} -90^\circ + \phi, & \phi > 0 \\ 90^\circ + \phi, & \phi < 0 \end{cases} $$

If \(\phi\) is positive, the image is rotated clockwise by \(\alpha\); if negative, counter-clockwise.

After rotation, the solar panel should be horizontally aligned. Next, I compute the mean intensity of the whole binary image (the line image). Then, I scan from the leftmost column and the rightmost column inward. For each column, I compute its mean intensity. If the column mean is less than the global mean, this column is considered background and is removed. The scan stops when a column has a mean greater than or equal to the global mean. This process trims the background columns. Similarly, I scan from the top and bottom rows. After this correction, the remaining rectangle contains the solar panel with minimal background.

3.5 Hotspot Detection

After segmenting the solar panel, I detect defective hotspots inside it. In infrared images, hotspots have significantly higher intensity than the normal panel area, typically more than twice the average intensity. Therefore, I apply a threshold operation: pixels with intensity greater than 2 times the mean intensity of the solar panel region are considered candidate hotspots. To avoid false detections due to noise, I also require the area of the connected hotspot region to be less than one-thirtieth of the total panel area. If such regions exist, they are marked as defects.

4. Method 2: Saliency Detection and Skeleton Extraction Based Segmentation

The second method uses a different strategy. It exploits the fact that the boundaries of solar panels exhibit high gradient magnitudes. I compute a saliency map based on gradient features to emphasize the panel edges. In parallel, I compute a saliency map based on color features to identify the connecting rods between adjacent solar panels. Removing these rods helps avoid over-segmentation. After obtaining a clean edge map, I use adaptive thresholding and morphological operations to create binary masks. Then, skeleton extraction is used to thin the borders, which reduces the background area after dilation. Finally, I extract the contours and their minimum bounding rectangles to obtain the solar panel regions.

4.1 Gradient Magnitude Feature

For each pixel in the RGB image, I compute the horizontal and vertical gradients using Sobel operators. Let \(S_x\) and \(S_y\) be the Sobel kernels:

$$ S_x = \begin{bmatrix} -1 & 0 & +1 \\ -2 & 0 & +2 \\ -1 & 0 & +1 \end{bmatrix}, \quad S_y = \begin{bmatrix} +1 & +2 & +1 \\ 0 & 0 & 0 \\ -1 & -2 & -1 \end{bmatrix}. $$

For the red channel \(A_R\), the gradient components are \(G_x = S_x * A_R\) and \(G_y = S_y * A_R\). The gradient magnitude is \(G = \sqrt{G_x^2 + G_y^2}\). I compute this for all three channels and then take the sum or maximum across channels to obtain a combined gradient magnitude feature. Thisfeature highlights the edges of solar panels and other structures.

4.2 Saliency Detection Based on Gradient

Saliency detection determines how different a pixel is from all other pixels. Let \(G_k\) be the gradient magnitude at pixel \(k\). The saliency value \(S(G_k)\) is defined as the sum of distances between \(G_k\) and all other pixels’ gradient magnitudes:

$$ S(G_k) = \sum_{j=1}^{N} \| G_k – G_j \|, $$

where \(N\) is the total number of pixels. To reduce computation, I group identical gradient values. Suppose there are \(M\) distinct gradient values \(G^{(1)}, \dots, G^{(M)}\), with frequencies \(f_1, \dots, f_M\). Then the saliency for a pixel with gradient \(G^{(i)}\) is:

$$ S(G^{(i)}) = \sum_{j=1}^{M} f_j \, \| G^{(i)} – G^{(j)} \|. $$

This produces a gradient saliency map where the edges of solar panels have high values because they are different from the mostly flat interior and background.

4.3 Color Saliency and Removal of Connecting Rods

Connecting rods are the metallic frames that hold adjacent solar panels together. These rods have distinct thermal and color properties compared with the solar panel surface. To remove them, I compute a color saliency map based on the RGB pixel values. Let \(C_k\) be the vector of RGB values at pixel \(k\). The color saliency is:

$$ S_c(C_k) = \sum_{j=1}^{N} \| C_k – C_j \|_2. $$

To simplify, I use the same grouped computation as above. The color saliency map highlights regions with rare colors, which often correspond to connecting rods. Next, I perform thresholding with a fixed threshold \(T=180\). Pixels above this threshold are considered candidate rod regions. I then compute the average value of the thresholded binary image. If the average is less than 40, the high-saliency regions are considered to be connecting rods. I apply morphological dilation to fill holes in these rod regions. The final rod mask is subtracted from the gradient saliency map. The subtraction removes the connecting rods while preserving the solar panel boundaries. This step is crucial because connecting rods would otherwise be misinterpreted as panel edges.

4.4 Adaptive Thresholding

The resulting saliency map is a grayscale image. To convert it into a binary edge map, I use an adaptive thresholding method based on the integral image. For each pixel, I calculate the sum of intensities in a rectangular neighborhood around it. Let \(I(x,y)\) be the integral image. The sum in a rectangle defined by corners \((x_1,y_1)\) and \((x_2,y_2)\) is:

$$ \sum_{x=x_1}^{x_2} \sum_{y=y_1}^{y_2} I(x,y) = I(x_2,y_2) – I(x_2,y_1-1) – I(x_1-1,y_2) + I(x_1-1,y_1-1). $$

The adaptive threshold for pixel \((x,y)\) is:

$$ T(x,y) = \left(1 – \frac{t}{100}\right) \cdot \text{mean}(x,y) – C, $$

where \(\text{mean}(x,y)\) is the average intensity in the rectangular region, \(t\) is a percentage parameter (typically 15), and \(C\) is a constant. I set \(C = 9 + \alpha(\text{avg} – 40)\), where \(\alpha = 0.12\) and \(\text{avg}\) is the mean of the whole saliency map. This adaptive adjustment helps handle different noise levels. If the pixel intensity is less than \(T\), it is set to 1 (foreground); otherwise, it is 0 (background).

4.5 Morphological Operations and Skeleton Extraction

The binary edge map may have gaps and noise. I perform dilation to connect nearby edges into closed regions. However, dilation also thickens the edges, adding background pixels to the foreground. To reduce this effect, I apply skeleton extraction (also called thinning) to the binary image. The skeleton preserves the topological structure of the edges while reducing them to one-pixel-thin lines. The thinning algorithm iteratively removes border pixels that satisfy certain conditions. For a pixel \(P_1\) with its eight neighbors \(P_2, P_3, \dots, P_9\) arranged clockwise, two conditions are used:

  • Condition 1: \(2 \le B(P_1) \le 6\) and \(A(P_1) = 1\), where \(B(P_1)\) is the number of nonzero neighbors and \(A(P_1)\) is the number of 0-to-1 transitions in the ordered sequence \(P_2, P_3, \dots, P_9, P_2\).
  • Condition 2: Similar but with shifted positions to remove other boundary pixels.

After thinning, the contour lines become one pixel wide. This reduces the background area after dilation, leading to a more accurate segmentation.

4.6 Contour Extraction and Final Segmentation

From the skeleton image, I find all connected components. For each connected component, I calculate its area. If the area is greater than 10,000 pixels, I consider it a candidate for a solar panel boundary. The minimum enclosing rectangle of this component is then extracted. This rectangle corresponds to a solar panel region. By performing this for all valid components, I obtain the segmentation result.

5. Experimental Results

I evaluated both proposed methods on a dataset of UAV-captured infrared images of solar panels provided by a company. The dataset consists of images with varying numbers of solar panels, different backgrounds, and significant color nonuniformity. For quantitative evaluation, I manually labeled the ground truth for each image. I used eight performance metrics: Recall, Specificity, False Positive Rate (FPR), False Negative Rate (FNR), Overall Error Rate (PWCE), Precision, F-Measure, and Similarity. Their definitions are listed in the following table.

Table 1: Eight performance metrics used in the experiments.
Metric Formula Description
Recall (Re) \( \frac{TP}{TP+FN} \) Ratio of correctly detected foreground pixels to the real foreground.
Specificity (Sp) \( \frac{TN}{TN+FP} \) Ratio of correctly detected background pixels to the real background.
False Positive Rate (FPR) \( \frac{FP}{FP+TN} \) Ratio of background pixels incorrectly classified as foreground.
False Negative Rate (FNR) \( \frac{FN}{FN+TP} \) Ratio of foreground pixels incorrectly classified as background.
Overall Error Rate (PWCE) \( \frac{100 \cdot (FN+FP)}{TP+FN+FP+TN} \) Percentage of misclassified pixels over the whole image.
Precision (Pr) \( \frac{TP}{TP+FP} \) Ratio of correctly detected foreground among all detected foreground.
F-Measure (F1) \( \frac{2 \cdot Pr \cdot Re}{Pr+Re} \) Harmonic mean of precision and recall.
Similarity (Sim) \( \frac{TP}{TP+FN+FP} \) Jaccard-like similarity between detection and ground truth.

Here, TP, TN, FP, FN denote the numbers of true positive, true negative, false positive, and false negative pixels, respectively.

5.1 Comparison with State-of-the-Art Methods

I compared the two proposed methods (referred to as “Ours 1” for the line-based method and “Ours 2” for the saliency-based method) with GranCut, Level Set (LS), Sparse Field (SF), Graph-based segmentation (Graph), and a standard Saliency detection method. The following table shows the average performance metrics over the entire dataset.

Table 2: Performance comparison of different segmentation algorithms.
Method Re Sp FPR FNR PWCE Pr F1 Sim
Ours 1 (Line) 0.977 0.820 0.180 0.023 11.938 0.773 0.863 0.759
Ours 2 (Saliency) 0.889 0.933 0.067 0.111 8.574 0.904 0.896 0.812
GrabCut 0.582 0.677 0.323 0.418 35.910 0.530 0.555 0.384
LS 0.423 0.553 0.447 0.577 49.833 0.380 0.400 0.250
SF 0.961 0.809 0.191 0.392 13.247 0.759 0.848 0.736
Graph 0.574 0.855 0.145 0.426 25.523 0.720 0.639 0.469
Saliency 0.449 0.758 0.242 0.551 36.313 0.546 0.493 0.327

From the table, it is clear that both of my proposed methods outperform the others in terms of F-Measure and Similarity. The line-based method (Ours 1) achieves the highest recall (0.977), meaning it detects almost all solar panel regions without missing many. The saliency-based method (Ours 2) achieves the best precision (0.904) and the lowest overall error rate (8.574%), indicating that it includes very little background noise. This trade-off is expected: Ours 1 is better at finding all panels, while Ours 2 is better at obtaining clean boundaries.

5.2 Effectiveness of Each Step

I also performed ablation studies to verify the contribution of each key step. For the line-based method, I evaluated the effect of guided filter enhancement and K-means clustering. For the saliency-based method, I evaluated the effect of gradient feature, skeleton extraction, adaptive threshold adjustment, and connecting rod removal. The results are summarized in the following tables.

Table 3: Effect of different enhancement algorithms for the line-based method.
Enhancement Re Sp FPR FNR PWCE Pr F1 Sim
Guided filter 0.977 0.820 0.180 0.023 11.938 0.773 0.863 0.759
Dark channel 0.834 0.730 0.270 0.166 23.005 0.530 0.734 0.582
Retinex 0.550 0.832 0.168 0.450 27.644 0.672 0.605 0.434
No enhancement 0.827 0.708 0.292 0.173 24.623 0.639 0.721 0.564
Table 4: Effect of K-means clustering on line-based method.
Method Re Sp FPR FNR PWCE Pr F1 Sim
Ours 1 (with K-means) 0.977 0.820 0.180 0.023 11.938 0.773 0.863 0.759
Without K-means 0.994 0.650 0.350 0.006 21.752 0.640 0.779 0.637
Table 5: Ablation study for the saliency-based method.
Method Re Sp FPR FNR PWCE Pr F1 Sim
Ours 2 (full) 0.889 0.933 0.067 0.111 8.574 0.904 0.896 0.812
Without gradient feature 0.449 0.758 0.242 0.551 36.343 0.546 0.493 0.327
Without skeleton extraction 0.931 0.875 0.122 0.059 10.019 0.844 0.886 0.795
Without adaptive threshold tuning 0.873 0.858 0.142 0.126 13.548 0.814 0.843 0.728
Without rod removal 0.877 0.847 0.153 0.123 14.066 0.803 0.839 0.722

These ablation results demonstrate that each proposed module contributes positively to the overall performance. Specifically, the guided filter enhancement significantly improves recall, while K-means clustering improves precision. In the saliency-based method, the gradient feature is essential; without it, the performance drops dramatically. Skeleton extraction improves precision and reduces the overall error. Adaptive threshold tuning and rod removal also provide noticeable gains.

5.3 Runtime Analysis

Efficiency is important for practical applications. The following table lists the average processing time per image for each method. My line-based method is the fastest among the compared algorithms, while the saliency-based method is also competitive.

Table 6: Runtime comparison (in seconds per image).
Method Ours 1 Ours 2 GrabCut LS SF Graph Saliency
Time (s) 0.336 2.300 20.431 48.869 61.312 4.305 0.588

Although the saliency-based method is slower than the line-based method, it still runs faster than most classic algorithms and provides better segmentation quality. This makes it suitable for offline processing or applications where accuracy is prioritized over real-time speed.

6. Visualization Results

To visually demonstrate the effectiveness of my methods, I present example segmentation results. The images below illustrate the input infrared image and the output of the saliency-based segmentation. The red rectangles indicate the detected solar panel regions.

The figure shows that the proposed algorithm accurately delineates the solar panels even when the background has similar temperature patterns or when the panel surfaces have uneven color distributions. The segmentation boundaries closely match the actual panel edges, including the connecting frames between panels.

7. Conclusion and Future Work

In this thesis, I have studied the problem of segmenting solar panels from unevenly colored infrared images. I proposed two effective solutions: one based on guided filter enhancement and line detection, and the other based on gradient saliency detection and skeleton extraction. Both methods exploit the rectangular geometry of solar panels and are robust to color nonuniformity, blur, and noise. Extensive experiments demonstrated that my methods outperform several existing segmentation algorithms in terms of accuracy, precision, recall, and computational efficiency.

For future work, I plan to improve the algorithms in several directions. First, the line-based method relies on the assumption that panels have clear straight edges; this may fail for curved or tilted panels. I will investigate methods to handle more general shapes. Second, the saliency-based method is computationally expensive due to pixel-wise comparisons. I will explore approximate techniques to accelerate the saliency computation. Third, I intend to incorporate deep learning models to further improve the segmentation accuracy, especially for complex backgrounds and varying weather conditions. Finally, I will extend my methods to detect other types of defects, such as delamination and soiling, by combining multimodal data from visible and infrared cameras.

In conclusion, the proposed segmentation methods provide reliable foundations for automatic solar panel inspection, reducing the need for manual labor and enabling timely maintenance of photovoltaic systems. Accurate segmentation of solar panels is a critical step toward efficient defect detection and energy yield optimization.

Scroll to Top