Enhancing the Quality of Low-Light Printed Circuit Board Images through Hue, Saturation, and Value Channel Processing and Improved Multi-Scale Retinex

Abstract

To address the issue of deteriorated PCB image quality in the quality inspection process due to insufficient or uneven lighting, we proposed an image enhancement fusion algorithm based on different color spaces. Firstly, an improved MSRCR method was employed for brightness enhancement of the original image. Next, the color space of the original image was transformed from RGB to HSV, followed by processing the S-channel image using bilateral filtering and contrast stretching algorithms. The V-channel image was subjected to brightness enhancement using adaptive Gamma and CLAHE algorithms. Subsequently, the processed image was transformed back to the RGB color space from HSV. Finally, the images processed by the two algorithms were fused to create a new RGB image, and color restoration was performed on the fused image. Comparative experiments with other methods indicated that the contrast of the image was optimized, texture features were more abundantly preserved, brightness levels were significantly improved, and color distortion was prevented effectively, thus enhancing the quality of low-lit PCB images.

Share and Cite:

Shang, H. , Li, P. and Peng, X. (2024) Enhancing the Quality of Low-Light Printed Circuit Board Images through Hue, Saturation, and Value Channel Processing and Improved Multi-Scale Retinex. Journal of Computer and Communications, 12, 1-10. doi: 10.4236/jcc.2024.121001.

1. Introduction

In the field of computer vision research, low-light image enhancement has been a long-standing focal point for researchers. The examination of image enhancement technology relying on PCB circuit boards is pivotal in domains such as image classification, segmentation, and recognition. Consequently, image enhancement assumes a crucial role in these facets. Throughout the developmental history of the PCB industry, experts and scholars have identified various classical methods for enhancing low-light images, employing algorithms based on spatial and frequency domains [1] . Among these, scholars like Jobson developed the Retinex algorithm to address different factors influencing low-light images, designed to maintain a consistent sense of color perception akin to the human eye [2] . However, traditional Retinex algorithms are prone to blurring and halo effects. In recent years, the Retinex algorithm has undergone a series of improvements. Wang and his team addressed issues faced by traditional Retinex image enhancement algorithms, such as insufficient preservation of texture details and abrupt changes in hue [3] . They proposed an enhancement algorithm for dark regions under complex conditions, using an improved Gabor algorithm. The processed image exhibits rich colors, closer to the original image, significantly reducing color distortion and over-enhancement during the image processing. This paper will delve into some widely recognized, significantly advantageous low-light image enhancement methods. It also explores low-light image enhancement methods that demonstrate greater applicability than previous ones. These methods not only preserve the original image information but also significantly enhance the brightness of low-light images, contributing to the improvement of image quality.

2. Fundamental Theory

2.1. HSV Color Space

In digital image processing, color image enhancement plays a crucial role. This process involves adjusting the brightness and color of a color image to meet human perception needs. Compared to grayscale images, color images contain richer information. RGB and HSV are two widely used color spaces for representing colors. In these two, there is a close correlation between the RGB components, and processing them separately may lead to image distortion, making it unsuitable for independent enhancement. The HSV space comprises three channel components: hue, saturation, and value. Hue dictates the color inclination toward red, green, or blue, and diverse hue ranges yield distinct colors. Saturation directly affects the color of the image, with deeper colors indicating higher saturation and vice versa. The brightness of the image is closely related to its luminance. In the HSV space, the advantage lies in the ability to separate the luminance component and color information, making it more conducive for observers [4] . HSV finds extensive applications in image enhancement, color selection, segmentation, and more. Therefore, choosing the HSV color space is beneficial for low-light PCB image enhancement [5] .

2.2. Retinex Algorithm

