Self-adaptive image dedusting method, device and equipment

By calculating the probability density of grayscale values ​​and cumulative distribution functions, adjusting the threshold range of black and white fields, adaptive image graying is realized, solving the image processing problems in different exposure scenarios, and improving image quality and user experience.

CN120580249APending Publication Date: 2025-09-02XIAMEN MEITUZHIJIA TECH
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202510639700.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-19
Publication Date
2025-09-02

AI Technical Summary

Technical Problem

The existing image processing technology cannot adaptively adjust according to different exposure scenes, resulting in the problem of "white is not white enough, black is not black enough, and overall gray". The traditional method is time-consuming and labor-intensive and has poor results.

Method used

By calculating the probability density function and cumulative distribution function of the input image, adjust the search range of the black field threshold and the white field threshold, select the optimal threshold and apply it to the color scale mapping function, and realize adaptive image graying removal.

Benefits of technology

It improves the adaptability and visual effect of image gray removal effect, enhances the practicality and user satisfaction of image processing, ensures the stability and accuracy of the gray removal process, especially retains important details in portrait image processing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120580249A_ABST
    Figure CN120580249A_ABST
Patent Text Reader

Abstract

The invention discloses a self-adaptive image de-dusting method, device and equipment. The method comprises the following steps: calculating a gray value probability density function and a gray value cumulative distribution function of an input image; based on the gray value probability density function, adjusting search ranges of a black field threshold and a white field threshold to obtain a black field threshold adjustment range and a white field threshold adjustment range; respectively selecting an optimal point meeting a preset value in the gray value cumulative distribution function in the black field threshold adjustment range and the white field threshold adjustment range to obtain an optimal black field threshold and an optimal white field threshold; and inputting the optimal black field threshold value and the optimal white field threshold value into a color gradation mapping function to be applied to the input image to obtain a de-dusting result image. The adaptability of the dedusting effect can be enhanced, the contrast ratio and the visual effect of the image are effectively improved, and the image retouching result better conforms to the expectation of a user.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of image processing technology, and in particular to an adaptive image de-graying method, device and equipment. Background Art

[0002] In the field of photography editing, due to the influence of weather and camera metering principles, photos may appear grayish, with whites not white enough, blacks not black enough, and an overall grayish cast. This phenomenon is usually addressed by manually adjusting contrast or saturation, which is not only time-consuming and labor-intensive, but also requires a certain level of operator experience. Furthermore, the automatic color gradation method used in traditional image processing algorithms is only effective for slightly grayed images, and is ineffective for severely grayed images, making it difficult to meet the high-quality image processing requirements of various scenarios. Summary of the Invention

[0003] In view of this, the purpose of the present invention is to propose an adaptive image degraving method, device and equipment, aiming to solve the problems such as the inability of existing image degraving methods to adaptively adjust according to different exposure scenarios.

[0004] To achieve the above object, the present invention provides an adaptive image de-graying method, the method comprising:

[0005] Calculate the gray value probability density function and gray value cumulative distribution function of the input image;

[0006] Based on the gray value probability density function, adjusting the search range of the black field threshold and the white field threshold to obtain the black field threshold adjustment range and the white field threshold adjustment range;

[0007] Selecting the optimal point of the grayscale value cumulative distribution function that meets the preset value within the black field threshold adjustment range and the white field threshold adjustment range respectively, to obtain the optimal black field threshold and the optimal white field threshold;

[0008] The optimal black field threshold and the optimal white field threshold are input into a tone mapping function to be applied to the input image to obtain a gray removal result image.

[0009] Preferably, the calculating of the grayscale value probability density function and the grayscale value cumulative distribution function of the input image includes:

[0010] Calculating the grayscale value probability density function based on the number of pixels with grayscale value i in the input image and the total number of pixels in the image;

[0011] The cumulative sum of the gray value probability density function at the corresponding gray value i is calculated to obtain the gray value cumulative distribution function.

[0012] Preferably, adjusting the search ranges of the black field threshold and the white field threshold based on the gray value probability density function to obtain the black field threshold adjustment range and the white field threshold adjustment range includes:

[0013] By expanding the search ranges of the black field threshold and the white field threshold, a black field threshold search range and a white field threshold search range are obtained;

[0014] Determine the maximum minimum value point within the black field threshold search range based on the gray value probability density function, and determine the minimum minimum value point within the white field threshold search range;

[0015] The search ranges of the black field threshold search range and the white field threshold search range are correspondingly adjusted according to the maximum minimum value point and the minimum minimum value point to obtain the black field threshold adjustment range and the white field threshold adjustment range.

