Image enhancement method, device, equipment and storage medium based on bilateral filtering
The image enhancement method addresses bilateral filtering limitations by converting to grayscale, performing wavelet decomposition, and using adaptive parameters to maintain edge information and improve image quality.
Patent Information
- Application Number
- CN202410577514.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-10
- Publication Date
- 2024-12-06
- Estimated Expiration
- 2044-05-10
AI Technical Summary
Bilateral filtering methods face limitations in processing large homogeneous areas, leading to halos, grayscale, and whitening due to manually set parameters and the assumption of spatial similarity among adjacent pixels, which results in blurred edges and poor image processing effects.
An image enhancement method that includes converting an input image to grayscale, performing wavelet decomposition, bilateral filtering on low-frequency components, logarithmic domain transformation, and adaptive parameter adjustment using high-frequency coefficient thresholds to maintain edge information and avoid halos and grayscale.
The method effectively suppresses noise while preserving edge information, achieving improved image processing effects by adaptively adjusting parameters and avoiding halos and grayscale through wavelet reconstruction.
Smart Images

Figure CN118485580B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of image processing, and in particular relates to an image enhancement method and device, equipment and storage medium based on bilateral filtering. Background Art
[0002] In the process of image acquisition, transmission and storage, due to various unfavorable factors, quality degradation often occurs, resulting in information loss, which brings huge challenges to subsequent image processing and analysis. Image enhancement is one of the contents of image processing. It is a processing technology that improves the readability of images, that is, the processing of improving the visual effect of images using computers or optical equipment.
[0003] One of the ways to enhance images is image denoising, which can be used to solve the problem of image quality degradation due to noise interference. Denoising technology can effectively improve image quality, increase the signal-to-noise ratio, and better reflect the information carried by the original image.
[0004] Bilateral filtering is a spatial domain nonlinear filtering denoising method commonly used to preserve image edges. Different from the previous smoothing filter, bilateral filtering mainly uses the spatial proximity of pixels in the neighborhood and the similarity of pixel values to construct a Gaussian weighted filter. The algorithm was proposed by Tomasi et al. and has a wide range of applications in image processing, such as denoising, demosaicing, streamer estimation, etc.
[0005] Bilateral filtering has the ability to preserve image edges while filtering out noise. It can address the limitations of wavelet transform in processing images with rich texture information. It preserves edge information while removing noise and smoothing images. For example, Deng et al. proposed an image retrieval method that removes noise, smoothes images, and preserves edge information. Luo et al. proposed an improved bilateral filtering and average correction image enhancement algorithm to enhance the contrast and clarity of images.
[0006] However, bilateral filtering may not perform well when processing large homogeneous areas. The preset parameters of traditional filtering and edge preservation produce halos in images with complex noise similar to edge pixels due to significant differences in image brightness. Moreover, traditional filtering methods generally only consider the spatial domain and assume that adjacent pixels should have similar characteristics. This assumption does not hold true at the edges of the image. If filtering is still done in this way, the edges will inevitably be blurred, resulting in grayscale or whitening. In addition, the parameters in traditional bilateral filtering are manually set and may not be suitable for large databases.
[0007] In summary, bilateral filtering, as a nonlinear filtering technology, can effectively suppress noise while protecting image edge information. However, it has the limitation of manually setting parameters and defects such as halo, grayscale, and whitening, which lead to poor image processing effect. Summary of the invention
[0008] The purpose of the present invention is to provide an image enhancement method and device, equipment, and storage medium based on bilateral filtering, which can realize adaptive parameter adjustment and eliminate halo, grayscale, whitening and other phenomena, thereby improving image processing effects.
[0009] The first aspect of the present invention discloses an image enhancement method based on bilateral filtering, comprising:
[0010] Converting an input image into a grayscale image, and determining a noisy image based on the grayscale image;
[0011] Performing wavelet decomposition on the noisy image to obtain a high-frequency component and a low-frequency component of the noisy image;
[0012] Performing bilateral filtering on the low-frequency component to obtain a filtered image;
[0013] Performing a logarithmic domain transformation on the filtered image to obtain a first reflected image;
[0014] stretching the first reflected image into a specified range to obtain a second reflected image;
[0015] According to the high frequency component, a high frequency coefficient threshold is calculated;
[0016] According to the high-frequency coefficient threshold, the high-frequency component is processed to obtain a target high-frequency component;
[0017] Wavelet reconstruction is performed according to the second reflected image and the target high-frequency component to obtain an output image.
[0018] In some embodiments, determining a noisy image according to the grayscale image includes:
[0019] Calculating a histogram of the grayscale image, and dividing the histogram into at least two sub-histograms;
[0020] Determine whether each sub-histogram needs to be equalized one by one;
[0021] If all sub-histograms do not need to be equalized, the grayscale image is determined to be a noisy image;
[0022] If there is at least one sub-histogram that needs to be equalized, determine the target sub-histogram that needs to be equalized, and after equalizing each target sub-histogram respectively, merge them according to the pixel position to obtain the overall image after equalization; determine the overall image as a noisy image.
[0023] In some embodiments, the histogram is divided into at least two sub-histograms, comprising:
[0024] Calculating the first-order derivative of each gray level in the histogram using a difference method, judging whether each gray level is an extreme point according to the first-order derivative, and obtaining a judgment result of each gray level;
[0025] Determine at least three local maxima according to the judgment results of each gray level;
[0026] According to at least three local maxima, segmenting the histogram to obtain at least two segmentation intervals;
[0027] Each of the segmented intervals is mapped to a new dynamic interval, and a sub-histogram corresponding to each of the dynamic intervals is obtained.
[0028] In some embodiments, determining whether each sub-histogram needs to be equalized includes:
[0029] Calculate the probability density of each gray level of each subhistogram;
[0030] If the difference between the probability densities of any two gray levels of the sub-histogram is less than or equal to the specified threshold, it is determined that the sub-histogram does not need to be equalized;
[0031] If the difference between the probability densities of any two gray levels of a sub-histogram is greater than a specified threshold, it is determined that the sub-histogram needs to be equalized.
[0032] In some embodiments, each target sub-histogram is equalized separately, including:
[0033] Calculating the cumulative distribution function of each target subhistogram according to the probability density of each gray level of each target subhistogram;
[0034] According to the cumulative distribution function, each gray level of each target sub-histogram is mapped to obtain an output corresponding to each gray level.
[0035] A second aspect of the present invention discloses an image enhancement device based on bilateral filtering, comprising:
[0036] A conversion unit, for converting an input image into a grayscale image;
[0037] A determination unit, configured to determine a noisy image according to the grayscale image;
[0038] A decomposition unit, used for performing wavelet decomposition on the noisy image to obtain a high-frequency component and a low-frequency component of the noisy image;
[0039] A filtering unit, used for performing bilateral filtering on the low-frequency component to obtain a filtered image;
[0040] A transformation unit, configured to perform a logarithmic domain transformation on the filtered image to obtain a first reflected image;
[0041] a stretching unit, configured to stretch the first reflected image into a specified range to obtain a second reflected image;
[0042] A calculation unit, used for calculating a high-frequency coefficient threshold according to the high-frequency component;
[0043] A processing unit, configured to process the high frequency component according to the high frequency coefficient threshold to obtain a target high frequency component;
[0044] A reconstruction unit is used to perform wavelet reconstruction according to the second reflected image and the target high-frequency component to obtain an output image.
[0045] In some embodiments, the determining unit includes:
[0046] A calculation subunit, used for calculating a histogram of the grayscale image;
[0047] A segmentation subunit, used for segmenting the histogram into at least two sub-histograms;
[0048] A judgment subunit, used to judge whether each sub-histogram needs to be equalized;
[0049] A determination subunit, used for determining the grayscale image as a noisy image when all subhistograms do not need to be equalized;
[0050] The equalization subunit is used to determine the target subhistogram that needs to be equalized when there is at least one subhistogram that needs to be equalized, and after equalizing each target subhistogram respectively, merge them according to the pixel position to obtain the overall image after equalization; and determine the overall image as a noisy image.
[0051] In some embodiments, the segmentation subunit is specifically used to calculate the first-order derivative of each gray level in the histogram using a difference method, determine whether each gray level is an extreme point based on the first-order derivative, and obtain the judgment result of each gray level; determine at least three local maxima based on the judgment result of each gray level; based on the at least three local maxima, segment the histogram to obtain at least two segmentation intervals; map each of the segmentation intervals to a new dynamic interval to obtain a sub-histogram corresponding to each of the dynamic intervals.
[0052] The third aspect of the present invention discloses an electronic device, comprising a memory storing executable program code and a processor coupled to the memory; the processor calls the executable program code stored in the memory to execute the image enhancement method based on bilateral filtering disclosed in the first aspect.
[0053] A fourth aspect of the present invention discloses a computer-readable storage medium storing a computer program, wherein the computer program enables a computer to execute the image enhancement method based on bilateral filtering disclosed in the first aspect.
[0054] The beneficial effects of the present invention are that, by converting an input image into a grayscale image, determining a noisy image according to the grayscale image, performing wavelet decomposition on the noisy image, and obtaining a high-frequency component and a low-frequency component of the noisy image; then performing bilateral filtering on the low-frequency component to obtain a filtered image, performing logarithmic domain transformation on the filtered image to obtain a first reflected image, and stretching the first reflected image to a specified range to obtain a second reflected image; at the same time, according to the high-frequency component, a high-frequency coefficient threshold is calculated, and the high-frequency component is processed to obtain a target high-frequency component; finally, wavelet reconstruction is performed according to the second reflected image and the target high-frequency component to obtain an output image, thereby adaptively reconstructing the high-frequency component according to the high-frequency component. The high-frequency coefficient threshold is calculated to achieve adaptive parameter adjustment; and by decomposing it into high-frequency components and low-frequency components for processing, the pixel value change degree of the low-frequency component is relatively small, and bilateral filtering plays a major role in the spatial domain, and the pixel value change degree of the high-frequency component is significant. Bilateral filtering works in both the spatial domain and the pixel value domain. Therefore, while maintaining the edge information of the image, the halo caused by the significant difference in image brightness at the edge can be effectively avoided; and by stretching the reflected image to a specified range, the image graying, whitening and other phenomena can be avoided, and then the halo, graying, whitening and other phenomena can be eliminated at the same time, thereby improving the image processing effect. BRIEF DESCRIPTION OF THE DRAWINGS
[0055] The accompanying drawings herein show specific examples of the technical solutions described in the present invention, and together with the specific implementation methods, constitute a part of the specification, and are used to explain the technical solutions, principles and effects of the present invention.
[0056] Unless otherwise specified or defined, the same reference numerals in different drawings represent the same or similar technical features, and the same or similar technical features may also be represented by different reference numerals.
[0057] Figure 1 is a flow chart of an image enhancement method based on bilateral filtering disclosed in an embodiment of the present invention;
[0058] Figure 2is the original input image before being processed by the embodiment of the present invention;
[0059] Figure 3 is an output image processed by the embodiment of the present invention;
[0060] Figure 4 is a structural schematic diagram of an image enhancement device based on bilateral filtering disclosed in an embodiment of the present invention;
[0061] Figure 5 It is a structural schematic diagram of an electronic device disclosed in an embodiment of the present invention.
[0062] Description of reference numerals:
[0063] 201, conversion unit; 202, determination unit; 203, decomposition unit; 204, filtering unit; 205, transformation unit; 206, stretching unit; 207, calculation unit; 208, processing unit; 209, reconstruction unit; 301, memory; 302, processor. DETAILED DESCRIPTION
[0064] Unless otherwise specified or defined, all technical and scientific terms used herein have the same meaning as those generally understood by those skilled in the art. In the case of combining the technical solution of the present invention with realistic scenarios, all technical and scientific terms used herein may also have meanings corresponding to the purpose of implementing the technical solution of the present invention. The "first, second..." used herein is only used to distinguish the names and does not represent a specific quantity or order. The term "and / or" used herein includes any and all combinations of one or more related listed items.
[0065] It should be noted that when a component is considered to be "fixed to" another component, it can be directly fixed to the other component or there can be a central component; when an component is considered to be "connected to" another component, it can be directly connected to the other component or there can be a central component at the same time; when an component is considered to be "installed on" another component, it can be directly installed on the other component or there can be a central component at the same time. When an component is considered to be "set on" another component, it can be directly set on the other component or there can be a central component at the same time.
[0066] Unless otherwise specified or defined, the "said" and "the" used in this document refer to the technical features or technical contents mentioned or described before the corresponding position, and the technical features or technical contents may be the same as or similar to the technical features or technical contents mentioned therein. In addition, the terms "including" and "having" and any variations thereof used in this document are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units that are not listed, or may optionally include other steps or units inherent to these processes, methods, products or devices.
[0067] The embodiment of the present invention discloses an image enhancement method based on bilateral filtering, which can be implemented by computer programming. The execution subject of the method can be an electronic device such as a computer, a laptop, a tablet computer, or an image enhancement device based on bilateral filtering embedded in an electronic device, and the present invention is not limited to this. In order to facilitate the understanding of the present invention, the specific embodiments of the present invention will be described in more detail below with reference to the drawings of the specification.
[0068] like Figure 1 As shown, the method includes the following steps 110 to 180:
[0069] 110. Convert the input image into a grayscale image, and determine the noisy image based on the grayscale image.
[0070] The grayscale image may be directly determined as a noisy image, or the grayscale image may be further processed to obtain a noisy image. As an optional implementation, the method of determining the noisy image based on the grayscale image may include the following steps S11 to S14 (not shown):
[0071] S11. Calculate a histogram of the grayscale image, and divide the histogram into at least two sub-histograms.
[0072] First, the histogram of the grayscale image is calculated to reflect the brightness distribution of the image. Among them, the histogram describes the statistical characteristics of each grayscale level of the image. The histogram is a discrete function that represents the corresponding relationship between each grayscale level of the image and the frequency of occurrence of the grayscale level. From the image point of view, the histogram is a two-dimensional image, the horizontal axis is the grayscale level of each pixel in the image, and the vertical axis represents the frequency of occurrence of pixels with each grayscale level in the image.
[0073] In order to make the enhanced image have a more natural visual effect, the histogram of the entire grayscale image is first divided into two or more sub-histograms, and then each sub-histogram is processed separately. The method of dividing the histogram of the grayscale image into at least two sub-histograms may include the following steps S1101 to S1104 (not shown):
[0074] S1101, using a difference method to calculate the first-order derivative of each gray level in the histogram, judging whether each gray level is an extreme point according to the first-order derivative, and obtaining a judgment result of each gray level.
[0075] Specifically, the difference method can be used to find the first-order derivative and extreme points of each gray level in the histogram:
[0076] g(i)=h(i-1)-h(i),i∈{0,1,…255}(1)
[0077]
[0078] Among them, g(i) represents the first-order derivative of gray level i, h(i) represents the number of pixels contained in the grayscale image at the current gray level i, pt(i) = (g(i) × g(i-1)), which is used to indicate whether the current gray level i is an extreme point; if pt(i) < 0, it indicates that the current gray level i is an extreme point; if pt(i) ≥ 0, it indicates that the current gray level i is not an extreme point.
[0079] S1102: Determine at least three local maximum values according to the judgment results of each gray level.
[0080] If a first number of consecutive gray levels are detected as extreme points, and a second number of consecutive gray levels are not extreme points, the last gray level is determined to be a local maximum. The first number and the second number may be the same or different, and their values are preset by the developer.
[0081] For example, the first number is 4 and the second number is 8, then the last point detected as four consecutive pt(i)<0 and then eight consecutive pt(i)≥0 after the above-mentioned first-order derivative and extreme point calculation is determined to be the local maximum value, so that after all gray levels in the histogram are detected, n+1 local maxima can be obtained, where n is a positive integer ≥2.
[0082] S1103 . Segment the histogram according to at least three local maxima to obtain at least two segmentation intervals.
[0083] According to the determined n+1 local maximum gray levels, the histogram of the gray image is segmented to obtain n segmentation intervals. Assume m0,m1,…,m n Corresponding to the gray levels of the above n+1 local maxima, n segmentation intervals can be obtained. That is, these n+1 local maxima can divide the histogram of the image into:
[0084] [I min ,m0],[m0+1,m1],……,[mn ,I max ]
[0085] Among them, I min and I max is the minimum and maximum grayscale value of the grayscale image.
[0086] S1104: Map each segmented interval to a new dynamic interval, and obtain a sub-histogram corresponding to each dynamic interval.
[0087] Mapping these sub-histogram segmentation intervals to new dynamic intervals helps to improve contrast while maintaining image details. The mapping method is as follows:
[0088] f j =(h j -l j )×log 10 M(3)
[0089]
[0090] Among them, h j is the highest pixel value in the jth subhistogram, l j is the lowest pixel value in the jth subhistogram, L j is the number of all pixels in subhistogram j; f j Represents the adjustment factor of the segmentation interval of the j-th subhistogram, Indicates the number of pixels in the segmentation interval, r j Indicates the dynamic interval size of the j-th sub-histogram after the segmentation interval is adjusted.
[0091] For the dynamic range of the jth subhistogram after mapping [start j ,end j ], can be calculated by the following formula:
[0092]
[0093] Among them, the starting point of the dynamic interval of the jth subhistogram is start j is the next value after the sum of the dynamic interval sizes of the previous j-1 sub-histograms, k represents the counting variable for the summation calculation, r k Represents the sum of the dynamic interval sizes of the previous k sub-histograms.
[0094] S12, determining whether each sub-histogram needs to be equalized.
[0095] First, calculate the probability density of each gray level of each subhistogram: Among them, PDF(i) is the probability density of the i-th gray level in the subhistogram, n i is the number of pixels with gray level i; i<q, that is, the value range of i is below q (such as q=50); N is the total number of pixels in the input image with image size m×n.
[0096] If the difference between the probability density of any two gray levels of the sub-histogram is less than or equal to the specified threshold, it is determined that the sub-histogram does not need to be equalized; if the difference between the probability density of any two gray levels of the sub-histogram is greater than the specified threshold, it is determined that the sub-histogram needs to be equalized.
[0097] For example, assuming that PDF(i) and PDF(j) are the probability densities of any two gray levels of the sub-histogram, if |PDF(i)-PDF(j)|≤0.1, it means that the probability densities of each gray level of the sub-histogram are similar, then the sub-histogram is considered to be evenly distributed and histogram equalization is not required, otherwise equalization is required.
[0098] S13: If all sub-histograms do not need to be equalized, the grayscale image is determined to be a noisy image.
[0099] S14. If there is at least one sub-histogram that needs to be equalized, determine the target sub-histogram that needs to be equalized, and after equalizing each target sub-histogram respectively, merge them according to the pixel position to obtain the overall image after equalization; determine the overall image as a noisy image.
[0100] Each target subhistogram is independently equalized to provide a more natural visual effect for the enhanced image. After each target subhistogram is independently equalized, it is merged according to the pixel position to obtain the overall image after equalization.
[0101] In step S14, each target sub-histogram is equalized in the following manner:
[0102] First, according to the probability density of each gray level of each target subhistogram, the cumulative distribution function of each target subhistogram is calculated; then, according to the cumulative distribution function, each gray level of each target subhistogram is mapped to obtain the output corresponding to each gray level.
[0103] Specifically, for each target subhistogram that needs to be equalized [start i ,end i ], the cumulative distribution function is calculated by the following formula:
[0104]
[0105] Where PDF(i) is the probability density of the i-th gray level in the target subhistogram, CDF(i) is the cumulative distribution function of the i-th gray level in the target subhistogram, and start i It is the starting gray level of the dynamic interval segment corresponding to the target sub-histogram.
[0106] Then, the output F(i) corresponding to each gray level is obtained using the following mapping conversion formula:
[0107] F(i)=start i +(end i -start i )×CDF(i) (7)
[0108] 120. Perform wavelet decomposition on the noisy image to obtain the high-frequency component and low-frequency component of the noisy image.
[0109] Among them, the two-dimensional discrete wavelet transform method can be used to decompose the noisy image, and the noisy image can be decomposed into high-frequency components and low-frequency components, where the low-frequency components mainly include the global information of the image, such as contour information, and the high-frequency components mainly include the local information of the image, such as the edge, details, and noise part of the image. Assuming that coif5 is used as the wavelet basis function, the two-dimensional discrete wavelet decomposition formula is as follows:
[0110]
[0111]
[0112] in, is the low-frequency component after decomposition, is the high-frequency component after decomposition, i = {H, V, D}, i represents the horizontal direction H, vertical direction V or diagonal direction D, j0 represents an arbitrary starting scale, usually set to 0. f(x, y) represents the discrete function of the image to be decomposed (i.e., the noisy image), x and y represent the x-axis and y-axis coordinates of the discrete component respectively; m and n represent the relative offset relative to (x, y), M and N represent the size of the noisy image, consisting of M×N pixels; is a two-dimensional scaling function, is the wavelet function corresponding to the direction i. The specific calculation and relationship between the two-dimensional scaling function and the wavelet function are as follows:
[0113]
[0114]
[0115] 130. Perform bilateral filtering on the low-frequency component to obtain a filtered image.
[0116] As an efficient and powerful image processing method, bilateral filtering not only effectively protects the edge information of the image, but also has a significant effect on eliminating salt and pepper noise. In the embodiment of the present invention, an improved bilateral filtering method is used to process the low-frequency component. The expression of bilateral filtering is as follows:
[0117]
[0118]
[0119]
[0120] In formula (10), I1(x1, y1) is the gray level of each pixel (x1, y1) in the low-frequency component, I′1(x1, y1) is the gray level obtained after denoising corresponding to the pixel (x2, y1) in the low-frequency component, S represents the local neighborhood with I1(x1, y1) as the center point, I2(x2, y3) is the gray level corresponding to the pixel (x2, y2) in the local neighborhood; W(x1, y1, x2, y2) is the kernel function of the spatial domain and the pixel range domain, where x1, y1 are the spatial coordinate values of the pixel center point, and x2, y2 are the spatial coordinate values of the local neighborhood points of the pixel center point.
[0121] In equations (11) and (12), I1(x1, y1) and I2(x2, y2) represent the grayscale levels of two pixels respectively; σ r is the brightness difference scale parameter, and p is the filter window parameter. It is the spatial weight between the pixels (x1, y1) and (x2, y2). It is the pixel value weight between the pixel points (x1, y1) and (x2, y2).
[0122] In the embodiment of the present invention, the That is, the pixel distance between the pixel point in the local neighborhood and the center point is lower than the filter window parameter, which can ensure that the pixel position is within the radius, and its spatial domain and pixel value domain are valid at the same time. In this way, in the flat area, the degree of pixel value change is relatively small, and bilateral filtering plays a major role in the spatial domain; in the edge area, the degree of pixel value change is significant, and bilateral filtering plays a role in both the spatial domain and the pixel value domain, so that while maintaining the edge information of the image, it can effectively avoid the halo caused by the significant difference in image brightness at the edge, thereby eliminating the halo phenomenon.
[0123] 140. Perform logarithmic domain transformation on the filtered image to obtain a first reflected image.
[0124] In order to eliminate the influence of illumination on the image, the first reflected image is obtained by logarithmic domain transformation. The transformation of the logarithmic domain is shown in the following formula:
[0125] R(x,y)=log a S(x,y)-k log a S(x,y)*F(x,y) (13)
[0126] Where k is the light adjustment parameter, log a It is a logarithmic function commonly used to change the dynamic range of data, S is the input filtered image, R is the output first reflection image, and F is a Gaussian kernel function used to enhance the local features of the image.
[0127] 150. Stretch the first reflected image into a specified range to obtain a second reflected image.
[0128] The first reflected image obtained after logarithmic domain transformation exceeds 0-230 in the pixel value range, which is easy to cause grayscale, whitening and other phenomena of the image, affecting the visual effect and subsequent processing. Therefore, it is necessary to stretch the first reflected image. First, calculate the maximum and minimum values of the grayscale level inside the first reflected image. Then, use the following formula (14) to stretch the first reflected image to the specified range of [0, 230]:
[0129]
[0130] Where d(x, y) is the second reflected image after stretching, R(x, y) is the first reflected image before stretching, and R min and R max are the maximum and minimum values of the grayscale in the first reflected image R(x, y) before stretching.
[0131] 160. Calculate a high-frequency coefficient threshold based on the high-frequency component.
[0132] In order to remove the noise in the high-frequency component, the fixed threshold method is first used to calculate the high-frequency coefficient threshold. The specific formula (15) is as follows:
[0133]
[0134] Among them, T is the high-frequency coefficient threshold, M*N is the image size of the high-frequency component, σ is the noise standard deviation, and its estimation formula is σ=median(|c|) / 0.6745, where c is the high-frequency component obtained by wavelet decomposition, median is the median function, and median(|c|) means taking the median of all high-frequency components.
[0135] 170. Process the high-frequency component according to the high-frequency coefficient threshold to obtain the target high-frequency component.
[0136] In view of the discontinuity and constant deviation problems of hard and soft threshold functions, the present invention adopts an improved threshold function to process high-frequency components. The specific formula is as follows:
[0137]
[0138] Among them, C j,k is the high frequency component obtained by wavelet decomposition, is the target high-frequency component estimated after threshold processing, j and k represent the pixel position information of the high-frequency component respectively, and T is the calculated high-frequency coefficient threshold. In the embodiment of the present invention, the improved threshold function uses 0.6T and T as segmentation points and is divided into three segments to estimate the target high-frequency component. The noise component can be better separated as a whole, the oscillation phenomenon is effectively avoided, and the constant deviation of the threshold function is reduced, thereby improving the accuracy of the estimated target high-frequency component.
[0139] 180. Perform wavelet reconstruction according to the second reflected image and the target high-frequency component to obtain an output image.
[0140] According to the second reflected image and the target high-frequency component obtained after processing the low-frequency component and the high-frequency component respectively, the image is reconstructed using the inverse discrete wavelet transform. The wavelet reconstruction formula is as follows:
[0141]
[0142] Among them, d(j0,m,n) is the stretched second reflected image, is the target high frequency component, is a two-dimensional scaling function, is the wavelet function in the direction corresponding to i.
[0143] In summary, by implementing the embodiment of the present invention, a new image enhancement algorithm is proposed by combining the advantages of histogram equalization and bilateral filtering. The algorithm organically integrates histogram equalization and bilateral filtering, as well as its adaptive parameter adjustment strategy, aiming to improve image quality while reducing noise in the image. First, the image is preprocessed using an improved histogram equalization strategy to enhance the image contrast, then bilateral filtering is used to protect the image edge information, and then the enhancement effect is automatically adjusted according to the characteristics of the image through an adaptive parameter adjustment strategy.
[0144] In order to avoid the "fading" and "speckle" effects caused by excessive image enhancement in the traditional global histogram equalization (HE) method, an improved HE method is proposed in the embodiment of the present invention, which divides the histogram into sub-histograms, dynamically adjusts its boundary range, and independently equalizes the sub-histograms that need to be equalized. This effectively avoids the problems of over-enhancement and under-enhancement, improves the visual effect and image quality, and the optimized histogram equalization can effectively improve the global contrast of the image, avoid over-enhancement and grayscale, so that the enhanced image provides a more natural visual effect.
[0145] There are other improvement strategies for traditional histogram equalization, which easily leads to excessive image enhancement, such as segmentation based on the K-means clustering algorithm and bilinear interpolation. Methods such as cross-bilateral filters can also adjust parameter settings adaptively. However, the effective combination of the improved HE method and the optimized bilateral filtering method can not only enhance the image contrast, avoid graying and excessive enhancement, but also effectively suppress noise while protecting the edge information of the image.
[0146] In order to verify the effect of the embodiment of the present invention, the following experimental results are analyzed and tested.
[0147] Parameter setting: Windows 10 operating system, MATLAB R2020a and Py-Charm IDE were used as experimental platforms. The filter window size was set to p = 4, the illumination image adjustment parameter k was set to 0.6, and the brightness difference scale parameter r was set to 0.002. Coif5 was used as the wavelet basis function for decomposition and reconstruction, and 2 layers were selected for the number of decomposition layers.
[0148] Dataset selection: The experimental dataset selected the representative DIVerse 2K resolution high-quality images (DIV2K dataset) for testing and analysis.
[0149] In order to objectively evaluate the image enhancement effect, this experiment comprehensively evaluates the image quality through several evaluation parameters such as Peak signal-to-noise ratio (PSNR), structural similarity (SSIM), contrast, and Universal Image Quality Metric (UIQM).
[0150] The specific evaluation parameter calculation formula is analyzed as follows.
[0151] The PSNR calculation is shown in the following formula (17):
[0152]
[0153] In formula (17), PSNR represents the amount of noise introduced into the enhanced image. The larger the value, the smaller the noise introduced during the image processing, and L is the maximum possible pixel value of the image color depth.
[0154] SSIM is used to measure the structural similarity of images, and its calculation is shown in formula (18).
[0155]
[0156] In the formula, u I and u O is the mean, σ I and σ O is the variance, σ IO is a covariate, C1 and C2 are constants.
[0157] Contrast is used to measure the difference in brightness between the bright and dark areas of an image. The smaller the difference range, the smaller the contrast, but the larger the contrast, the better. The calculation is shown in formula (19):
[0158]
[0159] Where I(x,y) is the pixel of the image, M and N are the width and height of the image, and MB is the average brightness of image I.
[0160] UIQM is a non-reference evaluation index for measuring color balance, clarity and contrast. The calculation is as follows:
[0161] UIQM=c1UICM+c2UISM+c3UIConM (20)
[0162] In the formula, UICM, UISM and UIConM are the metrics of color, clarity and contrast respectively, and c1, c and c3 are constants. The linear combination of hue, saturation and contrast as three components can obtain a measurement value that is more in line with human visual perception habits.
[0163] At the same time, five methods including contrast limited adaptive histogram equalization (CLAHE) algorithm, dynamic range separation histogram equalization (DRSHE), exposure based sub image histogram equalization (ESIHE), image fusion (FUSION), and the method proposed in the embodiment of the present invention are recorded for image enhancement, and the objective evaluation indicators are compared in a complex and changeable environment, as shown in Table 1 below.
[0164] Table 1 Comparison of objective evaluation indicators of various algorithms in complex and changing environments
[0165] Method Contrast PSNR SSIM UIQM Original 60.799 12.487 0.211 0.389 Reference 62.844 Inf 1.000 4.330 CLAHE 59.470 14.869 0.304 2.202 DRSH 75.117 15.969 0.433 3.380 ESIHE 67.673 16.445 0.469 2.054 FUSION 45.689 15.350 0.505 2.995 Embodiments of the present invention 61.335 19.207 0.516 3.489
[0166] It can be seen from the data in Table 1 above that the image quality processed by the CLAHE method is poorer and the brightness is lower than that of the method proposed in the embodiment of the present invention. Although the DRSHE and ESIHE methods enhance the contrast results and show high contrast and bright colors, the subjective visual effect is poor and there is color distortion caused by over-enhancement. Compared with the reference image, its SSIM and PSNR values are lower, indicating that the similarity is lower and the overall performance is poor. Although the FUSION method has good similarity with the reference image, it lacks contrast and color information, so it performs slightly worse in these two objective evaluation indicators.
[0167] Therefore, from the perspective of maintaining the naturalness of the image, improving the image quality and detail visibility, the image enhancement method based on the improved histogram equalization and the optimized bilateral filtering technology proposed in the embodiment of the present invention can effectively improve the global contrast of the image and avoid over-enhancement and grayscale. Figures 2 to 3 shown.
[0168] like Figure 4 As shown, the embodiment of the present invention discloses an image enhancement device based on bilateral filtering, including a conversion unit 201, a determination unit 202, a decomposition unit 203, a filtering unit 204, a transformation unit 205, a stretching unit 206, a calculation unit 207, a processing unit 208, and a reconstruction unit 209, wherein:
[0169] A conversion unit 201, used to convert an input image into a grayscale image;
[0170] A determination unit 202, configured to determine a noisy image according to the grayscale image;
[0171] A decomposition unit 203, configured to perform wavelet decomposition on the noisy image to obtain a high-frequency component and a low-frequency component of the noisy image;
[0172] A filtering unit 204, configured to perform bilateral filtering on the low-frequency component to obtain a filtered image;
[0173] A transformation unit 205, configured to perform a logarithmic domain transformation on the filtered image to obtain a first reflected image;
[0174] A stretching unit 206, configured to stretch the first reflected image into a specified range to obtain a second reflected image;
[0175] A calculation unit 207, configured to calculate a high frequency coefficient threshold according to the high frequency component;
[0176] A processing unit 208, configured to process the high frequency component according to the high frequency coefficient threshold to obtain a target high frequency component;
[0177] The reconstruction unit 209 is used to perform wavelet reconstruction according to the second reflected image and the target high-frequency component to obtain an output image.
[0178] As an optional implementation, the determining unit 202 includes the following subunits (not shown):
[0179] A calculation subunit, used for calculating a histogram of the grayscale image;
[0180] A segmentation subunit, used for segmenting the histogram into at least two sub-histograms;
[0181] A judgment subunit, used to judge whether each sub-histogram needs to be equalized;
[0182] A determination subunit, used for determining the grayscale image as a noisy image when all subhistograms do not need to be equalized;
[0183] The equalization subunit is used to determine the target subhistogram that needs to be equalized when there is at least one subhistogram that needs to be equalized, and after equalizing each target subhistogram respectively, merge them according to the pixel position to obtain the overall image after equalization; and determine the overall image as a noisy image.
[0184] Further optionally, a segmentation subunit is specifically used to calculate the first-order derivative of each gray level in the histogram using a difference method, judge whether each gray level is an extreme point based on the first-order derivative, and obtain the judgment result of each gray level; determine at least three local maxima based on the judgment result of each gray level; based on the at least three local maxima, segment the histogram to obtain at least two segmentation intervals; map each segmentation interval to a new dynamic interval, and obtain a sub-histogram corresponding to each dynamic interval.
[0185] Further optionally, a judgment subunit is specifically used to calculate the probability density of each gray level of each sub-histogram; if the difference between the probability density of any two gray levels of the sub-histogram is less than or equal to a specified threshold, it is determined that the sub-histogram does not need to be equalized; if the difference between the probability density of any two gray levels of the sub-histogram is greater than the specified threshold, it is determined that the sub-histogram needs to be equalized.
[0186] Further optionally, the equalization subunit is specifically used to calculate the cumulative distribution function of each target subhistogram based on the probability density of each gray level of each target subhistogram; according to the cumulative distribution function, each gray level of each target subhistogram is mapped to obtain the output corresponding to each gray level.
[0187] like Figure 5 As shown, an embodiment of the present invention discloses an electronic device, including a memory 301 storing executable program codes and a processor 302 coupled to the memory 301;
[0188] The processor 302 calls the executable program code stored in the memory 301 to execute the image enhancement method based on bilateral filtering described in the above embodiments.
[0189] An embodiment of the present invention further discloses a computer-readable storage medium storing a computer program, wherein the computer program enables a computer to execute the image enhancement method based on bilateral filtering described in the above embodiments.
[0190] The purpose of the above embodiments is to exemplarily reproduce and deduce the technical solution of the present invention, and to fully describe the technical solution, purpose and effect of the present invention. Its purpose is to make the public understand the disclosed content of the present invention more thoroughly and comprehensively, and it does not limit the scope of protection of the present invention.
[0191] The above embodiments are not exhaustive enumerations of the present invention, and there may be multiple other implementations not listed. Any replacement and improvement made without violating the concept of the present invention shall fall within the protection scope of the present invention.
Claims
1. An image enhancement method based on bilateral filtering, characterized in that: include: Converting an input image into a grayscale image, and determining a noisy image based on the grayscale image; Performing wavelet decomposition on the noisy image to obtain a high-frequency component and a low-frequency component of the noisy image; Performing bilateral filtering on the low-frequency component to obtain a filtered image; Performing a logarithmic domain transformation on the filtered image to obtain a first reflected image; Stretching the first reflected image into a specified range to obtain a second reflected image; According to the high frequency component, a high frequency coefficient threshold is calculated; According to the high-frequency coefficient threshold, the high-frequency component is processed to obtain a target high-frequency component; Perform wavelet reconstruction according to the second reflected image and the target high-frequency component to obtain an output image; wherein, Determining a noisy image according to the grayscale image includes: Calculating a histogram of the grayscale image, and dividing the histogram into at least two sub-histograms; Determine whether each sub-histogram needs to be equalized one by one; If all sub-histograms do not need to be equalized, the grayscale image is determined to be a noisy image; If there is at least one sub-histogram that needs to be equalized, determine the target sub-histogram that needs to be equalized, and after equalizing each target sub-histogram respectively, merge them according to the pixel position to obtain the overall image after equalization; determine the overall image as a noisy image; The histogram is divided into at least two sub-histograms, comprising: Calculating the first-order derivative of each gray level in the histogram using a differential method, judging whether each gray level is an extreme point according to the first-order derivative, and obtaining a judgment result of each gray level; According to the judgment results of each gray level, at least three local maximum values are determined; wherein, if a first number of consecutive gray levels are detected as extreme value points, and then a second number of consecutive gray levels are not extreme value points, the last gray level is determined to be the local maximum value; According to at least three local maxima, segmenting the histogram to obtain at least two segmentation intervals; Map each of the segmented intervals to a new dynamic interval, and obtain a subhistogram corresponding to each of the dynamic intervals, wherein the mapping method is as follows: f j =(h j -l j )×log 10 M In the formula, h j is the highest pixel value in the jth subhistogram, l j is the lowest pixel value in the jth subhistogram, L j is the number of all pixels in the jth subhistogram; f j Represents the adjustment factor of the segmentation interval of the j-th subhistogram, Indicates the number of pixels in the segmentation interval, r j Indicates the dynamic interval size of the j-th sub-histogram after the segmentation interval is adjusted; the dynamic interval range of the j-th sub-histogram after mapping [start j ,end j The calculation formula of ] is: Where, the starting point of the dynamic interval of the jth subhistogram is j is the next value after the sum of the dynamic interval sizes of the previous j-1 sub-histograms, k represents the counting variable for the summation calculation, r k Represents the sum of the dynamic interval sizes of the previous k sub-histograms.
2. The image enhancement method based on bilateral filtering according to claim 1, characterized in that: Determine whether each sub-histogram needs to be equalized, including: Calculate the probability density of each gray level of each subhistogram; If the difference between the probability densities of any two gray levels of the sub-histogram is less than or equal to the specified threshold, it is determined that the sub-histogram does not need to be equalized; If the difference between the probability densities of any two gray levels of a sub-histogram is greater than a specified threshold, it is determined that the sub-histogram needs to be equalized.
3. The image enhancement method based on bilateral filtering as claimed in claim 2, characterized in that: Each target subhistogram is equalized separately, including: Calculating the cumulative distribution function of each target subhistogram according to the probability density of each gray level of each target subhistogram; According to the cumulative distribution function, each gray level of each target sub-histogram is mapped to obtain an output corresponding to each gray level.
4. An image enhancement device based on bilateral filtering, used to implement the image enhancement method based on bilateral filtering as claimed in any one of claims 1 to 3, characterized in that: include: A conversion unit, for converting an input image into a grayscale image; A determination unit, configured to determine a noisy image according to the grayscale image; A decomposition unit, used for performing wavelet decomposition on the noisy image to obtain a high-frequency component and a low-frequency component of the noisy image; A filtering unit, used for performing bilateral filtering on the low-frequency component to obtain a filtered image; A transformation unit, configured to perform a logarithmic domain transformation on the filtered image to obtain a first reflected image; a stretching unit, configured to stretch the first reflected image into a specified range to obtain a second reflected image; A calculation unit, used for calculating a high-frequency coefficient threshold according to the high-frequency component; A processing unit, configured to process the high frequency component according to the high frequency coefficient threshold to obtain a target high frequency component; A reconstruction unit is used to perform wavelet reconstruction according to the second reflected image and the target high-frequency component to obtain an output image; wherein, The determining unit comprises: A calculation subunit, used for calculating a histogram of the grayscale image; A segmentation subunit, used for segmenting the histogram into at least two sub-histograms; A judgment subunit, used to judge whether each sub-histogram needs to be equalized; A determination subunit, used for determining the grayscale image as a noisy image when all subhistograms do not need to be equalized; The equalization subunit is used to determine the target subhistogram to be equalized when there is at least one subhistogram to be equalized, and after equalizing each target subhistogram respectively, merge them according to the pixel position to obtain the overall image after equalization; determine the overall image as a noisy image; The segmentation subunit is specifically used to calculate the first-order derivative of each gray level in the histogram by using the difference method, judge whether each gray level is an extreme point according to the first-order derivative, and obtain the judgment result of each gray level; determine at least three local maxima according to the judgment result of each gray level; according to the at least three local maxima, segment the histogram to obtain at least two segmentation intervals; map each of the segmentation intervals to a new dynamic interval, and obtain a sub-histogram corresponding to each dynamic interval.
5. An electronic device, characterized in that: It comprises a memory storing executable program code and a processor coupled to the memory; the processor calls the executable program code stored in the memory to execute the image enhancement method based on bilateral filtering as described in any one of claims 1 to 3.
6. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program enables a computer to execute the image enhancement method based on bilateral filtering according to any one of claims 1 to 3.