The core concept of the Retinex theory lies in the idea that an object’s color is not solely confined to the values of reflected light intensity but varies with the amount of light it receives [6] . This theory aims to ensure color consistency for objects under uneven lighting conditions, providing color constancy. Retinex can achieve a stable state in the presence of non-uniform characteristics, such as compressing the range of abnormal features, enhancing image edges, and stabilizing colors. Therefore, it can adaptively enhance various types of images [7] [8]. Its primary task is to preserve image details and textures while adjusting the brightness and contrast of the image. The Retinex algorithm is implemented through three primary methods: Single-Scale Retinex (SSR), Multi-Scale Retinex (MSR), and Multi-Scale Retinex with Color Restoration (MSRCR). The resulting image can be represented by the following formula, where the expression is analogous to Formula (1):

I ( x , y ) = L ( x , y ) R ( x , y ) (1)

In this context, I ( x , y ) represents the received signal, L ( x , y ) is the illuminance from the ambient light, and R ( x , y ) denotes the reflectance of the target object carrying the image features. Due to certain limitations of the Single-Scale Retinex (SSR) algorithm in restoring high-frequency components of images, the Multi-Scale Retinex (MSR) algorithm was proposed. It aims to perform filtering operations on low, medium, and high spatial frequency scales of the source image. The reflectance image obtained using the MSR algorithm can be expressed by Formula (2):

r ( x , y ) = i = 1 n ω i { log I ( x , y ) log [ g i ( x , y ) I ( x , y ) ] } (2)

In the formula, g i represents the Gaussian surround function at different scales with other conditions being the same; n is the difference in the number of functions, typically set to n = 3; ω is the weight coefficient in the algorithm, usually set to 1/3. The Multi-Scale Retinex (MSR) algorithm may introduce color distortion as it doesn’t consider the intrinsic relationships between the RGB channels. There is a close correlation between the RGB components, and processing them independently can lead to image deformation, making it unsuitable for standalone image enhancement. To tackle this problem, the Multi-Scale Retinex with Color Restoration (MSRCR) algorithm, which incorporates color restoration functionality, was introduced. It is referred to as the MSRCR algorithm. To mitigate color distortion, a color restoration factor C i is introduced. By adjusting the variation of the color restoration factor C, the MSR algorithm’s proportion is changed to restore it to the original proportion values, thereby achieving color compensation and resolving color distortion phenomena. The mathematical expression for the MSRCR algorithm is given by Formula (3):

r M S R C R i ( x , y ) = C i ( x , y ) r M S R i (3)

3. The Algorithm in This Paper

3.1. Conversion between RGB Space and HSV Space

To convert an image to the HSV space, it is necessary to first transform the color in the RGB space. Therefore, colors defined by (h, s, v) are closely related to the colors in the RGB image. The colors correspond differently in various channels, with RGB color space and HSV color space being numerically equivalent [9] . The conversion relationship can be mathematically expressed by Equations (4)-(6). Where (r, g, b) are the components of the corresponding color channels, and the maximum (max) and minimum (min) values of the RGB image are maintained consistently [10] . The formula for RGB to HSV conversion is as follows:

H = COS 1 { ( R G ) + ( R B ) 2 [ ( R G ) 2 + ( R B ) ( R G ) 2 ] } 360 (4)

S = 1 3 R + G + B [ min ( R , G , B ) ] (5)

V = 1 3 ( R + G + B ) (6)

3.2. Bilateral Filtering and Its Characteristics

As a non-linear filter, the core of bilateral filtering involves processing the internal structure of the target image by compromising the similarity of its pixels. It also considers factors like grayscale similarity to achieve edge-preserving denoising. Bilateral filtering exhibits significant advantages, especially in enhancing the edge processing of images. In contrast to traditional approaches such as the Retinex algorithm, which typically uses Gaussian filtering functions to enhance local features of images, bilateral filtering excels in preserving details without introducing the noise that can lead to local blurring. Therefore, this paper opts for the bilateral filtering function, known for its strong detail-preserving capabilities, to replace the original Gaussian function in the algorithm. The formula is given by (7):

f ( x , y ) = ( i , j ) S x , y ω s ( i , j ) ω r ( i , j ) I ( i , j ) ( i , j ) S x , y ω s ( i , j ) ω r ( i , j ) ­ (7)