[0016] Preferably, selecting the optimal point of the grayscale value cumulative distribution function that satisfies a preset value within the black field threshold adjustment range and the white field threshold adjustment range respectively to obtain the optimal black field threshold and the optimal white field threshold includes:

[0017] Calculating the black field percentage threshold and the white field percentage threshold based on the average brightness and the median brightness of the input image;

[0018] Determining an optimal point of the grayscale value cumulative distribution function that is smaller than the black field percentage threshold within the black field threshold adjustment range to obtain the optimal black field threshold;

[0019] An optimal point of the grayscale value cumulative distribution function that is greater than the white field percentage threshold is determined within the white field threshold adjustment range to obtain the optimal white field threshold.

[0020] Preferably, the calculation based on the image average brightness and the intermediate brightness value of the input image to obtain the black field percentage threshold and the white field percentage threshold includes:

[0021] Determine the distance between the average brightness of the image and the median brightness value to obtain a brightness distance, wherein the median brightness value is 128;

[0022] The product of the brightness distance and the preset parameter adjustment coefficient is calculated, and the sum of the obtained product result and the lower limit threshold is calculated to obtain the black field percentage threshold and the white field percentage threshold.

[0023] Preferably, the input image is a portrait image; and determining the distance between the average brightness of the image and the median brightness value to obtain the brightness distance includes:

[0024] The portrait image is processed through skin segmentation to obtain the average skin brightness of the skin area;

[0025] The distance between the average skin brightness and the middle brightness value is determined to obtain the brightness distance.

[0026] Preferably, determining the optimal point of the grayscale value cumulative distribution function that is smaller than the black field percentage threshold within the black field threshold adjustment range to obtain the optimal black field threshold includes:

[0027] Traversing from the end point of the black field threshold adjustment range to the starting point of the range, a grayscale value that satisfies the grayscale value cumulative distribution function and is less than the black field percentage threshold is selected as the optimal black field threshold.

[0028] Preferably, determining the optimal point of the grayscale value cumulative distribution function that is greater than the white field percentage threshold within the white field threshold adjustment range to obtain the optimal white field threshold includes:

[0029] Traversing from the range starting point to the range ending point of the white field threshold adjustment range, a grayscale value that satisfies the grayscale value cumulative distribution function and is greater than the white field percentage threshold is selected as the optimal white field threshold.

[0030] To achieve the above object, the present invention provides an adaptive image de-dusting device, comprising:

[0031] A calculation unit, used to calculate the gray value probability density function and gray value cumulative distribution function of the input image;

[0032] An adjusting unit, configured to adjust the search ranges of the black field threshold and the white field threshold based on the gray value probability density function, to obtain a black field threshold adjustment range and a white field threshold adjustment range;

[0033] A selection unit is configured to select an optimal point of the grayscale value cumulative distribution function that satisfies a preset value within the black field threshold adjustment range and the white field threshold adjustment range, respectively, to obtain an optimal black field threshold and an optimal white field threshold;

[0034] The de-ashing unit is configured to input the optimal black field threshold and the optimal white field threshold into a tone mapping function to apply the function to the input image, thereby obtaining a de-ashing result image.

[0035] In order to achieve the above objectives, the present invention also proposes an adaptive image degraving device, including a processor, a memory, and a computer program stored in the memory, wherein the computer program is executed by the processor to implement the steps of an adaptive image degraving method as described in the above embodiment.

[0036] To achieve the above objectives, the present invention further provides a computer-readable storage medium having a computer program stored thereon. The computer program is executed by a processor to implement the steps of an adaptive image degraving method as described in the above embodiment.

[0037] To achieve the above object, the present invention further provides a computer program product, comprising a computer program / instruction, which, when executed by a processor, implements the steps of an adaptive image degraving method as described in the above embodiment.

[0038] Beneficial effects:

[0039] The above scheme can accurately grasp the grayscale distribution characteristics of the image by calculating the grayscale value probability density function and cumulative distribution function of the input image. On this basis, it adjusts the search range of the black field threshold and the white field threshold, and selects the optimal point that meets the preset value as the optimal threshold, so that the degraving operation can be targetedly adjusted according to the specific grayscale distribution of the image, thereby enhancing the adaptability of the degraving effect, effectively improving the contrast and visual effect of the image, and making the photo editing results more in line with user expectations. Through adaptive adjustment, it helps to improve the practicality of the image degraving function and user satisfaction.

