Industrial detection image detail enhancement method
By converting RGB images into YUV images and performing nonlinear stretching, contrast-limited adaptive histogram equalization and bilateral filtering, the problems of noise and distortion in industrial inspection images are solved, and effective enhancement of image details and clear presentation of features are achieved.
Patent Information
- Application Number
- CN202510874580.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-27
- Publication Date
- 2025-09-30
AI Technical Summary
Existing technologies easily introduce noise and distortion into industrial inspection images, making it difficult to effectively enhance image details. Improper weighting also leads to image feature filtering or distortion.
After converting the RGB image to a YUV image, the image contrast and brightness are enhanced by nonlinear stretching of brightness, limiting contrast adaptive histogram equalization and bilateral filtering, combined with weighted superposition processing.
It significantly improves the contrast and brightness of the image, reduces color distortion, ensures a high signal-to-noise ratio, enhances the image feature recognition capability, and improves the reliability of the detection results.
Smart Images

Figure CN120725939A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image processing, and in particular to a method for enhancing details of industrial inspection images. Background Art
[0002] Image detail enhancement is a method that improves the visual quality of an image by processing specific image features (such as edges, contours, and contrast). Its purpose is to increase image clarity, highlight useful information, and compress useless information, making the image more suitable for human or computer analysis and processing.
[0003] However, traditional enhancement easily causes noise and high color distortion, often highlighting specific features of the image at the expense of color fidelity and image signal-to-noise ratio.
[0004] However, there are also some problems in the existing technology: 1. Refer to Chinese invention patent CN117173066A, an image enhancement algorithm based on multi-scale exposure fusion. This invention addresses the problem that traditional single-image enhancement technology is prone to under-enhancement or over-enhancement when processing low-light images. Over-enhancement can lead to saturation of image pixel values, amplifying background noise or distorting the image. Under-enhancement can lead to insufficient enhancement of edge and texture information, resulting in loss of image detail. Similarly, improper weighting can easily cause image features to be filtered out. 2. Refer to Chinese invention patent CN118941479A, which discloses a method, device, apparatus, and storage medium for enhancing blood vessel information in medical endoscopic images. The method includes obtaining a medical endoscopic image to be processed. The invention achieves image enhancement by superimposing multiple layers of images. However, such an enhancement method can easily lead to image distortion if the superposition weights between multiple layers of images are not properly controlled.
[0005] 3. Refer to Chinese invention patent CN110175964A, a Laplacian pyramid-based Retinex image enhancement method. This method includes the following three steps: First, multi-scale convolution is performed on the original image using three 3x3 Gaussian convolution kernels to obtain feature maps of the R, G, and B channels at different scales. However, the enhancement effect has been verified to be limited and cannot meet the high feature requirements of specific scenes.
[0006] Both files 1 and 2 above effectively process the image features, but improper weighting can easily lead to image distortion. The enhancement effect of file 3 is relatively limited. Therefore, a method for enhancing the details of industrial inspection images is needed to improve it. Summary of the Invention
[0007] The purpose of the present invention is to provide a method for enhancing details of industrial inspection images to overcome the deficiencies in the prior art.
[0008] To achieve the above object, the present invention provides the following technical solutions: This application discloses a method for enhancing details of industrial inspection images, comprising the following steps: S1: Get RGB image; S2: Convert RGB image to YUV image; S3: Perform nonlinear stretching on the brightness in the YUV image to obtain enhanced brightness; S4: performing detail enhancement processing on the chroma in the YUV image to improve the contrast and image quality of the image and obtain enhanced chroma; S5: Merge the enhanced chroma and the enhanced brightness to obtain an enhanced YUV image.
[0009] Preferably, the image is converted in S2 using a basic conversion formula from RGB to YUV.
[0010] Preferably, in said S3, nonlinear stretching is performed on the brightness in the YUV image, wherein the gamma values include: γ=1.1 Y∈(0,12); γ=1.5 Y∈(13,165); γ=0.65 Y∈(166,255).
[0011] In the low brightness range Y∈(0,12), a gamma value of γ=1.1 can moderately increase the brightness of dark areas, allowing previously imperceptible details to appear; in the medium brightness range Y∈(13,165), a gamma value of γ=1.5 can optimize the contrast of the main part of the image; in the high brightness range Y∈(166,255), a gamma value of γ=0.65 can prevent overexposure of bright details, thereby achieving fine-tuning of the overall brightness of the image.
[0012] Preferably, the S4 includes the following sub-steps: S41: performing contrast-limited adaptive histogram equalization on chroma U and V in the YUV image to obtain a chroma median value of one; S42: Perform bilateral filtering on the chroma U and V in the YUV image to obtain the second intermediate chroma value; S43: Perform weighted superposition on the chroma intermediate value 1 and the chroma intermediate value 2 to calculate and obtain enhanced chroma.
[0013] Preferably, the S41 includes the following sub-steps: S411: Divide the YUV image into several sub-blocks; S412: Setting a threshold and performing threshold determination on pixels of each sub-block; S413: When the value of a pixel exceeds the threshold, the excess portion is evenly distributed to other color levels, and the histogram of each sub-block is equalized.
[0014] Preferably, in order to avoid discontinuity at sub-block boundaries, the contrast-limited adaptive histogram equalization uses a bilinear interpolation method to smooth the processed image.
[0015] Preferably, the S42 includes the following sub-steps: S421: Taking one pixel as the center, weight the spatial positions of the pixels around it to obtain a spatial proximity weight, where the closer the pixel is, the greater the weight; S422: Taking the current pixel as the center, identify the similarity between it and the surrounding pixels, and obtain the pixel value similarity weight, where the more similar the pixel, the greater the weight; S423: According to the spatial proximity weight and the pixel value similarity weight, a final weight coefficient is comprehensively obtained, and the second chromaticity intermediate value is calculated.
[0016] The present application also discloses an industrial inspection image detail enhancement device, comprising a memory and one or more processors, wherein the memory stores executable code, and when the one or more processors execute the executable code, they are used to implement the above-mentioned industrial inspection image detail enhancement method.
[0017] The present application also discloses a computer-readable storage medium having a program stored thereon. When the program is executed by a processor, the above-mentioned method for enhancing details of industrial inspection images is implemented.
[0018] Beneficial effects of the present invention: (1) Through nonlinear stretching under Y and contrast-limited adaptive histogram equalization under U and V, bilateral filtering and weighted superposition processing, the specific features of the image are effectively highlighted, the contrast and brightness of the image are significantly improved, and it is convenient for detection personnel or detection equipment to accurately identify; (2) While enhancing image details, the present invention reduces color distortion, ensures a high signal-to-noise ratio of the image, and can clearly present features such as shape and color without color deviation, thereby improving the reliability of the detection results.
[0019] The features and advantages of the present invention will be described in detail through embodiments with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] Figure 1 This is a flowchart of the steps of a method for enhancing image details in industrial inspection according to the present invention; Figure 2 It is a schematic diagram of the device of the present invention. DETAILED DESCRIPTION
[0021] To make the objectives, technical solutions, and advantages of the present invention more clearly understood, the present invention is further described in detail below with reference to the accompanying drawings and examples. However, it should be understood that the specific embodiments described herein are merely illustrative of the present invention and are not intended to limit the scope of the present invention. In addition, in the following description, descriptions of well-known structures and technologies are omitted to avoid unnecessary confusion of the present invention.
[0022] See Figure 1 , an embodiment of the present invention provides a method for enhancing details of industrial inspection images, comprising the following steps: Step S0: Acquire an RGB image.
[0023] Step S1: Convert the RGB image into a YUV image according to the RGB to YUV formula, where the RGB to YUV formula is: Step S2: Perform nonlinear stretching on Y to obtain brightness , where the nonlinear stretching formula is: Step S3: Perform contrast-limited adaptive histogram equalization on U and V to obtain 、 , where the contrast-limited adaptive histogram equalization is to divide the image into blocks, calculate the cumulative distribution function, and then crop it and equalize the image in the block; Specifically, the image is divided into blocks, which divide the input image into non-overlapping sub-blocks of equal size. The number of pixels in each sub-block is M*M, and the statistical cumulative distribution function is set to a threshold ,If the value of a pixel exceeds the threshold, the excess part will be "clipped", that is, evenly distributed to other color levels. After contrast limitation, the histogram of each sub-block is equalized; The basic idea of histogram equalization is to adjust the pixel value distribution of an image to a uniform distribution through a transformation function, thereby enhancing the contrast of the image. In contrast-constrained adaptive histogram equalization, the cumulative distribution function (CDF) is usually used to implement histogram equalization. By calculating the cumulative frequency of each color class and mapping it to a new pixel value range, the image is processed in blocks. In order to avoid discontinuities at the sub-block boundaries, limited contrast adaptive histogram equalization uses bilinear interpolation to smooth the processed image. Bilinear interpolation calculates the final pixel value of each pixel by taking a weighted average of the processing results of adjacent sub-blocks.
[0024] in Take 1.8-2.1, specifically 2.0, and M is 8.
[0025] Step S4: Perform bilateral filtering on U and V to obtain 、 , where bilateral filtering adds a pixel value weight term to Gaussian filtering, that is, it takes into account both the distance factor and the influence of pixel value differences. The closer the pixel values, the greater the weight. Specifically, bilateral filtering spatially defines a weight function similar to a Gaussian kernel. This function weights the spatial positions of surrounding pixels, centered around the current pixel. Pixels closer to the current pixel receive a larger weight, while pixels farther away receive a smaller weight. Furthermore, a Gaussian function based on pixel value differences is used to measure the similarity between the current pixel and its surrounding pixels. If the grayscale or color values of surrounding pixels differ slightly from the current pixel, indicating a greater image content similarity, these pixels are assigned a larger weight. Conversely, if the differences are large, the weights are smaller. For each pixel in the image, bilateral filtering calculates the weighted average of the pixels in its surrounding neighborhood as the filtering result. Specifically, the spatial proximity weight function and the pixel value similarity weight function are multiplied together to obtain a combined weight coefficient. This weight coefficient is then used to weight the sum of the pixel values in the neighborhood. The sum is then divided by the sum of the weight coefficients to obtain the current pixel value.
[0026] Specifically, referring to the table below, the Gaussian kernel is a 3*3 matrix operation template, and the Gaussian kernel coefficient is: Step S5: and Obtained by weighted superposition , 、 Obtained by weighted superposition , where the weighted superposition formula is: in Take 0.9, Take 0.85.
[0027] Step S6: Merge 、 、 Output YUV image.
[0028] An embodiment of an industrial inspection image detail enhancement device of the present invention can be applied to any device with data processing capabilities, and the device with data processing capabilities can be a device or apparatus such as a computer. The device embodiment can be implemented through software, or through hardware or a combination of software and hardware. Taking software implementation as an example, as a device in a logical sense, it is formed by the processor of any device with data processing capabilities in which it is located reading the corresponding computer program instructions in the non-volatile memory into the memory for execution. From the hardware level, if Figure 2 As shown in the figure, it is a hardware structure diagram of any device with data processing capability where an industrial inspection image detail enhancement device of the present invention is located. Figure 2 In addition to the dedicated chip, on-chip bus, MIPI interface, memory, and non-volatile memory shown, any device with data processing capabilities in which the apparatus in the embodiment is located may also include other hardware, depending on the actual function of the device with data processing capabilities, which will not be described in detail here. The implementation process of the functions and effects of each unit in the above-mentioned apparatus is specifically detailed in the implementation process of the corresponding steps in the above-mentioned method, and will not be described in detail here.
[0029] For the device embodiments, since they basically correspond to the method embodiments, the relevant parts can be referred to the partial description of the method embodiments. The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the present invention. A person of ordinary skill in the art can understand and implement the present invention without inventive work.
[0030] 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 or improvements made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.
Claims
1. A method for enhancing image details in industrial inspection, characterized by: The steps include: S1: Get RGB image; S2: Convert RGB image to YUV image; S3: Perform nonlinear stretching on the brightness in the YUV image to obtain enhanced brightness; S4: performing detail enhancement processing on the chroma in the YUV image to improve the contrast and image quality of the image and obtain enhanced chroma; S5: Merge the enhanced chroma and the enhanced brightness to obtain an enhanced YUV image.
2. The method for enhancing details of industrial inspection images according to claim 1, wherein: In S2, the image is converted using the basic conversion formula from RGB to YUV.
3. The method for enhancing details of industrial inspection images according to claim 1, wherein: In the S3, nonlinear stretching is performed on the brightness of the YUV image, wherein the gamma values include: γ=1.1 Y∈(0,12); γ=1.5 Y∈(13,165); γ=0.65 Y∈(166,255).
4. The method for enhancing details of industrial inspection images according to claim 1, wherein: The S4 includes the following sub-steps: S41: performing contrast-limited adaptive histogram equalization on chroma U and V in the YUV image to obtain a chroma median value of one; S42: Perform bilateral filtering on the chroma U and V in the YUV image to obtain the second intermediate chroma value; S43: Perform weighted superposition on the chroma intermediate value 1 and the chroma intermediate value 2 to calculate and obtain enhanced chroma.
5. The method for enhancing details of industrial inspection images according to claim 4, wherein: The S41 includes the following sub-steps: S411: Divide the YUV image into several sub-blocks; S412: Setting a threshold and performing threshold determination on pixels of each sub-block; S413: When the value of a pixel exceeds the threshold, the excess portion is evenly distributed to other color levels, and the histogram of each sub-block is equalized.
6. The method for enhancing details of industrial inspection images according to claim 4, wherein: In order to avoid discontinuities at sub-block boundaries, contrast-constrained adaptive histogram equalization uses a bilinear interpolation method to smooth the processed image.
7. The method for enhancing details of industrial inspection images according to claim 4, wherein: The S42 includes the following sub-steps: S421: Taking one pixel as the center, weight the spatial positions of the pixels around it to obtain a spatial proximity weight, where the closer the pixel is, the greater the weight; S422: Taking the current pixel as the center, identify the similarity between it and the surrounding pixels, and obtain the pixel value similarity weight, where the more similar the pixel, the greater the weight; S423: According to the spatial proximity weight and the pixel value similarity weight, a final weight coefficient is comprehensively obtained, and the chromaticity intermediate value 2 is calculated.
8. An industrial inspection image detail enhancement device, characterized by: The system comprises a memory and one or more processors, wherein the memory stores executable code, and when the one or more processors execute the executable code, the system is used to implement the method for enhancing details of industrial inspection images according to any one of claims 1 to 7.
9. A computer-readable storage medium, characterized in that: A program is stored thereon, and when the program is executed by a processor, an industrial inspection image detail enhancement method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Image color processing element and method
CN102026004A
System and method for removing image chroma noise with reference to multi-channel multi-resolution
CN110246087A
Method and apparatus for cross-component adaptive loop filter for video coding
CN114710977A
Low-illumination image enhancement method
CN114998122A
Single underwater image enhancement method based on contrast stretching and fusion
CN118195976A