In the formula, S x , y represents the central pixel and its neighborhood, I ( i , j ) denotes different pixels in the neighborhood, ω s is the spatial similarity factor, and ω r is the intensity similarity factor. The expressions for the similarity factors are given by (8)-(9):

ω s ( i , j ) = 1 2 π σ s exp [ ( x x c ) 2 + ( y y c ) 2 2 σ s 2 ] (8)

ω r ( i , j ) = 1 2 π σ r exp { [ I ( x , y ) I ( x c , y c ) ] 2 2 σ r 2 } (9)

In the formula, σ s and σ r are scale factors.

3.3. Improved MSRCR Algorithm

The central surrounding function in the traditional Retinex algorithm is typically a Gaussian filter. However, when using Gaussian filtering to process images, halo phenomena may occur. This phenomenon arises because in a Gaussian filter, as the distance between neighboring pixels decreases, their relationship becomes closer; conversely, as the distance increases, their relationship becomes more distant. This situation results in the phenomenon of blurred edges in the image. To address this issue, in the theoretical framework of Gaussian filtering, the more characteristic bilateral filtering is incorporated to aim at preserving the edge features of the image. Bilateral filtering considers differences in both value and spatial domains. By enhancing the details of the image while simultaneously achieving edge denoising, bilateral filtering can effectively eliminate halo phenomena. In this paper, bilateral filtering is introduced as a new central surrounding function in the MSR algorithm with color restoration, replacing the Gaussian filter that was originally used in the traditional algorithm. This change aims to improve the experimental results of the image, particularly by reducing the occurrence of color over-enhancement while preserving detailed information.

3.4. Saturation Enhancement Algorithm Based on Contrast Stretching

In the HSV color space, when the hue (H parameter) remains constant, the parameters of saturation and brightness are crucial for the quality of an image. However, increasing brightness alone may lead to certain color distortions in the image. It is necessary to process the image’s saturation [11] . To make the edges of the image clearer, optimization of the processed saturation (S channel) is essential. Due to insufficient or uneven illumination intensity, low-light color images not only darken the image and blur details but also result in a decrease in color depth and saturation. In the process of image enhancement, excessive enhancement of image brightness may lead to color distortion. To avoid this phenomenon, linear stretching of contrast should be performed [12] [13] [14] , adjusting pixel values to the [0, 255] range. The mathematical expression for contrast stretching is given by (10):

I ( x , y ) = I ( x , y ) Imin Imax Imin ( MAX MIN ) + MIN (10)

The minimum and maximum values in the grayscale space following the algorithmic stretching process are referred to as min and max.

3.5. Basic Workflow of the Algorithm in This Paper

The In our paper, we propose a novel algorithm for enhancing low-light images by jointly processing them in the HSV channel and the RGB space using the Retinex algorithm. The improved algorithm follows these steps: Step: 1 involves the application of an improved MSRCR image enhancement algorithm to the initial RGB image, highlighting its impact on details, including edges. In Step 2, the original image undergoes processing in the HSV space, achieved by segregating the RGB image into three channels and subsequently transforming it into the HSV space. Step 3: Optimize the image collected by its S channel using an improved bilateral filtering, followed by saturation stretching transformation. Finally, normalize the processed components. Step 4: Apply adaptive gamma correction to the brightness channel (V component) to correct the enhanced image. While effectively retaining image information, this step achieves the purpose of image correction. Further enhance brightness using the CLAHE algorithm. Step 5: Reconstruct the optimized HSV image by combining the optimized S channel, V channel, and the unchanged H channel. Convert the result back to an RGB image. Step 6: Fuse the two sets of enhanced RGB images to generate the final image. The workflow of the algorithm is illustrated in Figure 1.

4. Experimental Results and Analysis

During the experiment, low-light images from different scenarios were processed using single-scale, multi-scale Retinex algorithms, HE algorithm, a thorough recapitulation of the processing outcomes was performed in accordance with the algorithm introduced in this paper. Conducted within the Visual Studio 2019 environment, the experiment employed C++ as the programming