[0040] The probability density function is calculated according to the number of pixels with gray value i and the total number of pixels. The cumulative distribution function is obtained by accumulating the probability density function values. This method has high accuracy and reliability based on the pixel statistical characteristics of the image, and can provide a reliable data basis for subsequent threshold adjustment and de-graying operations, ensuring the stability and effectiveness of the entire de-graying process.

[0041] By expanding the search range and determining the minimum points within the search range based on the grayscale probability density function, and then adjusting the search range according to these minimum points, the threshold search interval can be determined more reasonably. The optimized search range is more consistent with the actual grayscale distribution of the image, which helps to find more appropriate black field thresholds and white field thresholds when selecting the optimal threshold later, thereby improving the rationality and effectiveness of the de-graying effect.

[0042] By calculating the black field percentage threshold and the white field percentage threshold based on the average brightness and median brightness value of the input image, the optimal black field threshold and white field threshold can be determined more accurately under different brightness conditions, thereby achieving more adaptive de-dusting processing of the image and effectively improving the de-dusting effect.

[0043] By traversing the threshold adjustment range to identify the optimal point that meets the requirements, this method quickly and accurately finds the appropriate threshold, ensuring the stability and reliability of the de-dusting effect. The optimal threshold is determined by taking into account the image's brightness distribution and the cumulative distribution function of grayscale values. This allows the algorithm to minimize the loss of detail in shadows and highlights while adjusting contrast, preserving important image information.

[0044] For portrait images, the average brightness of the skin area is obtained through skin segmentation to calculate the percentage threshold, giving more weight to the skin area. This can better process portrait images under complex lighting conditions and improve the practicality and user experience of the portrait de-graying function. BRIEF DESCRIPTION OF THE DRAWINGS

[0045] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0046] Figure 1 A flowchart of an adaptive image de-dusting method provided by one embodiment of the present invention is shown.

[0047] Figure 2 A CDF diagram of conventionally determining a black field threshold and a white field threshold provided by an embodiment of the present invention.

[0048] Figure 3 A schematic diagram of the distribution of minimum value points of a histogram corresponding to a grayscale value probability density function in a black field threshold search range provided by an embodiment of the present invention.

[0049] Figure 4 A schematic diagram of the distribution of minimum value points of a histogram corresponding to a grayscale value probability density function in a white field threshold search range provided by an embodiment of the present invention.

[0050] Figure 5 A schematic diagram comparing the effects of different dust removal methods provided in one embodiment of the present invention.

[0051] Figure 6 A schematic structural diagram of an adaptive image dedubbing device provided by one embodiment of the present invention.

[0052] The realization of the objectives of the invention, the functional features and advantages will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION

[0053] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention. Therefore, the following detailed description of the embodiments of the present invention provided in the drawings is not intended to limit the scope of the invention for which protection is sought, but merely represents selected embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.

[0054] The present invention is described in detail below with reference to the embodiments.

[0055] Reference Figure 1 FIG2 is a flow chart of an adaptive image de-graying method provided by an embodiment of the present invention.

[0056] In this embodiment, the method includes:

[0057] S11, calculating the gray value probability density function and gray value cumulative distribution function of the input image.

[0058] Furthermore, in step S11, the grayscale value probability density function and grayscale value cumulative distribution function of the input image are calculated, including:

[0059] S11-1, calculating according to the number of pixels of gray value i in the input image and the total number of pixels in the image to obtain the gray value probability density function;

[0060] S11-2, calculating the cumulative sum of the gray value probability density function at the corresponding gray value i to obtain the gray value cumulative distribution function.

[0061] In this embodiment, according to Calculate the gray value probability density function (PDF) of the input image. PDF reflects the probability of occurrence of each pixel gray value in the image. The gray value calculation formula is expressed as: gray = r*0.299+g*0.587+b*0.114; p(i) represents the probability of gray level i, n i Represents the number of pixels at gray level i, N represents the total number of pixels in the image (i.e., N = H × W), and the value range of i is 0≤i≤255 (for 8-bit grayscale images). Calculate the grayscale cumulative distribution function (CDF), which represents the cumulative probability of pixels with a grayscale value i or below.

[0062] In the conventional method, the grayscale cumulative distribution function is set as the black field threshold when the grayscale value corresponds to the threshold (for example, 0.2% of the total number of pixels), and the grayscale cumulative distribution function is set as the white field threshold when the grayscale value corresponds to the threshold (for example, 99.8% of the total number of pixels), that is, CDF (black field threshold) = 0.002, CDF (white field threshold) = 0.998, as shown in Figure 2. Figure 2 It is generally believed that the black field threshold black_value is less than 30 or less, and the white field threshold white_value is greater than 220 or more.

[0063] S12, adjusting the search ranges of the black field threshold and the white field threshold based on the gray value probability density function to obtain a black field threshold adjustment range and a white field threshold adjustment range.

[0064] Furthermore, in step S12, adjusting the search ranges of the black field threshold and the white field threshold based on the gray value probability density function to obtain the black field threshold adjustment range and the white field threshold adjustment range includes:

[0065] S12-1, by expanding the search ranges of the black field threshold and the white field threshold, obtaining a black field threshold search range and a white field threshold search range;

[0066] S12-2, determining a maximum minimum value point within the black field threshold search range and a minimum minimum value point within the white field threshold search range based on the gray value probability density function;

[0067] S12-3, adjusting the search ranges of the black field threshold search range and the white field threshold search range according to the maximum minimum value point and the minimum minimum value point, to obtain the black field threshold adjustment range and the white field threshold adjustment range.

[0068] In this embodiment, there is still room for adjustment for the black field threshold black_value and the white field threshold white_value, which can be used to solve more complex de - graying problems. In other words, in order to obtain a de - graying effect with higher contrast, the search ranges of the black field threshold and the white field threshold can be appropriately expanded. Specifically, the search ranges of the black field threshold and the white field threshold can be expanded according to the actual situation respectively. First, let the search range of the black field threshold be s1 = [0, black_pixel_gate] = [0, 80], and the search range of the white field threshold be s2 = [white_pixel_gate, 255] = [200, 255]. The above - mentioned settings of the search range of the black field threshold or the white field threshold can be set according to the following. Specifically, each image in a batch of sampled image data is processed as follows: The black field threshold is obtained when the gray - value cumulative distribution function corresponds to the gray value at a threshold (such as 0.2% of the total number of pixels), and the white field threshold is obtained when the gray - value cumulative distribution function corresponds to the gray value at a threshold (such as 99.8% of the total number of pixels). The upper bound r of the search range of the black field threshold here is set to the median or an integer multiple of the median in the set of black field thresholds obtained from this batch of data, and the lower bound t of the search range of the white field threshold here is set to the median or a decimal multiple of the median in the set of white field thresholds of the data set. Thus, the search range of the black field threshold is defined as [0, r], and the search range of the white field threshold is defined as [t, 255]. Furthermore, in the set of minimum - value points of the histogram (corresponding to the gray - value probability density function obtained above), the maximum minimum - value index within the search range of the black field threshold (i.e., [0, 80]) and the minimum minimum - value point index within the search range of the white field threshold (i.e., [200, 255]) are initially screened. Specifically:

[0069] We believe that at the minimum - value points of the histogram, the number of image pixels aggregated is less than that at other points, and the corresponding affected image area is also relatively small. Such stable points, as the black field threshold or the white field threshold, will not change the regional distribution state of image pixels and are more suitable as candidate points (the set of minimum - value points within the search ranges of the black field threshold and the white field threshold). For example, for a gray - value image of a histogram with only two peaks p1 and p2, where p1 < p2, the picture can be divided into two categories c1 and c2 according to the gray value, and the gray - value distribution is near p1 and p2. If a certain point p12 near p1 is selected as the black field threshold, then category c1 will be divided into two categories on the left and right at p12. If the black field threshold is selected at the peak valley (i.e., a certain minimum - value point) between p1 and p2, the regional distribution state of the original image gray value can be minimally disrupted.

[0070] Since the set of histogram minimum points may be relatively small, in actual use, the white field threshold or black field threshold will be searched near the minimum point that meets the requirements. For the optimization of the black field threshold, we hope to obtain a relatively large value, so we need to select the maximum extreme point s1_p within the black field threshold search range s1; similarly, we need to select the minimum extreme point s2_p within the white field threshold search range s2. For example, for the corresponding Figure 2 The minimum value point set of the gray value probability density function includes index1=4, index2=57, index3=85...., but only index1 and index2 are within the black field threshold search range s1=[0,80], so the maximum minimum value s1_p=index=57, such as Figure 3 Similarly, in the white field threshold search range s2 = [200, 255], the minimum point set includes index1 = 212, index2 = 221, index3 = 227, index4 = 250, so the minimum extreme point in s2 is s2_p = index1 = 212, as shown in Figure 4 Furthermore, the search ranges of the black field threshold and the white field threshold are adjusted according to s1_p and s2_p, and the black field threshold adjustment range s1_new = [0, s1_p] = [0, 57] and the white field threshold adjustment range s2_new = [s2_p, 255] = [212, 255] are obtained.