Figure 1. Workflow diagram.

language and was implemented using OpenCV 3.4.1. The objective was to evaluate the proposed algorithm’s effectiveness, employing three low-light PCB images to highlight its performance across challenging environmental conditions and diverse object characteristics. Results were compared for different types of images, as shown in Figure 2, and subjected to both subjective and objective analysis and evaluation.

4.1. Subjective Evaluation

From a subjective analytical standpoint, the image processed by the algorithm outlined in this paper demonstrates a discernible enhancement in overall brightness and heightened contrast when juxtaposed with the original image. More detailed information is noted to be richer, especially in annotated areas such as circuit lines. In contrast to the other four algorithms, the algorithm presented in this paper significantly amplifies the overall brightness of the PCB circuit board, thereby rendering the details on the distant circuit board more prominent. For the PCB circuit board, contrast is improved, and the patterns become clearer after processing with the algorithm in this paper. In line with human visual characteristics, components and other parts become brighter, revealing more detailed information. It’s noteworthy that the color representation of the circuit board almost remains distortion-free after processing with the algorithm in this paper, and the colors are closer to the original. In contrast, after enhancement with different algorithms, while component images are improved, there is noticeable detail blurring and image-wide distortion. Images processed with the MSRCR algorithm exhibit improved contrast but reveal instability in color processing. This highlights the effectiveness of the algorithm in this paper in enhancing low-light images, preserving and presenting more image features.

4.2. Objective Evaluation

Subjective evaluation involves the observer’s intuitive visual perception and relies on multiple evaluation criteria or individual experience. Its main drawback

Figure 2. Comparison of experimental results.

is the lack of consistency. In contrast, objective evaluation adopts a consistent assessment method, resulting in higher stability of results. In this study, the enhancement effects of low-light images were objectively evaluated using multiple evaluation indicators. Primarily, the standard deviation serves as an indicator of the spread of pixel values from the mean, illustrating the distribution of pixel values within the image. A higher standard deviation indicates better image quality, suggesting greater overall differences in brightness and color, potentially leading to a richer and more detailed perception for observers. Secondly, the average gradient is an indicator of image sharpness and texture variation. A higher average gradient value indicates richer texture features, making the image easier to identify and clearer, reflecting more pronounced changes in local regions of the image. Finally, the gray value reflects the overall brightness of the processed image. A higher gray value corresponds to higher brightness. Increasing the gray value during image enhancement helps improve the brightness contrast of the image, making it easier to observe and understand. Through these objective evaluation indicators, we can comprehensively understand the performance of low-light image enhancement methods in different aspects, providing better guidance for optimizing and improving image processing. For the three groups of image enhancement results using different algorithms, this paper conducts objective analysis using the aforementioned evaluation indicators. Specific results can be found in Tables 1-3. From Table 1, it can be concluded that the standard deviation improvement of the three groups of images enhanced by the algorithm in this paper is superior to other algorithms, highlighting a significant improvement

Table 1. Standard deviation comparison of algorithms.

Table 2. Mean value comparison of algorithms.

Table 3. Average gradient comparison of algorithms.

in the quality of the original images. Table 2 shows that the algorithm in this paper maintains a high level of image mean values, successfully enhancing the brightness of low-light images. The average gradient in Table 3 more intuitively illustrates the significant optimization effect of this algorithm on clarity.

5. Conclusion and Analysis

In response to the significant variations in brightness and issues such as uneven lighting and loss of image texture in low-light PCB images, this study proposes a Retinex-based image enhancement algorithm in both HSV and RGB color spaces. The effectiveness of the algorithm in processing low-light images is evident, as the enhanced images show a reduction in color distortion, improved brightness, enhanced contrast, reduced glare, and strengthened low-light PCB images for industrial production and application. This contributes to an overall improvement in image quality, aligning more with human visual perception. Experimental results indicate that compared to traditional image enhancement algorithms, this study’s algorithm achieves favorable results in both subjective and objective evaluations, significantly enhancing the quality of low-light PCB images with richer texture feature preservation. Despite its success, the algorithm exhibits some shortcomings, such as slightly longer processing times and instability in handling images under more complex environmental conditions. Therefore, future research in low-light image algorithms should consider additional environmental factors to maintain algorithm efficiency and stability, especially when dealing with low-light images containing various noise types. Hence, further exploration in this field is essential, contributing to the advancement of technology for the betterment of human life.