[0071] S13 , selecting an optimal point of the grayscale value cumulative distribution function that meets a preset value within the black field threshold adjustment range and the white field threshold adjustment range, respectively, to obtain an optimal black field threshold and an optimal white field threshold.

[0072] Furthermore, in step S13, the optimal point of the grayscale value cumulative distribution function that meets the preset value is selected within the black field threshold adjustment range and the white field threshold adjustment range respectively to obtain the optimal black field threshold and the optimal white field threshold, including:

[0073] S13-1, calculating according to the image average brightness and the intermediate brightness value of the input image to obtain a black field percentage threshold and a white field percentage threshold;

[0074] S13-2, determining an optimal point of the grayscale value cumulative distribution function that is smaller than the black field percentage threshold in the black field threshold adjustment range, to obtain the optimal black field threshold;

[0075] S13-3, determining an optimal point of the grayscale value cumulative distribution function that is greater than the white field percentage threshold within the white field threshold adjustment range, and obtaining the optimal white field threshold.

[0076] Furthermore, in step S13-1, the black field percentage threshold and the white field percentage threshold are obtained by calculating the image average brightness and the intermediate brightness value of the input image, including:

[0077] S13-1-1, determining the distance between the average brightness of the image and the middle brightness value to obtain a brightness distance, wherein the middle brightness value is 128;

[0078] S13-1-2, calculate the product of the brightness distance and the preset parameter adjustment coefficient, and calculate the sum of the product result and the lower limit threshold to obtain the black field percentage threshold and the white field percentage threshold.

[0079] In this embodiment, by properly designing black_percent_gate, the optimal point of the grayscale value cumulative distribution function that is smaller than black_percent_gate is found in the black threshold search range s1_new as the black threshold, and the optimal point of the grayscale value cumulative distribution function that is larger than black_percent_gate is found in the white threshold search range s2_new as the white threshold. Specifically:

[0080] Let black_precent_gate be a linear function of the image's average brightness: black_precent_gate = lower_threshold + k*distance. Here, lower_threshold is a fixed value (lower threshold) that can be set to 0.01; k is a tuning factor that needs to be adjusted based on the actual scene; and distance is the distance between the image's average brightness and the median brightness of 128. We assume that a lower average brightness indicates a darker image. To achieve greater contrast, the calculated black threshold should be larger, so the control condition for the black threshold, black_percent_gate, is set to a larger value. black_percent_gate can also be designed as a quadratic or higher-order function related to brightness (for example, a quadratic function can be expressed as black_precent_gate = lower_threshold + k1*distance + k2*distance*distance; k1 and k2 represent tuning factors. A higher-order function can be expressed as black_precent_gate = lower_threshold + k1*distance + k2*distance^2 + ... + kn*distance^N; k1, k2, ..., kn represent the parameters to be adjusted). In the same way, white_percent_gate=lower_threshold+k*distance.

[0081] The following further explains the adjustment process for parameter k: The black threshold primarily affects the dark areas of the image. If k is too large, the calculated black threshold will be too large, causing many pixels in the dark areas to be set to 0, resulting in a loss of detail in the dark areas. If k is too small, the calculated black threshold will be too small, resulting in weaker gray removal. The white threshold primarily affects the highlights. If k is too large, the calculated white threshold will be too large, weakening gray removal. If k is too small, the calculated white threshold will be too small, causing many pixels in the highlights to be set to 255, resulting in a loss of highlight detail. For certain industrial applications, such as fluorescent images, where background processing is generally not important, k can be adjusted to a higher black threshold to achieve higher contrast and gray removal. In the field of beauty cameras, both dark and highlight details need to be preserved, so k adjustment requires more precision. The method for finding k is similar to the binary search method, as follows: When selecting the black threshold, K_max is the estimated maximum value of k, and the search range initially has 0 as the left endpoint and K_max as the right endpoint. k0 = mid = K_max / 2 is introduced into the de-dusting program to process the same batch of image data. If the effect image shows excessive loss of shadow and highlight details, the search continues to the left, with the right endpoint updated to right = mid, the left endpoint remains at 0, and k1 = mid = (left + right) / 2 = K_max / 4. If the de-dusting ability of the effect image is weak, the search continues to the right, with the left endpoint updated to left = mid, the right endpoint remains at K_max, and k1 = mid = (left + right) / 2 = K_max * 3 / 4. After repeated experiments, the k value with the strongest de-dusting ability and the highest retention of shadow and highlight details is obtained. The k adjustment process for the white field threshold is similar.

[0082] Furthermore, the input image is a portrait image; in step S13-1-1, determining the distance between the average brightness of the image and the middle brightness value to obtain the brightness distance includes:

[0083] The portrait image is processed through skin segmentation to obtain the average skin brightness of the skin area;

[0084] The distance between the average skin brightness and the middle brightness value is determined to obtain the brightness distance.

[0085] In another embodiment, specialized processing for portrait images is performed: skin segmentation is performed to determine the average skin brightness of the skin area, which is then used instead of the image average brightness to calculate the black_percent_gate. Under these control conditions, the black threshold selected gives more weight to the skin area, enabling processing of portrait images under complex lighting conditions. Specifically, black_percent_gate = lower_threshold + k * distance, where distance is the distance between the average skin brightness of the portrait skin area and the median brightness value of 128.

[0086] The parameter K needs to be adjusted because, in beauty camera scenarios, gray removal requires not only increased midtone contrast but also minimal loss of detail in shadows and highlights. Overadjusting the black_value and white_value thresholds can result in loss of detail in shadows and highlights, while underadjusting them can lead to a weak gray removal effect. Therefore, by controlling the K value, we can find the optimal black and white thresholds for the scenario.

[0087] Furthermore, in step S13-2, determining the optimal point of the grayscale value cumulative distribution function that is smaller than the black field percentage threshold within the black field threshold adjustment range to obtain the optimal black field threshold includes:

[0088] Traversing from the end point of the black field threshold adjustment range to the starting point of the range, a grayscale value that satisfies the grayscale value cumulative distribution function and is less than the black field percentage threshold is selected as the optimal black field threshold.

[0089] Furthermore, in step S13-2, determining the optimal point of the grayscale value cumulative distribution function that is greater than the white field percentage threshold within the white field threshold adjustment range to obtain the optimal white field threshold includes:

[0090] Traversing from the range starting point to the range ending point of the white field threshold adjustment range, a grayscale value that satisfies the grayscale value cumulative distribution function and is greater than the white field percentage threshold is selected as the optimal white field threshold.

[0091] In this embodiment, within the adjusted black field threshold characteristic range [0, s1_p], the grayscale value that satisfies the grayscale value cumulative distribution function value less than black_percent_gate is selected from the end to the starting end as the optimal black field threshold; within the adjusted white field threshold range [s2_p, 255], the grayscale value that satisfies the grayscale value cumulative distribution function value greater than white_percent_gate is selected from the starting end to the end as the optimal white field threshold.

[0092] Define s1_new=[s1_new_a,s1_new_b], s2_new=[s2_new_a,s2_new_b];

[0093] The pseudo code example for searching for the optimal black field threshold and the optimal white field threshold is as follows:

[0094]

[0095] as well as

[0096]

[0097] S14, inputting the optimal black field threshold and the optimal white field threshold into a tone mapping function to apply to the input image, thereby obtaining a de-graying result image.

[0098] In this embodiment, the optimal black field threshold and the optimal white field threshold obtained above are applied to the image to be repaired through a color scale mapping function to achieve a more adaptive portrait or non-portrait gray removal effect.

[0099] Among them, the color scale mapping formula is:

[0100]

[0101] In the formula, inShadows represents the black field threshold of the input image (the optimal black field threshold obtained after the above processing), which is used to convert all input images below this threshold to 0; inHighlights represents the white field threshold of the input image (the optimal white field threshold obtained after the above processing), which is used to convert all input images above this threshold to 255; Vin and Vout are the input pixel value and output pixel value respectively. The color level mapping transformation improves the contrast of the image, making the retouched result more in line with the user's expectations. Figure 5 The left, middle and right parts show the original image of the input image, the image after using the existing default automatic degraving method on the market, and the image after using this solution to automatically degrave the image.

[0102] Reference Figure 6 FIG. 1 is a schematic structural diagram of an adaptive image dedubbing device provided by an embodiment of the present invention.

[0103] In this embodiment, the device 20 includes:

[0104] A calculation unit 21 is used to calculate the gray value probability density function and the gray value cumulative distribution function of the input image;

[0105] An adjusting unit 22 is configured to adjust the search ranges of the black field threshold and the white field threshold based on the gray value probability density function to obtain a black field threshold adjustment range and a white field threshold adjustment range;

[0106] A selection unit 23 is configured to select an optimal point of the grayscale value cumulative distribution function that satisfies a preset value within the black field threshold adjustment range and the white field threshold adjustment range, respectively, to obtain an optimal black field threshold and an optimal white field threshold;