Conflicts of Interest

The authors declare no conflicts of interest regarding the publication of this paper.

References

[1] Ji, P., Hu, X.Y. and Zhang, R.Q. (2021) Research on Image Enhancement Technology Based on Histogram Equalization Algorithm. Journal of Bengbu College, 10, 40-43.
[2] Rahman, Z., Jobson, D.J. and Woodell, G.A. (2004) Retinex Processing for Automatic Image Enhancement. Journal of Electronic Imaging, 13, 100-110.
https://doi.org/10.1117/1.1636183
[3] Parihar, A.S. and Singh, K. (2018) A Study on Retinex Based Method for Image Enhancement. 2018 2nd International Conference on Innovative Systems and Control (ICISC), Coimbatore, 19-20 January 2018, 619-624.
https://doi.org/10.1109/ICISC.2018.8398874
[4] Zhang, L.Y., Hao, B.N., Meng, Q.Y., et al. (2020) Improved Fusion Retinex Algorithm Based on HSV Space for Underground Image Enhancement. Journal of China Coal Society, 45, 532-540.
[5] Jobson, D.J., Rahman, Z. and Woodell, G.A. (1997) Properties and Performance of a Center/Surround Retinex. IEEE Transactions on Image Processing, 6, 451-462.
https://doi.org/10.1109/83.557356
[6] Turan, B. (2021) An Image Enhancement Method for Night-Way Images. Balkan Journal of Electrical and Computer Engineering, 9, 8-16.
https://doi.org/10.17694/bajece.802855
[7] Zotin, A.G. (2020) Fast Algorithm of Image Enhancement Based on Multi-Scale Retinex. International Journal of Reasoning-Based Intelligent Systems, 12,106-116.
https://doi.org/10.1504/IJRIS.2020.106804
[8] Jiang, Y.F., Gong, X.Y., Liu, D., et al. (2021) EnlightenGAN: Deep Light Enhancement without Paired Supervision. IEEE Transactions on Image Processing, 30, 2340-2349.
https://doi.org/10.1109/TIP.2021.3051462
[9] Qin, X.J., Cheng, Y.F., Fan, Y.L., et al. (2016) HSV Color Space Retinex Image Enhancement Algorithm Based on Triangular Filtering. Journal of Small & Micro Computing Systems, 37, 168-172.
[10] Oh, J.G. and Hong, M.C. (2019) Adaptive Image Rendering Using a Nonlinear Mapping Function-Based Retinex Model. Sensors, 19, Article 969.
https://doi.org/10.3390/s19040969
[11] Cao, C.C., Gong, S.R., Zhou, L.F., et al. (2022) Video Smoke Detection Based on HSV Color Space Features. Computer Technology and Development, 32, 171-175.
[12] Wang, H.Y., Yin, W.R., Wang, L., et al. (2019) Fast Edge Extraction Algorithm Based on HSV Color Space. Journal of Shanghai Jiao Tong University, 53, 765-772.
[13] Wang, Y.L. and Zhang, J. (2018) Single-Scale Retinex Color Image Enhancement Algorithm Based on Improved Imaging Model. Computer Engineering and Design, 39, 3511-3515.
[14] Su, K.Y., Wang, X.G. and Liu, G.M. (2022) Research on Image Enhancement of Uneven Illumination Based on Improved Retinex Algorithm. Laser Journal, 43, 103-108.

Copyright © 2024 by authors and Scientific Research Publishing Inc.

Creative Commons License

This work and the related PDF file are licensed under a Creative Commons Attribution 4.0 International License.