[0107] The de-dusting unit 24 is configured to input the optimal black field threshold and the optimal white field threshold into a tone mapping function to apply the function to the input image, thereby obtaining a de-dusting result image.

[0108] Each unit module of the device 20 can respectively execute the corresponding steps in the above method embodiment, so each unit module will not be described in detail here. Please refer to the description of the corresponding steps above for details.

[0109] The embodiment of the present invention further provides an adaptive image de-dusting device, which includes the adaptive image de-dusting device as described above, wherein the adaptive image de-dusting device can adopt Figure 6 The structure of the embodiment can be executed accordingly. Figure 1 The technical solution of the method embodiment shown has similar implementation principles and technical effects. For details, please refer to the relevant records in the above embodiments and will not be repeated here.

[0110] The device includes: a mobile phone, digital camera, tablet computer, or other device with a camera function, or a device with an image processing function, or a device with an image display function. The device may include components such as a memory, a processor, an input unit, a display unit, and a power supply.

[0111] Among them, the memory can be used to store software programs and modules, and the processor executes various functional applications and data processing by running the software programs and modules stored in the memory. The memory may mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, an application required for at least one function (such as an image playback function, etc.), etc.; the data storage area can store data created according to the use of the device, etc. In addition, the memory may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage device. Accordingly, the memory may also include a memory controller to provide the processor and the input unit with access to the memory.

[0112] The input unit can be used to receive input digital, character, or image information, and generate keyboard, mouse, joystick, optical, or trackball signal input related to user settings and function control. Specifically, the input unit of this embodiment includes not only a camera, but also a touch-sensitive surface (such as a touch display) and other input devices.

[0113] The display unit can be used to display information input by the user or information provided to the user and various graphical user interfaces of the device, which can be composed of graphics, text, icons, videos and any combination thereof. The display unit may include a display panel. Optionally, the display panel can be configured in the form of an LCD (Liquid Crystal Display), an OLED (Organic Light-Emitting Diode), etc. Furthermore, the touch-sensitive surface can cover the display panel. When the touch-sensitive surface detects a touch operation on or near it, it is transmitted to the processor to determine the type of touch event. The processor then provides a corresponding visual output on the display panel based on the type of touch event.

[0114] The embodiment of the present invention further provides a computer-readable storage medium, which may be a computer-readable storage medium included in the memory in the above embodiment; or a computer-readable storage medium that exists independently and is not assembled into a device. The computer-readable storage medium stores at least one instruction, which is loaded and executed by a processor to implement Figure 1 The computer readable storage medium may be a read-only memory, a magnetic disk or an optical disk.

[0115] The embodiment of the present invention further provides a computer program product, including a computer program / instruction, which is loaded and executed by a processor to implement Figure 1 An adaptive image de-graying method is shown.

[0116] It should be noted that the various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. For similar or identical parts between the various embodiments, reference can be made to each other. For the apparatus embodiments, device embodiments, and storage medium embodiments, since they are generally similar to the method embodiments, their descriptions are relatively simple. For relevant parts, reference can be made to the descriptions of the method embodiments.

[0117] Furthermore, in this document, the terms "comprises," "comprising," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, article, or apparatus that includes a list of elements includes not only those elements but also other elements not explicitly listed, or elements inherent to such process, method, article, or apparatus. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not preclude the presence of additional identical elements in the process, method, article, or apparatus that includes the element.

[0118] While the foregoing description shows and describes preferred embodiments of the present invention, it should be understood that the present invention is not limited to the forms disclosed herein and should not be construed as excluding other embodiments. Rather, the present invention can be used in various other combinations, modifications, and environments, and can be modified within the scope of the present invention by the teachings herein or by techniques or knowledge in the relevant art. Modifications and variations made by those skilled in the art without departing from the spirit and scope of the present invention are intended to be within the scope of the appended claims.

Claims

1. An adaptive image de-graying method, characterized in that: The method comprises: Calculate the gray value probability density function and gray value cumulative distribution function of the input image; Based on the grayscale value probability density function, adjusting the search range of the black field threshold and the white field threshold to obtain the black field threshold adjustment range and the white field threshold adjustment range; Selecting the optimal point of the grayscale value cumulative distribution function that meets the preset value within the black field threshold adjustment range and the white field threshold adjustment range respectively, to obtain the optimal black field threshold and the optimal white field threshold; The optimal black field threshold and the optimal white field threshold are input into a tone mapping function to be applied to the input image to obtain a gray removal result image.

2. The adaptive image de-graying method according to claim 1, characterized in that: The step of calculating the grayscale value probability density function and the grayscale value cumulative distribution function of the input image includes: Calculating the grayscale value probability density function based on the number of pixels with grayscale value i in the input image and the total number of pixels in the image; The cumulative sum of the gray value probability density function at the corresponding gray value i is calculated to obtain the gray value cumulative distribution function.

3. The adaptive image de-graying method according to claim 1, characterized in that: The step of adjusting the search ranges of the black field threshold and the white field threshold based on the gray value probability density function to obtain the black field threshold adjustment range and the white field threshold adjustment range includes: By expanding the search ranges of the black field threshold and the white field threshold, a black field threshold search range and a white field threshold search range are obtained; Determine the maximum minimum value point within the black field threshold search range based on the gray value probability density function, and determine the minimum minimum value point within the white field threshold search range; The search ranges of the black field threshold search range and the white field threshold search range are correspondingly adjusted according to the maximum minimum value point and the minimum minimum value point to obtain the black field threshold adjustment range and the white field threshold adjustment range.

4. The adaptive image de-graying method according to claim 1, characterized in that: The step of selecting the optimal point of the grayscale value cumulative distribution function that satisfies a preset value within the black field threshold adjustment range and the white field threshold adjustment range to obtain the optimal black field threshold and the optimal white field threshold comprises: Calculating the black field percentage threshold and the white field percentage threshold based on the average brightness and the median brightness of the input image; Determining an optimal point of the grayscale value cumulative distribution function that is smaller than the black field percentage threshold within the black field threshold adjustment range to obtain the optimal black field threshold; An optimal point of the grayscale value cumulative distribution function that is greater than the white field percentage threshold is determined within the white field threshold adjustment range to obtain the optimal white field threshold.

5. The adaptive image de-graying method according to claim 4, characterized in that: The calculating, based on the image average brightness and the intermediate brightness value of the input image, to obtain the black field percentage threshold and the white field percentage threshold comprises: Determine the distance between the average brightness of the image and the median brightness value to obtain a brightness distance, wherein the median brightness value is 128; The product of the brightness distance and the preset parameter adjustment coefficient is calculated, and the sum of the obtained product result and the lower limit threshold is calculated to obtain the black field percentage threshold and the white field percentage threshold.

6. The adaptive image de-graying method according to claim 5, characterized in that: The input image is a portrait image; and determining the distance between the average brightness of the image and the median brightness value to obtain the brightness distance includes: The portrait image is processed through skin segmentation to obtain the average skin brightness of the skin area; The distance between the average skin brightness and the middle brightness value is determined to obtain the brightness distance.

7. The adaptive image de-graying method according to claim 4, characterized in that: Determining the optimal point of the grayscale value cumulative distribution function that is smaller than the black field percentage threshold in the black field threshold adjustment range to obtain the optimal black field threshold includes: Traversing from the end point of the black field threshold adjustment range to the starting point of the range, a grayscale value that satisfies the grayscale value cumulative distribution function and is less than the black field percentage threshold is selected as the optimal black field threshold.

8. The adaptive image de-graying method according to claim 4, characterized in that: Determining the optimal point of the grayscale value cumulative distribution function that is greater than the white field percentage threshold within the white field threshold adjustment range to obtain the optimal white field threshold includes: Traversing from the range starting point to the range ending point of the white field threshold adjustment range, a grayscale value that satisfies the grayscale value cumulative distribution function and is greater than the white field percentage threshold is selected as the optimal white field threshold.

9. An adaptive image de-dusting device, characterized in that: The device comprises: A calculation unit, used to calculate the gray value probability density function and the gray value cumulative distribution function of the input image; An adjusting unit, configured to adjust the search ranges of the black field threshold and the white field threshold based on the gray value probability density function, to obtain a black field threshold adjustment range and a white field threshold adjustment range; A selection unit is configured to select an optimal point of the grayscale value cumulative distribution function that satisfies a preset value within the black field threshold adjustment range and the white field threshold adjustment range, respectively, to obtain an optimal black field threshold and an optimal white field threshold; The de-ashing unit is configured to input the optimal black field threshold and the optimal white field threshold into a tone mapping function to apply the function to the input image, thereby obtaining a de-ashing result image.

10. An adaptive image de-dusting device, characterized in that: The method comprises a processor, a memory and a computer program stored in the memory, wherein the computer program is executed by the processor to implement the steps of the adaptive image degraving method according to any one of claims 1 to 8.

Citation Information

Patent Citations

  • Exposure correction method for digital images

    US20050254723A1

  • Black / white stretching system using R G B information in an image and method thereof

    US20060153446A1

  • Method and apparatus for image processing

    WO2025067228A1