Image processing method and device, electronic equipment, storage medium and program product

By adjusting the pixel distribution in the highlighted areas of the image's histogram, the distortion and detail loss issues of high dynamic range images displayed on low dynamic range devices are resolved, resulting in a clearer and more natural image presentation.

CN121937299APending Publication Date: 2026-04-28BEIJING XIAOMI MOBILE SOFTWARE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
BEIJING XIAOMI MOBILE SOFTWARE CO LTD
Filing Date
2024-10-25
Publication Date
2026-04-28

AI Technical Summary

Technical Problem

Existing signal acquisition equipment and display terminals cannot effectively process high dynamic range images, resulting in image distortion and loss of detail, which fails to meet users' visual expectations and artistic aesthetics.

Method used

By determining the image's histogram, identifying the target pixel value range and adjusting the number of pixels, and based on the slope change of the cumulative distribution curve, finely adjusting the pixel distribution in the highlighted area, generating a more uniform histogram, and thus reconstructing the target image.

Benefits of technology

It significantly improves the overall visual effect of images, making them clearer and more natural while maintaining rich detail information, and solves the problems of insufficient contrast and loss of detail in bright areas.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121937299A_ABST
    Figure CN121937299A_ABST
Patent Text Reader

Abstract

The invention relates to an image processing method and device, electronic equipment, a storage medium and a program product. The method comprises the following steps: determining a histogram associated with an image to be processed; determining a target pixel value range to be adjusted in the histogram; based on a first cumulative distribution curve corresponding to the histogram, determining a target pixel value of which the slope is greater than a preset slope threshold value according to a pixel value decreasing direction, and based on the target pixel value, adjusting the number of pixels of each pixel value in the range of the target pixel value in the histogram to obtain an adjusted histogram; and determining a processed target image based on the adjusted histogram and the to-be-processed image. Through the method, the light sensation can be enhanced, and the contrast in the target image can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of image processing technology, and in particular to an image processing method and apparatus, electronic device, storage medium, and program product. Background Technology

[0002] In nature, the contrast between light and dark in visual scenes is extremely pronounced, with a dynamic range often spanning an astonishing 1:100,000. In contrast, the dynamic range of current signal acquisition devices (such as cameras and camcorders) and display terminals is typically limited to between 1:256 and 1:1024. To perfectly reproduce the detailed information of real-world scenes on display devices or printing media, it is often necessary to compress the brightness range of this information into a smaller interval. Unfortunately, this compression process is often accompanied by problems such as image distortion and loss of detail, resulting in the final image quality failing to meet user expectations. Summary of the Invention

[0003] To overcome the problems existing in related technologies, this disclosure provides an image processing method and apparatus, electronic device, storage medium, and program product.

[0004] According to a first aspect of the present disclosure, an image processing method is provided, the method comprising:

[0005] Determine the histogram associated with the image to be processed;

[0006] Determine the range of target pixel values ​​to be adjusted in the histogram; wherein the pixel values ​​within the target pixel value range are greater than a first preset pixel threshold.

[0007] Based on the first cumulative distribution curve corresponding to the histogram, target pixel values ​​with a slope greater than a preset slope threshold are determined in the direction of decreasing pixel values; wherein, the slope of the pixel value is determined based on the first cumulative distribution curve, representing the rate of change of the number of pixels corresponding to the pixel value.

[0008] Based on the target pixel value, the number of pixels for each pixel value within the target pixel value range in the histogram is adjusted to obtain an adjusted histogram; wherein, the difference between the number of pixels for each pixel value within the target pixel value range after adjustment is less than the difference between the number of pixels for each pixel value within the target pixel value range before adjustment.

[0009] Based on the adjusted histogram and the image to be processed, the processed target image is determined.

[0010] According to a second aspect of the present disclosure, an image processing apparatus is provided, the apparatus comprising:

[0011] The first determining module is configured to determine the histogram associated with the image to be processed;

[0012] The second determining module is configured to determine the range of target pixel values ​​to be adjusted in the histogram; wherein the pixel values ​​within the target pixel value range are greater than a first preset pixel threshold.

[0013] The third determining module is configured to determine a target pixel value with a slope greater than a preset slope threshold based on the first cumulative distribution curve corresponding to the histogram, in the direction of decreasing pixel value; wherein, the slope of the pixel value is determined based on the first cumulative distribution curve, representing the rate of change of the number of pixels corresponding to the pixel value.

[0014] The adjustment module is configured to adjust the number of pixels of each pixel value within the target pixel value range in the histogram based on the target pixel value, thereby obtaining an adjusted histogram; wherein the difference between the number of pixels of each pixel value within the target pixel value range after adjustment is smaller than the difference between the number of pixels of each pixel value within the target pixel value range before adjustment.

[0015] The fourth determining module is configured to determine the processed target image based on the adjusted histogram and the image to be processed.

[0016] According to a third aspect of the present disclosure, an electronic device is provided, comprising:

[0017] processor;

[0018] Memory used to store computer programs or instructions;

[0019] The processor executes the computer program or instructions to implement the steps of the method described in the first aspect of the present disclosure.

[0020] According to a fourth aspect of the present disclosure, a non-transitory computer-readable storage medium is provided, the storage medium storing a computer program or instructions that, when executed by a processor, implement the steps of the method described in the first aspect of the present disclosure.

[0021] According to a fifth aspect of the present disclosure, a computer program product is provided, including a computer program or instructions, which, when executed by a processor, implement the steps of the method described in the first aspect of the present disclosure.

[0022] The technical solutions provided by the embodiments of this disclosure may include the following beneficial effects:

[0023] In this embodiment, the target pixel value range and target pixel value are obtained from the histogram of the image to be processed. Based on the target pixel value, the number of pixels for each pixel value within the target pixel value range in the histogram is finely adjusted, and then the target image is determined based on the adjusted histogram. Since the target pixel value with a large slope in the highlighted area corresponds to the pixel value of the pixel point with relatively significant pixel value change in the image, and this target pixel value is related to the contrast of the highlighted area, adjusting the number of pixels for each pixel value within the target pixel value range based on this target pixel value can more finely control the degree of adjustment of the number of pixels, making the distribution of the number of pixel values ​​within the target pixel range in the adjusted histogram more uniform. This helps to compensate for any missing contrast in the image to be processed, significantly improving the overall visual effect of the image, making the image look clearer and more natural, while maintaining rich detail information.

[0024] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this disclosure. Attached Figure Description

[0025] The accompanying drawings, which are incorporated in and form a part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure.

[0026] Figure 1 This is a flowchart of an image processing method according to an exemplary embodiment. Figure 1 .

[0027] Figure 2 This is a flowchart of an image processing method according to an exemplary embodiment. Figure 2 .

[0028] Figure 3 This is a complete flowchart illustrating an image processing method according to an exemplary embodiment.

[0029] Figure 4 This is a block diagram illustrating an image processing apparatus according to an exemplary embodiment.

[0030] Figure 5 This is a block diagram illustrating an electronic device according to an exemplary embodiment. Detailed Implementation

[0031] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numerals in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this disclosure. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this disclosure as detailed in the appended claims.

[0032] In the field of image processing, there is a tone mapping method that, after a High Dynamic Range (HDR) image is acquired by an image acquisition module, uses tone mapping to convert the rich details and wide brightness levels of the HDR image into a Low Dynamic Range (LDR) image suitable for display devices. This method preserves the rich details and wide brightness levels of the HDR image, allowing the LDR image to present a wider and more delicate visual effect on the display device. However, this process presents specific technical challenges, especially when processing non-linear images. Specifically, tone mapping technology typically relies on the linear exposure ratio of the images for fusion processing, which requires that the feature information between the images to be fused maintain a linear relationship. If the original HDR image has already undergone non-linear adjustments, such as gamma correction or local contrast enhancement, directly applying a linear exposure ratio fusion method may cause problems. This is because the previous non-linear processing may have disrupted the linear relationship of the image features, leading to problems such as insufficient contrast in bright areas, weakened local contrast, and loss of tonal range in the tone-mapped LDR image. These issues diminish the carefully adjusted visual effects of the original image, resulting in an LDR image that fails to fully meet the user's visual expectations and artistic aesthetics.

[0033] Furthermore, similar situations of insufficient contrast may occur during routine image processing. Especially when adjusting image display parameters, inappropriate contrast settings can lead to loss of detail in bright areas of the image. In other words, improper contrast adjustment may weaken or mask the detail in bright parts of the image, thus affecting the overall image quality and sharpness.

[0034] In response, this disclosure provides an image processing method. Figure 1 This is a flowchart of an image processing method according to an exemplary embodiment. Figure 1 .like Figure 1 As shown, the method mainly includes the following steps:

[0035] S11. Determine the histogram associated with the image to be processed;

[0036] S12. Determine the range of target pixel values ​​to be adjusted in the histogram; wherein the pixel values ​​within the target pixel value range are greater than a first preset pixel threshold.

[0037] S13. Based on the first cumulative distribution curve corresponding to the histogram, determine the target pixel value with a slope greater than a preset slope threshold in the direction of decreasing pixel value; wherein, the slope of the pixel value is determined based on the first cumulative distribution curve, representing the rate of change of the number of pixels corresponding to the pixel value.

[0038] S14. Based on the target pixel value, adjust the number of pixels of each pixel value within the target pixel value range in the histogram to obtain an adjusted histogram; wherein, the difference between the number of pixels of each pixel value within the target pixel value range after adjustment is less than the difference between the number of pixels of each pixel value within the target pixel value range before adjustment.

[0039] S15. Based on the adjusted histogram and the image to be processed, determine the processed target image.

[0040] The image processing method in this disclosure can be applied to electronic devices with image processing functions, such as user equipment (UE), mobile devices, user terminals, tablet computers, personal digital assistants (PDAs), handheld devices, computing devices, and vehicle-mounted devices. It can also be applied to electronic devices with photo or video recording functions, such as wearable devices, cameras, camcorders, drones, and dashcams.

[0041] In step S11, the electronic device determines the histogram associated with the image to be processed, wherein the image to be processed is any given image whose contrast needs to be adjusted, which can be either images whose contrast is lost after being processed by color gamut mapping technology, or ordinary images that originally need to improve their contrast.

[0042] In some embodiments, the electronic device includes an image acquisition component. In response to a detected shooting command, the electronic device acquires an image to be processed via the image acquisition component. The shooting command can be a touch command, a voice command, or the execution of an application within the electronic device that triggers the image acquisition component. The electronic device can detect the shooting command based on the execution of the application. In other embodiments, the electronic device can receive images to be processed sent from other devices, or it can directly acquire images stored locally, such as images from a mobile phone's photo album application.

[0043] In this embodiment, the histogram refers to a statistical distribution map of pixel values ​​in the image to be processed. The horizontal axis of the histogram represents the pixel value (typically from 0 to 255), and the vertical axis represents the number of pixels with that value appearing in the image to be processed. The histogram provides a clear overview of the pixel value distribution in the image to be processed, including highlight areas, dark areas, and midtone areas. The histogram associated with the image to be processed can be the histogram of the image itself, or it can be a histogram determined by a low-frequency image obtained after frequency decomposition of the image to be processed. Correspondingly, in some embodiments, the electronic device can acquire the pixel value of each pixel in the image to be processed and count the number of pixels corresponding to each pixel value, displaying the number of pixels corresponding to each pixel value in the form of a statistical histogram. In other embodiments, the electronic device can first perform frequency decomposition on the image to be processed to obtain low-frequency and high-frequency images of the image to be processed, and then determine the histogram based on the low-frequency image of the image to be processed. The method of determining the histogram based on the low-frequency image can refer to the method of determining the histogram based on the image to be processed in the foregoing embodiments.

[0044] In step S12, the electronic device identifies the target pixel value range to be adjusted in the histogram based on a first preset pixel threshold. Pixel values ​​within the target pixel value range are all greater than the first preset pixel threshold, typically representing relatively brighter parts of the image. In this embodiment, the target pixel value range is obtained to focus on the bright parts of the image to be processed for subsequent targeted adjustments. In some embodiments, the electronic device can directly determine the range between the first pixel value in the histogram that is greater than the first preset pixel threshold and the largest pixel value in the histogram as the target pixel value range.

[0045] In other embodiments, the electronic device may determine the target pixel value range based on the image corresponding to the histogram or based on a first cumulative distribution curve corresponding to the histogram.

[0046] In this embodiment of the disclosure, the image corresponding to the histogram can be the image to be processed, or a low-frequency image of the image to be processed. The first cumulative distribution curve corresponding to the histogram is a curve reflecting the statistical distribution characteristics of the image pixel values. The horizontal axis of the first cumulative distribution curve is the pixel value, and the vertical axis is the cumulative probability of all pixels within the range from the lowest pixel value to the current pixel value in the histogram.

[0047] In step S13, the electronic device calculates the first cumulative distribution curve corresponding to the histogram. It traverses the first cumulative distribution curve from the maximum pixel value to the minimum pixel value, calculating the slope at each pixel value. The slope represents the rate of change in the number of pixels for that pixel value. A large slope indicates a drastic change in the number of pixels near that pixel value, potentially representing edges or details in the image; a small slope indicates a relatively flat change in the number of pixels near that pixel value. The slope difference reflects the change in the number of pixels between adjacent pixel values. The slope at the current pixel value can be obtained by taking the derivative of the first cumulative distribution curve.

[0048] In this embodiment, the electronic device identifies a target pixel value in the first cumulative distribution curve whose slope is greater than a preset slope threshold in a decreasing direction. This target pixel value belongs to a pixel value in a highlighted area of ​​the image where the pixel value change is relatively significant. These pixels typically correspond to significant edges, texture changes, or color transition areas in the image. It should be noted that the target pixel value can be a pixel value within a target pixel value range. In step S14, the electronic device adjusts the number of pixels for each pixel value within the target pixel value range in the histogram based on the target pixel value determined in step S13, obtaining an adjusted histogram. Specifically, the number of pixels corresponding to each pixel value within the target pixel value range in the histogram is redistributed based on the target pixel value. The purpose of this redistribution is to reduce the difference in the number of pixels between pixel values ​​within the target pixel value range. The adjusted histogram shows that the difference in the number of pixels between pixel values ​​within the target pixel value range is smaller than the difference in the number of pixels between pixel values ​​within the target pixel value range before adjustment. Thus, the adjusted histogram is smoother, meaning the distribution of pixel values ​​is more uniform.

[0049] In some embodiments, the electronic device can refer to the pixel value data to the left of the target pixel value on the histogram to set the pixel value data to the right of the target pixel value, thereby flexibly adjusting the pixel values ​​in the histogram to change the distribution of pixel values ​​in the histogram. For example, the number of pixels to the right of the target pixel value can be mapped based on the number of pixels to the left of the target pixel value using a preset weighting coefficient. In order to adjust the relative frequency of pixel values ​​without changing the total number of pixels in the histogram, the electronic device will also perform precise scaling processing on the number of pixels within the target pixel value range. In this way, we can effectively change the distribution pattern of pixel values ​​while keeping the total number of pixels in the histogram unchanged.

[0050] In other embodiments, the electronic device may determine a pixel number clipping threshold for the pixel values ​​in the histogram based on the target pixel value; clip the number of pixels exceeding the pixel number clipping threshold based on the pixel number clipping threshold, and then accumulate the clipped pixels and redistribute them to the target pixel value range. This redistribution may be uniform or based on a specific rule (such as maintaining the original relative proportion).

[0051] In step S15, the electronic device determines the processed target image based on the adjusted histogram and the image to be processed. This process essentially involves reconstructing the original image to be processed based on the new pixel value distribution in the adjusted histogram. Specifically, for each pixel in the image to be processed, the electronic device searches for the corresponding pixel value in the adjusted histogram and determines the mapping position of this new pixel value in the original image. Then, it assigns this new pixel value to the corresponding pixel in the target image. Through this pixel-by-pixel processing, the electronic device ultimately generates a target image with more balanced contrast while preserving the original content to be processed.

[0052] It is understood that in this embodiment of the disclosure, the target pixel value range and target pixel value are obtained from the histogram of the image to be processed. Based on the target pixel value, the number of pixels for each pixel value within the target pixel value range in the histogram is finely adjusted, and then the target image is determined based on the adjusted histogram. Since the target pixel value with a large slope in the highlighted area corresponds to the pixel value of the pixel point with relatively significant pixel value change in the image, and this target pixel value is related to the contrast of the highlighted area, adjusting the number of pixels for each pixel value within the target pixel value range based on this target pixel value can more finely control the degree of adjustment of the number of pixels, making the distribution of the number of pixel values ​​within the target pixel range in the adjusted histogram more uniform. This helps to compensate for the contrast that may be missing in the image to be processed, significantly improving the overall visual effect of the image, making the image look clearer and more natural, while maintaining rich detail information.

[0053] Figure 2 This is a flowchart of an image processing method according to an exemplary embodiment. Figure 2 .like Figure 2 As shown, the method mainly includes the following steps:

[0054] The determination of the histogram associated with the image to be processed includes:

[0055] S21. Determine the histogram of the low-frequency image of the image to be processed;

[0056] S22. Determine the range of target pixel values ​​to be adjusted in the histogram; wherein the pixel values ​​within the range of target pixel values ​​are greater than a first preset pixel threshold.

[0057] S23. Based on the first cumulative distribution curve corresponding to the histogram, determine the target pixel value with a slope greater than a preset slope threshold in the direction of decreasing pixel value; wherein, the slope of the pixel value is determined based on the first cumulative distribution curve, representing the rate of change of the number of pixels corresponding to the pixel value.

[0058] S24. Based on the target pixel value, adjust the number of pixels of each pixel value within the target pixel value range in the histogram to obtain an adjusted histogram; wherein, the difference between the number of pixels of each pixel value within the target pixel value range after adjustment is less than the difference between the number of pixels of each pixel value within the target pixel value range before adjustment.

[0059] The step of determining the processed target image based on the adjusted histogram and the image to be processed includes:

[0060] S25. Based on the adjusted histogram of the low-frequency image and the low-frequency image of the image to be processed, determine the adjusted low-frequency image.

[0061] S26. The adjusted low-frequency image and the high-frequency image of the image to be processed are fused to obtain the target image.

[0062] In step S21, the electronic device performs frequency division processing on the image to be processed, decomposing it into low-frequency and high-frequency images, and determining the histogram of the low-frequency image. The low-frequency image reflects the overall brightness and contrast information of the image to be processed, while the high-frequency image reflects details and textures. In some embodiments, the electronic device may employ methods such as the Laplacian pyramid to construct a Gaussian pyramid layer by layer upwards from the image to be processed, with each layer representing the low-frequency component of the image below it. Starting from the top of the Gaussian pyramid, the current layer image is upsampled layer by layer downwards, and then convolved using a Gaussian kernel to obtain approximate values ​​for newly added pixels. The upsampled image is subtracted from its adjacent next-lower-layer image in the Gaussian pyramid; the resulting difference image is the high-frequency component of the current layer, constituting one layer of the Laplacian pyramid. Through this process, the electronic device can decompose the image to be processed into high-frequency and low-frequency images.

[0063] In other embodiments, the electronic device may apply a Fast Global Smooth Filter (FSG Filter) technique to decompose the image to be processed. The FSG Filter transforms the global smoothing problem into a minimization problem of a weighted quadratic energy function. By minimizing this energy function, a smoothing effect can be achieved on the image. Specifically, the FSG Filter is used to process the input image to be processed, and a smooth base layer image P1 is obtained by minimizing the weighted quadratic energy function. P1 contains the low-frequency information of the image, namely the main structure and smoothed regions of the image. After obtaining the smooth image P1, subtracting P1 from the original image yields the detail layer image P2. P2 contains the high-frequency information of the image, namely the details, edges, and textures of the image.

[0064] In this embodiment of the present disclosure, the electronic device may adjust the histogram of the low-frequency image in steps S22-S24. For specific operation descriptions, please refer to the corresponding operation descriptions in the aforementioned steps S12-S14.

[0065] In step S25, the electronic device can use the histogram of the adjusted low-frequency image to generate a new low-frequency image through inverse transformation. The specific operation process can refer to the histogram processing method of the image to be processed in step S15 above.

[0066] In step S26, the electronic device fuses the adjusted low-frequency image obtained above with the high-frequency components of the original image to obtain the target image. The fusion method can include simple addition, weighted averaging, or more complex multi-scale fusion strategies. This process improves the contrast in the target image while minimizing the impact on the high-frequency content of the original image to preserve as much detail and texture information as possible.

[0067] It is understood that in this embodiment of the present disclosure, by separating low-frequency and high-frequency images from the image to be processed, adjusting the contrast range of the low-frequency image, and fusing the adjusted low-frequency image with the high-frequency image to obtain the target image, the image contrast can be enhanced better while reducing the impact on the detail information of the high-frequency image, making the display effect of the target image more realistic and natural.

[0068] As previously described, the electronic device can determine the target pixel value range based on the image corresponding to the histogram or based on a first cumulative distribution curve corresponding to the histogram. In some embodiments, determining the target pixel value range to be adjusted in the histogram includes:

[0069] Based on the minimum pixel value of the first image region in the image corresponding to the histogram, the starting value of the target pixel value range is determined; wherein, the pixel value of each pixel in the first image region is greater than the second preset pixel threshold.

[0070] or,

[0071] Based on the first cumulative distribution curve, the slope difference between adjacent pixel values ​​is determined in the direction of decreasing pixel value until a target adjacent pixel value with a slope difference greater than a preset slope difference threshold is determined, and the target pixel value with the larger number of pixels corresponding to the pixel value among the target adjacent pixel values ​​is taken as the starting value of the target pixel value range.

[0072] In this embodiment, the electronic device can first identify a first image region in the image corresponding to the histogram. Since the histogram is a histogram of the image to be processed or a histogram of a low-frequency image, the image corresponding to the histogram can be the image to be processed itself or a low-frequency image. The first image region is a region in the image corresponding to the histogram that has specific pixel value characteristics, which may be the main object or region of interest in the image. It is usually characterized by high brightness, vivid colors, etc. The pixel value of each pixel in the first image region is greater than a second preset pixel threshold, wherein the second preset pixel threshold can be set based on the specific operational requirements of the first image region. For example, the second image region can be the sky region in the image.

[0073] In this embodiment of the disclosure, the electronic device further acquires the minimum pixel value among all pixel values ​​in the first image region, and then determines the starting value of the target pixel value range based on the minimum pixel value. Specifically, the pixel values ​​of each pixel in the first image region are compared, and the minimum pixel value is taken as the starting value of the target pixel value range. It can be considered that the starting value is the starting point of the pixel value range that needs to be adjusted. By determining the starting value of the target pixel value range based on the minimum pixel value of a specific region (the first image region), the range of pixel values ​​that need to be adjusted in the image is more accurately reflected, thereby enabling more direct adjustment of these key features in the first image region, which helps to improve the accuracy of image contrast processing.

[0074] In this embodiment of the disclosure, the electronic device can also perform cumulative distribution calculation on the histogram to obtain a first cumulative distribution curve, and traverse the first cumulative distribution curve in the direction of decreasing pixel value to calculate the slope difference between adjacent pixel values. The slope difference between adjacent pixel values ​​in the first cumulative distribution curve reflects the change in the number of pixels between adjacent pixel values. The electronic device traverses from the maximum pixel value to the minimum pixel value in the histogram. During the traversal, when a slope difference is found to be greater than a preset slope difference threshold, the current adjacent pixel value is taken as the target adjacent pixel value. The preset slope difference threshold is used to determine whether the slope difference is significant, thereby determining whether the target pixel value range needs to be adjusted.

[0075] In this embodiment of the disclosure, the electronic device selects the target pixel value with the largest number of corresponding pixels from among the target's adjacent pixel values ​​as the starting value of the target pixel value range. By determining the starting value based on the slope difference of the first cumulative distribution curve, important features in the image to be processed can be preserved, while unnecessary adjustments to unimportant or redundant pixel values ​​can be reduced.

[0076] It is understood that in this embodiment of the disclosure, the starting value of the target pixel value range is determined based on the minimum pixel value of the first image region or the pixel value of the larger number of target adjacent pixels with significantly different slopes in the first cumulative distribution curve. By extending the analysis to the minimum pixel value of the first image region, the determined starting value can reflect the dark details in the image. Alternatively, by using the pixel features with abrupt changes in slope in the first cumulative distribution curve to determine the starting value, the edge contours in the image can be captured more accurately, which is of great significance for improving the detail representation of the image.

[0077] In some other embodiments, determining the range of target pixel values ​​to be adjusted in the histogram includes:

[0078] In response to the existence of a second image region in the image corresponding to the histogram, the maximum pixel value in the histogram is determined as the termination value of the target pixel value range; wherein, the pixel value of each pixel in the second image region is greater than a third preset pixel threshold, and the third preset pixel threshold is greater than the second preset pixel threshold;

[0079] or,

[0080] In response to the absence of the second image region in the image corresponding to the histogram, a termination value for the target pixel value range is determined based on the first image region and the ambient light intensity when the image to be processed was acquired; wherein, the termination value is positively correlated with the pixel mean of the first image region and the ambient light intensity, and the termination value is greater than or equal to the target pixel value.

[0081] In this embodiment of the disclosure, the electronic device determines whether a second image region exists in the image corresponding to the histogram. This process is achieved by comparing the pixel value of each pixel in the image with a third preset pixel threshold. If multiple pixels have pixel values ​​greater than the third preset pixel threshold, it is determined that a second image region exists; otherwise, it is determined that a second image region does not exist. The second image region typically refers to a region in the image with high brightness or significant features, such as a highlight area or a prominent area. For example, the second image region could be a sun area. Since the second image region is more prominent than the first image region, the third preset pixel threshold used to determine the second image region will be greater than the second preset pixel threshold.

[0082] In this embodiment of the disclosure, when a second image region exists in the image corresponding to the histogram, the electronic device determines the maximum pixel value in the histogram as the termination value of the target pixel value range. Because the second image region typically represents the highlighted parts of the image and has higher pixel values, the maximum pixel value can be used as the termination value to preserve the highlight details in the image.

[0083] In this embodiment of the disclosure, when there is no second image region in the image corresponding to the histogram, the electronic device determines a termination value for the target pixel value range based on the first image region and the ambient light intensity. The ambient light intensity is calculated based on data measured by an environmental sensor within the image acquisition device during image acquisition. The termination value is positively correlated with the average pixel value of the first image region and the ambient light intensity. That is, as the average pixel value of the first image region and the ambient light intensity increase, the termination value also increases accordingly. This helps to flexibly and dynamically adjust the target pixel value range based on the degree of brightness change within the scene, even in scenarios where a second image region is absent, to better match and adapt to the actual characteristics.

[0084] It is understood that in this embodiment, processing is performed separately for different image scenes based on whether a second image region exists in the image. When a second image region (i.e., a high-brightness region) exists in the image, the maximum pixel value in the histogram is determined as the termination value of the target pixel value range. This ensures that the pixel values ​​in the high-brightness region are processed appropriately, avoiding over-compression or loss of highlight details. When a second image region does not exist in the image, the termination value is determined based on the first image region (i.e., a darker or medium-brightness region) and the ambient light intensity when the image was captured. This takes into account the actual shooting environment, making the processed image more consistent with human visual habits while maintaining the natural brightness distribution of the image.

[0085] In some embodiments, adjusting the number of pixels for each pixel value within the target pixel value range in the histogram based on the target pixel value to obtain an adjusted histogram includes:

[0086] Based on the target pixel value and the maximum number of pixels corresponding to the pixel values ​​within the target pixel range, a pixel number adjustment threshold is determined;

[0087] The number of pixels within the target pixel range that exceed the pixel number adjustment threshold is accumulated to obtain the cumulative excess number.

[0088] After setting the number of pixels in the target pixel range of the histogram that exceeds the pixel number adjustment threshold as the pixel number adjustment threshold, the accumulated excess number is evenly distributed to each pixel value in the target pixel range of the histogram to obtain the adjusted histogram.

[0089] In this embodiment, the electronic device determines a pixel number adjustment threshold based on the target pixel value and the maximum number of pixels corresponding to pixel values ​​within the target pixel range. The maximum number of pixels is the value with the highest corresponding pixel count among all pixel values ​​within the target pixel range, i.e., the peak pixel count within that target pixel value range. The pixel number adjustment threshold is used to determine which pixel values ​​need adjustment. In short, if the number of pixels for a certain pixel value exceeds this threshold, then it needs to be adjusted. In some embodiments, the pixel number adjustment threshold can be dynamically adjusted based on image features. The electronic device first analyzes features such as brightness, contrast, or color distribution of the image, dynamically calculates a scaling factor based on the analyzed image features, and multiplies the maximum number of pixels by the dynamically calculated scaling factor to obtain an adjusted pixel number value. This value represents the upper limit of the adjusted pixel number based on image features. The adjusted pixel number value is then compared with the target pixel value, and the smaller of the two values ​​is selected as the final pixel number adjustment threshold. This is because a smaller value usually implies stricter adjustment conditions, which helps to further improve the contrast adjustment effect.

[0090] In other embodiments, the electronic device may determine a pixel number adjustment ratio based on the target pixel value, and then determine a pixel number adjustment threshold based on the pixel number adjustment ratio and the maximum pixel number.

[0091] In this embodiment of the disclosure, the electronic device traverses all pixel values ​​within the target pixel range and accumulates the number of pixels whose number exceeds a pixel number adjustment threshold to obtain a cumulative excess number. This cumulative excess number will be used to subsequently distribute the excess value evenly among the pixel values ​​within the target pixel range.

[0092] In this embodiment, the electronic device first sets the number of pixels in the target pixel range that exceed a pixel number adjustment threshold as the pixel number adjustment threshold. Then, the previously calculated cumulative excess number is evenly distributed among the pixel values ​​within the target pixel range. This step aims to adjust the pixel number distribution within the target pixel range by reducing the peak pixel number in the histogram, while maintaining the total pixel number unchanged, making it more uniform. After this adjustment, a new histogram is obtained, with a more uniform pixel number distribution within the target pixel value range. Based on this adjusted histogram, an optimized target image can be generated.

[0093] It is understood that in this embodiment of the present disclosure, by determining the threshold value for adjusting the number of pixels, the number of pixels exceeding the threshold value is limited, which effectively reduces the situation where some pixel values ​​are overly concentrated in the histogram, and redistributes the accumulated excess pixels evenly, so that too much image information is not lost in the process of adjusting the histogram, and the final adjusted histogram shows a smoother distribution of pixel values, thereby effectively improving the visual effect and overall quality of the image.

[0094] In some embodiments, determining the pixel number adjustment threshold based on the target pixel value and the maximum number of pixels corresponding to pixel values ​​within the target pixel range includes:

[0095] Based on the target pixel value, determine the pixel number adjustment ratio;

[0096] The pixel number adjustment threshold is determined based on the product of the pixel number adjustment ratio and the maximum pixel number.

[0097] In this embodiment of the disclosure, the electronic device determines a pixel quantity adjustment ratio based on a target pixel value. The pixel quantity adjustment ratio represents the magnitude of increase or decrease in the number of pixels during subsequent adjustments. In some embodiments, the electronic device can determine the relative position of the target pixel value in the image and the pixel quantity distribution around that pixel value using a histogram, and determine a pixel quantity adjustment ratio based on the relative position information and the pixel quantity distribution. For example, if the target pixel value is large, it may indicate that the brightness in the image is high, and no very large adjustment is needed; therefore, the pixel quantity adjustment ratio can be set to a smaller value.

[0098] In other embodiments, determining the pixel number adjustment ratio based on the target pixel value includes:

[0099] Based on a preset mapping relationship, an initial adjustment ratio corresponding to the target pixel value is determined; wherein, the preset mapping relationship includes a mapping between pixel values ​​and adjustment ratios, and there is a negative correlation between pixel values ​​and adjustment ratios;

[0100] The weighting coefficient of the initial adjustment ratio is determined based on whether a second image region exists in the image corresponding to the histogram; wherein the pixel value of each pixel in the second image region is greater than a third preset pixel threshold.

[0101] The initial adjustment ratio is weighted based on the weighting coefficients to determine the pixel number adjustment ratio.

[0102] In this embodiment of the disclosure, the electronic device determines the initial adjustment ratio corresponding to the target pixel value according to a preset mapping relationship. The preset mapping relationship can be a database or lookup table stored in the electronic device, containing the mapping relationship between pixel values ​​and adjustment ratios. There is a negative correlation between pixel values ​​and adjustment ratios; that is, the higher the pixel value, the smaller the adjustment ratio to retain more bright details in the image; the lower the pixel value, the larger the adjustment ratio to remove unnecessary dark information.

[0103] In this embodiment of the present disclosure, the electronic device determines whether a second image region exists in the image corresponding to the histogram, and determines a weight coefficient for adjusting the initial adjustment ratio based on the determination result. If a second image region exists, a smaller weight coefficient is set to reduce the adjustment range of the number of pixels in the highlighted region; if no second image region exists, a larger weight coefficient is set to maintain or increase the adjustment range of the number of pixels in the region.

[0104] In this embodiment of the disclosure, the electronic device weights the initial adjustment ratio based on weighting coefficients to determine the final pixel number adjustment ratio. For example, the product of the weighting coefficients and the initial adjustment ratio can be used to determine the pixel number adjustment ratio. During this process, the weighting coefficients of the initial adjustment ratio can be adaptively adjusted based on scene information of the second image region, thereby enabling more refined control over the adjustment of pixel values ​​in the histogram.

[0105] In this embodiment of the disclosure, the electronic device determines the pixel number adjustment threshold by multiplying the pixel number adjustment ratio and the maximum pixel number.

[0106] It is understood that in this embodiment of the disclosure, the pixel number adjustment ratio is determined by the target pixel value, and then this ratio is multiplied by the maximum pixel number of the image to precisely set the pixel number adjustment threshold. This process is highly dependent on the actual content of the image, achieving a dynamic response to adjustment needs. Through this method, we can precisely control which pixels will be adjusted and the extent of their adjustment, thereby significantly enhancing the adaptability and accuracy of the adjustment.

[0107] In some embodiments, determining the weighting coefficient of the initial adjustment ratio based on whether a second image region exists in the image corresponding to the histogram includes:

[0108] In response to the presence of the second image region in the image corresponding to the histogram, the variance ratio between the variance of the local image in the high-frequency image of the image to be processed and the variance of the high-frequency image is determined; wherein, the local image is composed of pixels whose pixel values ​​are all greater than a second preset pixel threshold;

[0109] The weighting coefficient is determined based on the area of ​​the second image region, the ambient light intensity when the image to be processed was acquired, and the variance ratio; wherein the weighting coefficient is negatively correlated with the area of ​​the second image region and the ambient light intensity, and positively correlated with the variance ratio.

[0110] In this embodiment of the disclosure, when a second image region exists in the image corresponding to the histogram, the electronic device extracts a high-frequency image of the image to be processed. The high-frequency image mainly contains the edge and texture information of the image, which is very useful for detecting detailed changes in the image. Then, a local image is selected from the high-frequency image. The local image consists of pixels whose pixel values ​​are all greater than a second preset pixel threshold. The purpose of this step is to filter out regions with high brightness or strong contrast in the image for subsequent variance calculation.

[0111] In this embodiment of the disclosure, the electronic device further calculates the variance ratio between the variance of the local image and the variance of the high-frequency image. Variance is a statistic that measures the degree of dispersion of data. The variance ratio can reflect the degree of dispersion of the local image relative to the entire high-frequency image, thereby reflecting the richness of local details of the image to a certain extent.

[0112] In this embodiment, the electronic device determines a weighting coefficient based on the area of ​​the second image region, the ambient light intensity when the image to be processed was acquired, and the variance ratio. The weighting coefficient is negatively correlated with the area of ​​the second image region and the ambient light intensity, and positively correlated with the variance ratio. This means that when the area of ​​the second image region is large and the ambient light intensity is high, the weighting coefficient will decrease accordingly, thereby reducing the influence of the initial adjustment ratio to preserve more of the original bright details in the image; conversely, when the variance of a local image is large, i.e., when there is a lot of texture, the influence of the initial adjustment ratio will increase to reduce overexposure.

[0113] It is understood that in the embodiments of this disclosure, when the second image region exists in the image corresponding to the histogram, intelligent adaptation based on relatively bright scene conditions is achieved by comprehensively considering multiple factors such as the area of ​​the second image region, ambient light intensity, and local variance ratio. The weight coefficient of the initial adjustment ratio is finely adjusted, which not only significantly improves the overall visual effect of the image, but also effectively reduces the over-processing or accidental loss of local details during the image enhancement process, and helps to improve the integrity and detail of information in the image.

[0114] In some embodiments, determining the weighting coefficient of the initial adjustment ratio based on whether a second image region exists in the image corresponding to the histogram includes:

[0115] In response to the absence of the second image region in the image corresponding to the histogram, the weighting coefficient is determined based on the ambient light intensity when the image to be processed is acquired or the average pixel value of the first image region in the image corresponding to the histogram; wherein the weighting coefficient is positively correlated with the ambient light intensity or the average pixel value; and the pixel value of each pixel in the first image region is greater than a second preset pixel threshold.

[0116] In this embodiment of the disclosure, when there is no second image region in the image corresponding to the histogram, the electronic device determines the weighting coefficient of the initial adjustment ratio based on the collected ambient light intensity or the calculated pixel mean. The weighting coefficient is positively correlated with the ambient light intensity or the pixel mean; that is, the higher the ambient light intensity or the larger the pixel mean, the larger the weighting coefficient. This means that in cases of strong ambient light or high overall image brightness, a larger adjustment range is provided for the initial adjustment ratio.

[0117] It is understood that in this embodiment of the present disclosure, when there is no specific second image region in the image, the weighting coefficients are determined by considering the ambient light intensity or the average pixel value of the brighter areas in the image. This achieves intelligent adaptation based on relatively dark scene conditions and finely adjusts the weighting coefficients of the initial adjustment ratio. Since the local features of the image and the overall environment are considered when adjusting the weighting coefficients, the overall visual effect of the image can be significantly improved.

[0118] In some embodiments, determining the processed target image based on the adjusted histogram and the image to be processed includes:

[0119] The adjusted histogram is subjected to histogram equalization to obtain an equalized histogram; wherein the difference in the number of pixels for each pixel value in the equalized histogram is smaller than the difference in the number of pixels for each pixel value in the adjusted histogram.

[0120] The target image is determined based on the equalized histogram and the image to be processed.

[0121] In this embodiment of the disclosure, the electronic device performs histogram equalization processing on the adjusted histogram obtained from the aforementioned processing, using histogram equalization technology to obtain an equalized histogram. This transforms the grayscale histogram of the original image from a relatively concentrated range of pixel values ​​into a uniform distribution across the entire range of pixel values, thereby increasing contrast and making the image clearer. In this embodiment of the disclosure, the difference in the number of pixels for each pixel value in the equalized histogram is smaller than the difference in the number of pixels for each pixel value in the histogram before histogram equalization, thus resulting in a more uniform distribution of pixel values ​​in the equalized histogram.

[0122] In this embodiment of the disclosure, the electronic device can obtain the distribution of each pixel value based on the equalized histogram, and then reconstruct the original image to be processed based on the pixel value distribution corresponding to the equalized histogram to obtain the target image.

[0123] It is understood that by performing equalization processing on the adjusted histogram in this embodiment of the present disclosure, the contrast can be further improved on the basis of the adjusted histogram, resulting in a more uniform brightness distribution, thereby further improving the visual effect of the image to be processed, making it more natural and comfortable.

[0124] In some embodiments, determining the target image based on the equalized histogram and the image to be processed includes:

[0125] Determine the second cumulative distribution curve of the equalized histogram;

[0126] For each pixel value in the second cumulative distribution curve, in response to the cumulative probability corresponding to the pixel value in the second cumulative distribution curve being greater than the probability value corresponding to the pixel value in the preset slope line, the cumulative probability corresponding to the pixel value in the second cumulative distribution curve is updated to the probability value corresponding to the pixel value in the preset slope line, thus obtaining the updated second cumulative distribution curve;

[0127] The target image is determined based on the updated second cumulative distribution curve and the image to be processed.

[0128] In this embodiment of the disclosure, the electronic device calculates a second cumulative distribution curve based on the above-mentioned equalized histogram, wherein the second cumulative distribution curve reflects the statistical distribution characteristics of each pixel value in the equalized histogram.

[0129] In this embodiment, for each pixel value in the second cumulative distribution curve, the electronic device determines whether its corresponding cumulative probability is greater than the probability value of the corresponding pixel value in a preset slope line. The preset slope line is set according to the characteristics of the image and adjustment requirements, and its slope determines the degree of adjustment to the second cumulative distribution curve. If the cumulative probability corresponding to a pixel value in the second cumulative distribution curve is greater than the probability value of the corresponding pixel value in the preset slope line, then the cumulative probability corresponding to that pixel value is updated to the probability value of the corresponding pixel value in the preset slope line; if the cumulative probability corresponding to a pixel value in the second cumulative distribution curve is less than or equal to the probability value of the corresponding pixel value in the preset slope line, then the original value of that pixel value in the second cumulative distribution curve is maintained. This process essentially smooths the steep parts of the second cumulative distribution curve, reducing the possibility of over-enhancing image contrast.

[0130] In this embodiment of the disclosure, the second cumulative distribution curve after the aforementioned cumulative probability value can reduce the risk of excessive image contrast enhancement while retaining the contrast enhancement effect of the equalization histogram. The electronic device can reconstruct the original image to be processed using the pixel value distribution corresponding to the updated second cumulative distribution curve, thereby obtaining the target image.

[0131] It is understood that, in this embodiment of the present disclosure, the slope of the second cumulative distribution curve is finely controlled by introducing a preset slope straight line. This helps to further fine-tune the contrast of the image to be processed and can significantly reduce the "overstretching" phenomenon that may be caused by traditional histogram equalization. In this way, while enhancing the contrast of the image to be processed, the display effect in the target image is also made more natural and softer.

[0132] Figure 3 This is a complete flowchart illustrating an image processing method according to an exemplary embodiment, such as... Figure 3 As shown, it includes the following steps:

[0133] Step S301: High and low frequency separation to obtain the base layer P1 and detail layer P2.

[0134] In this embodiment of the present disclosure, the electronic device performs high-low frequency separation on the image to be processed based on frequency to obtain a basic layer P1, i.e., a low-frequency image, and a detail layer P2, i.e., a high-frequency image.

[0135] Step S302: Obtain the minimum gray level RightBright that is missing in the highlighted area.

[0136] In this embodiment of the disclosure, the electronic device determines the target pixel value with a slope greater than a preset slope threshold based on the first cumulative distribution curve corresponding to the histogram of the low-frequency image P1, in the direction of decreasing pixel value, that is, the minimum gray level RightBright where the bright area is missing; wherein, the slope of the pixel value is determined based on the first cumulative distribution curve, and represents the rate of change of the number of pixels corresponding to the pixel value.

[0137] Step S303: Obtain the starting point StartBin of the histogram adjustment range.

[0138] In this embodiment of the present disclosure, the electronic device determines the starting value, i.e., the starting point StartBin, of the target pixel value range based on the minimum pixel value of the first image region in the image corresponding to the histogram, wherein the pixel value of each pixel in the first image region is greater than a second preset pixel threshold; or based on the first cumulative distribution curve, the slope difference between adjacent pixel values ​​is determined in the direction of decreasing pixel value until a target adjacent pixel value with a slope difference greater than a preset slope difference threshold is determined, and the target pixel value with the larger number of pixels corresponding to the pixel value among the target adjacent pixel values ​​is taken as the starting value of the target pixel value range.

[0139] Step S304: Obtain the Sky Detail Ratio.

[0140] In this embodiment of the disclosure, the electronic device determines the variance ratio between the variance of a local image and the variance of the high-frequency image of the image to be processed; wherein, the local image consists of pixels whose pixel values ​​are all greater than a second preset pixel threshold. In this embodiment of the disclosure, the local region can be the sky, and the variance ratio is the sky detail ratio (SkyDetailRatio).

[0141] Step S305: Determine the histogram clipping value ClipRatio based on RightBright.

[0142] In this embodiment of the disclosure, the electronic device determines the histogram clipping value ClipRatio, which is the adjustment ratio of the number of pixels within the target pixel range, based on the target pixel value RightBright.

[0143] Step S306: Determine if RightBright is relatively large. If yes, proceed to step S307; otherwise, proceed to step S308.

[0144] In this embodiment of the present disclosure, the electronic device determines the size of the target pixel value RightBright. If the target pixel value RightBright is particularly large, it means that more details in the image need to be preserved, so step S307 is executed. If the target pixel value RightBright is relatively small, then in order to improve the contrast in the image, the pixel value distribution within the target pixel value range needs to be smoothed, so step S308 is executed.

[0145] Step S307, ClipRatio decays rapidly.

[0146] In this embodiment of the disclosure, the electronic device sets the ClipRatio to a small value, and the value of ClipRatio decays rapidly.

[0147] Step S308: Determine if the sun exists in the scene. If yes, proceed to step S309; ​​otherwise, proceed to step S310.

[0148] In this embodiment of the present disclosure, the electronic device determines whether the image contains a scene of the sun. If the sun is present, step S309 is executed; if the sun is not present, step S310 is executed.

[0149] Step S309: Adjust the size of ClipRatio according to various conditions; the end point EndBin of the histogram adjustment range is the maximum image brightness.

[0150] In this embodiment of the disclosure, if the image scene contains a sun, the electronic device determines the weighting coefficient of the ClipRatio based on the sun's area, the ambient light intensity when the image to be processed was acquired, and the SkyDetailRatio. The weighting coefficient is negatively correlated with the sun's area and ambient light intensity, and positively correlated with the SkyDetailRatio value. The electronic device also sets the EndBin value, the endpoint of the target pixel value range, to the maximum pixel value in the image.

[0151] Step S310: Adjust the size of ClipRatio and the endpoint EndBin according to various conditions.

[0152] In this embodiment of the disclosure, if the image scene does not contain the sun, the electronic device determines the weighting coefficient for adjusting ClipRatio based on the ambient light intensity and the average pixel value of the sky region when the image to be processed is acquired, wherein the weighting coefficient is positively correlated with either the ambient light intensity or the average pixel value. The electronic device also determines the termination value EndBin of the target pixel value range based on the ambient light intensity and the average pixel value, wherein the termination value is positively correlated with both the average pixel value and the ambient light intensity.

[0153] Step S311: Perform histogram cropping and distribute the cropped portion evenly below the histogram of the entire image.

[0154] In this embodiment of the disclosure, the electronic device clips the number of pixels in the target pixel range that exceeds the ClipRatio based on the histogram clipping value ClipRatio, accumulates the number of clipped pixels to obtain the accumulated pixel count, and distributes the accumulated pixel count equally to all pixel values ​​in the target pixel range to obtain the adjusted histogram.

[0155] Step S312: Calculate the cumulative distribution function of the cropped histogram, and perform image transformation based on the mapping relationship obtained from the cumulative distribution function.

[0156] In this embodiment of the disclosure, the electronic device determines a second cumulative distribution curve based on the adjusted histogram, and performs histogram equalization processing on the second cumulative distribution curve using histogram equalization technology.

[0157] Step S313: Add the detail layer P2 back.

[0158] In this embodiment of the present disclosure, the electronic device determines the equalized low-frequency image based on the equalized histogram, and fuses the low-frequency image with the aforementioned detail image P2 to obtain the processed target image.

[0159] Figure 4 This is a block diagram of an image processing apparatus 400 according to an exemplary embodiment. Figure 4 As shown, the device mainly includes:

[0160] The first determining module 401 is configured to determine the histogram associated with the image to be processed;

[0161] The second determining module 402 is configured to determine the range of target pixel values ​​to be adjusted in the histogram; wherein the pixel values ​​within the target pixel value range are greater than a first preset pixel threshold.

[0162] The third determining module 403 is configured to determine a target pixel value with a slope greater than a preset slope threshold based on the first cumulative distribution curve corresponding to the histogram, in the direction of decreasing pixel value; wherein, the slope of the pixel value is determined based on the first cumulative distribution curve, representing the rate of change of the number of pixels corresponding to the pixel value.

[0163] The adjustment module 404 is configured to adjust the number of pixels of each pixel value within the target pixel value range in the histogram based on the target pixel value, thereby obtaining an adjusted histogram; wherein the difference between the number of pixels of each pixel value within the target pixel value range after adjustment is smaller than the difference between the number of pixels of each pixel value within the target pixel value range before adjustment.

[0164] The fourth determining module 405 is configured to determine the processed target image based on the adjusted histogram and the image to be processed.

[0165] In some embodiments, the first determining module 401 is further configured to determine a histogram of a low-frequency image of the image to be processed;

[0166] The fourth determining module 405 is further configured to determine an adjusted low-frequency image based on the histogram of the low-frequency image after adjustment and the low-frequency image of the image to be processed; and to fuse the adjusted low-frequency image with the high-frequency image of the image to be processed to obtain the target image.

[0167] In some embodiments, the second determining module 402 is further configured to determine the starting value of the target pixel value range based on the minimum pixel value of the first image region in the image corresponding to the histogram; wherein the pixel value of each pixel in the first image region is greater than a second preset pixel threshold; or, based on the first cumulative distribution curve, the slope difference between adjacent pixel values ​​is determined in the direction of decreasing pixel value until a target adjacent pixel value with a slope difference greater than a preset slope difference threshold is determined, and the target pixel value with the larger number of pixels corresponding to the pixel value among the target adjacent pixel values ​​is taken as the starting value of the target pixel value range.

[0168] In some embodiments, the second determining module 402 is further configured to, in response to the existence of a second image region in the image corresponding to the histogram, determine the maximum pixel value in the histogram as the termination value of the target pixel value range; wherein the pixel value of each pixel in the second image region is greater than a third preset pixel threshold, and the third preset pixel threshold is greater than the second preset pixel threshold; or, in response to the absence of a second image region in the image corresponding to the histogram, determine the termination value of the target pixel value range based on the first image region and the ambient light intensity when the image to be processed was acquired; wherein the termination value is positively correlated with the average pixel value of the first image region and the ambient light intensity, and the termination value is greater than or equal to the target pixel value.

[0169] In some embodiments, the adjustment module 404 is further configured to: determine a pixel number adjustment threshold based on the target pixel value and the maximum number of pixels corresponding to the pixel values ​​within the target pixel range; accumulate the number of pixels within the target pixel range that exceeds the pixel number adjustment threshold to obtain a cumulative excess number; set the number of pixels in the histogram corresponding to the pixel values ​​within the target pixel range that exceed the pixel number adjustment threshold as the pixel number adjustment threshold; and then distribute the cumulative excess number equally among the pixel values ​​within the target pixel range in the histogram to obtain the adjusted histogram.

[0170] In some embodiments, the adjustment module 404 is further configured to determine a pixel number adjustment ratio based on the target pixel value; and to determine a pixel number adjustment threshold value based on the product of the pixel number adjustment ratio and the maximum pixel number.

[0171] In some embodiments, the adjustment module 404 is further configured to determine an initial adjustment ratio corresponding to the target pixel value based on a preset mapping relationship; wherein the preset mapping relationship includes a mapping between pixel values ​​and adjustment ratios, and there is a negative correlation between pixel values ​​and adjustment ratios; determine a weight coefficient for the initial adjustment ratio based on whether a second image region exists in the image corresponding to the histogram; wherein the pixel value of each pixel in the second image region is greater than a third preset pixel threshold; and determine the pixel quantity adjustment ratio by weighting the initial adjustment ratio based on the weight coefficient.

[0172] In some embodiments, the adjustment module 404 is further configured to, in response to the existence of the second image region in the image corresponding to the histogram, determine the variance ratio between the variance of a local image in the high-frequency image of the image to be processed and the variance of the high-frequency image; wherein the local image is composed of pixels whose pixel values ​​are all greater than a second preset pixel threshold; and determine the weighting coefficient based on the area of ​​the second image region, the ambient light intensity when the image to be processed was acquired, and the variance ratio; wherein the weighting coefficient is negatively correlated with the area of ​​the second image region, the ambient light intensity, and the variance ratio.

[0173] In some embodiments, the adjustment module 404 is further configured to, in response to the absence of the second image region in the image corresponding to the histogram, determine the weight coefficient based on the ambient light intensity when the image to be processed is collected or the average pixel value of the first image region in the image corresponding to the histogram; wherein the weight coefficient is positively correlated with the ambient light intensity or the average pixel value; and the pixel value of each pixel in the first image region is greater than a second preset pixel threshold.

[0174] In some embodiments, the fourth determining module 405 is further configured to perform histogram equalization processing on the adjusted histogram to obtain an equalized histogram; wherein the difference between the number of pixels of each pixel value in the equalized histogram is less than the difference between the number of pixels of each pixel value in the adjusted histogram; and to determine the target image based on the equalized histogram and the image to be processed.

[0175] In some embodiments, the fourth determining module 405 is further configured to: determine a second cumulative distribution curve of the equalized histogram; for each pixel value in the second cumulative distribution curve, in response to the cumulative probability corresponding to the pixel value in the second cumulative distribution curve being greater than the probability value corresponding to the pixel value in the preset slope line, update the cumulative probability corresponding to the pixel value in the second cumulative distribution curve to the probability value corresponding to the pixel value in the preset slope line, thereby obtaining an updated second cumulative distribution curve; and determine the target image based on the updated second cumulative distribution curve and the image to be processed.

[0176] Regarding the apparatus in the above embodiments, the specific manner in which each module performs its operation has been described in detail in the embodiments related to the method, and will not be elaborated upon here.

[0177] Figure 5 This is a structural block diagram of an electronic device 500 according to an exemplary embodiment. For example, the electronic device 500 can be an electronic device with image processing capabilities, such as a user equipment (UE), mobile device, user terminal, tablet computer, personal digital assistant (PDA), handheld device, computing device, or in-vehicle device. It can also be an electronic device with photography or video recording capabilities, such as a wearable device, camera, camcorder, drone, or dashcam.

[0178] Reference Figure 5 The electronic device 500 may include one or more of the following components: processing component 502, memory 504, power supply component 506, multimedia component 508, audio component 510, input / output (I / O) interface 512, sensor component 514, and communication component 516.

[0179] Processing component 502 typically controls the overall operation of electronic device 500, such as operations associated with at least one of display, telephone call, data communication, camera operation, and recording operation. Processing component 502 may include one or more processors 520 to execute instructions to perform all or part of the steps of the methods described above. Furthermore, processing component 502 may include one or more modules to facilitate interaction between processing component 502 and other components. For example, processing component 502 may include a multimedia module to facilitate interaction between multimedia component 508 and processing component 502.

[0180] Memory 504 is configured to store various types of data to support operation on electronic device 500. Examples of such data include at least one of the following: instructions for any application or method operating on electronic device 500, contact data, phonebook data, messages, pictures, and videos. Memory 504 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as Static Random Access Memory (SRAM), Electrically Erasable Programmable Read Only Memory (EEPROM), Erasable Programmable Read-Only Memory (EPROM), Programmable Read Only Memory (PROM), Read-Only Memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk.

[0181] Power supply component 506 provides power to various components of electronic device 500. Power supply component 506 may include at least one of the following: a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to electronic device 500.

[0182] Multimedia component 508 includes a screen that provides an output interface between electronic device 500 and user. In some embodiments, the screen may include a Liquid Crystal Display (LCD) and a Touch Panel (TP). If the screen includes a Touch Panel, the screen may be implemented as a touchscreen to receive input signals from the user. The Touch Panel includes one or more touch sensors to sense touches, swipes, and gestures on the Touch Panel. The touch sensors may sense not only the boundaries of touch or swipe actions but also the duration and pressure associated with the touch or swipe operation. In some embodiments, multimedia component 508 includes a front-facing camera and / or a rear-facing camera. When electronic device 500 is in an operating mode, such as a shooting mode or video mode, the front-facing camera and / or rear-facing camera may receive external multimedia data. Each front-facing camera and rear-facing camera may be a fixed optical lens system or have focal length and optical zoom capabilities.

[0183] Audio component 510 is configured to output and / or input audio signals. For example, audio component 510 includes a microphone (MIC) configured to receive external audio signals when electronic device 500 is in an operating mode, such as call mode, recording mode, and voice recognition mode. The received audio signals may be further stored in memory 504 or transmitted via communication component 516. In some embodiments, audio component 510 also includes a speaker for outputting audio signals.

[0184] I / O interface 512 provides an interface between processing component 502 and peripheral interface modules, such as keyboards, click wheels, and buttons. These buttons may include, but are not limited to, home buttons, volume buttons, power buttons, and lock buttons.

[0185] Sensor assembly 514 includes one or more sensors for providing state assessments of various aspects of electronic device 500. For example, sensor assembly 514 may detect the on / off state of electronic device 500, the relative positioning of components such as the display and keypad of electronic device 500, changes in position of electronic device 500 or one of its components, the presence or absence of user contact with electronic device 500, orientation or acceleration / deceleration of electronic device 500, and temperature changes of electronic device 500. Sensor assembly 514 may include a proximity sensor configured to detect the presence of nearby objects without any physical contact. Sensor assembly 514 may also include an optical sensor, such as a complementary metal-oxide-semiconductor (CMOS) or charge-coupled device (CCD) image sensor, for use in imaging applications. In some embodiments, sensor assembly 514 may also include, but is not limited to, at least one of the following: an accelerometer, a gyroscope, a magnetometer, a pressure sensor, and a temperature sensor.

[0186] Communication component 516 is configured to facilitate wired or wireless communication between electronic device 500 and other devices. Electronic device 500 can access wireless networks based on communication standards, such as Wi-Fi, 4G, 5G, or combinations thereof. In one exemplary embodiment, communication component 516 receives broadcast signals or broadcast-related information from an external broadcast management system via a broadcast channel. In one exemplary embodiment, communication component 516 also includes a Near Field Communication (NFC) module to facilitate short-range communication. For example, the NFC module may be implemented based on Radio Frequency Identification (RFID), Infrared Data Association (IrDA), Ultra Wide Band (UWB), Bluetooth (BT), and other technologies.

[0187] In an exemplary embodiment, the electronic device 500 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field-programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components.

[0188] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 504 including executable instructions or a computer program, which can be executed by a processor 520 of an electronic device 500 to perform the above-described method. For example, the non-transitory computer-readable storage medium may be a ROM, random access memory (RAM), a compact disc read-only memory (CD-ROM), magnetic tape, floppy disk, and optical data storage device, etc.

[0189] A non-transitory computer-readable storage medium, wherein instructions in the storage medium, when executed by a processor of an electronic device, enable the electronic device to perform any of the image processing methods described above in the embodiments of this disclosure.

[0190] This disclosure provides a computer program product comprising a computer program or executable instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer program or executable instructions from the computer-readable storage medium and executes the computer program or executable instructions, causing the computer device to perform any of the image processing methods described above in this disclosure.

[0191] Other embodiments of this disclosure will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This disclosure is intended to cover any variations, uses, or adaptations of this disclosure that follow the general principles of this disclosure and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this disclosure are indicated by the claims.

[0192] It should be understood that this disclosure is not limited to the precise structures described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this disclosure is limited only by the appended claims.

Claims

1. An image processing method, characterized in that, The method includes: Determine the histogram associated with the image to be processed; Determine the range of target pixel values ​​to be adjusted in the histogram; wherein the pixel values ​​within the target pixel value range are greater than a first preset pixel threshold. Based on the first cumulative distribution curve corresponding to the histogram, target pixel values ​​with a slope greater than a preset slope threshold are determined in the direction of decreasing pixel values; wherein, the slope of the pixel value is determined based on the first cumulative distribution curve, representing the rate of change of the number of pixels corresponding to the pixel value. Based on the target pixel value, the number of pixels for each pixel value within the target pixel value range in the histogram is adjusted to obtain an adjusted histogram; wherein, the difference between the number of pixels for each pixel value within the target pixel value range after adjustment is less than the difference between the number of pixels for each pixel value within the target pixel value range before adjustment. Based on the adjusted histogram and the image to be processed, the processed target image is determined.

2. The method according to claim 1, characterized in that, The determination of the histogram associated with the image to be processed includes: Determine the histogram of the low-frequency image of the image to be processed; The step of determining the processed target image based on the adjusted histogram and the image to be processed includes: The adjusted low-frequency image is determined based on the histogram of the low-frequency image and the low-frequency image of the image to be processed. The target image is obtained by fusing the adjusted low-frequency image with the high-frequency image of the image to be processed.

3. The method according to claim 1 or 2, characterized in that, Determining the range of target pixel values ​​to be adjusted in the histogram includes: Based on the minimum pixel value of the first image region in the image corresponding to the histogram, the starting value of the target pixel value range is determined; wherein, the pixel value of each pixel in the first image region is greater than the second preset pixel threshold. or, Based on the first cumulative distribution curve, the slope difference between adjacent pixel values ​​is determined in the direction of decreasing pixel value until a target adjacent pixel value with a slope difference greater than a preset slope difference threshold is determined, and the target pixel value with the larger number of pixels corresponding to the pixel value among the target adjacent pixel values ​​is taken as the starting value of the target pixel value range.

4. The method according to claim 3, characterized in that, Determining the range of target pixel values ​​to be adjusted in the histogram includes: In response to the existence of a second image region in the image corresponding to the histogram, the maximum pixel value in the histogram is determined as the termination value of the target pixel value range; wherein, the pixel value of each pixel in the second image region is greater than a third preset pixel threshold, and the third preset pixel threshold is greater than the second preset pixel threshold; or, In response to the absence of the second image region in the image corresponding to the histogram, a termination value for the target pixel value range is determined based on the first image region and the ambient light intensity when the image to be processed was acquired; wherein, the termination value is positively correlated with the pixel mean of the first image region and the ambient light intensity, and the termination value is greater than or equal to the target pixel value.

5. The method according to claim 1 or 2, characterized in that, The step of adjusting the number of pixels for each pixel value within the target pixel value range in the histogram based on the target pixel value to obtain the adjusted histogram includes: Based on the target pixel value and the maximum number of pixels corresponding to the pixel values ​​within the target pixel range, a pixel number adjustment threshold is determined; The number of pixels within the target pixel range that exceed the pixel number adjustment threshold is accumulated to obtain the cumulative excess number. After setting the number of pixels in the target pixel range of the histogram that exceeds the pixel number adjustment threshold as the pixel number adjustment threshold, the accumulated excess number is evenly distributed to each pixel value in the target pixel range of the histogram to obtain the adjusted histogram.

6. The method according to claim 5, characterized in that, The step of determining the pixel number adjustment threshold based on the target pixel value and the maximum number of pixels corresponding to pixel values ​​within the target pixel range includes: Based on the target pixel value, determine the pixel number adjustment ratio; The pixel number adjustment threshold is determined based on the product of the pixel number adjustment ratio and the maximum pixel number.

7. The method according to claim 6, characterized in that, Determining the pixel number adjustment ratio based on the target pixel value includes: Based on a preset mapping relationship, an initial adjustment ratio corresponding to the target pixel value is determined; wherein, the preset mapping relationship includes a mapping between pixel values ​​and adjustment ratios, and there is a negative correlation between pixel values ​​and adjustment ratios; The weighting coefficient of the initial adjustment ratio is determined based on whether a second image region exists in the image corresponding to the histogram; wherein the pixel value of each pixel in the second image region is greater than a third preset pixel threshold. The initial adjustment ratio is weighted based on the weighting coefficients to determine the pixel number adjustment ratio.

8. The method according to claim 7, characterized in that, The step of determining the weighting coefficients for the initial adjustment ratio based on whether a second image region exists in the image corresponding to the histogram includes: In response to the presence of the second image region in the image corresponding to the histogram, the variance ratio between the variance of the local image in the high-frequency image of the image to be processed and the variance of the high-frequency image is determined; wherein, the local image is composed of pixels whose pixel values ​​are all greater than a second preset pixel threshold; The weighting coefficient is determined based on the area of ​​the second image region, the ambient light intensity when the image to be processed was acquired, and the variance ratio; wherein the weighting coefficient is negatively correlated with the area of ​​the second image region and the ambient light intensity, and positively correlated with the variance ratio.

9. The method according to claim 7, characterized in that, The step of determining the weighting coefficients for the initial adjustment ratio based on whether a second image region exists in the image corresponding to the histogram includes: In response to the absence of the second image region in the image corresponding to the histogram, the weighting coefficient is determined based on the ambient light intensity when the image to be processed is acquired or the average pixel value of the first image region in the image corresponding to the histogram; wherein the weighting coefficient is positively correlated with the ambient light intensity or the average pixel value; and the pixel value of each pixel in the first image region is greater than a second preset pixel threshold.

10. The method according to claim 1, characterized in that, The step of determining the processed target image based on the adjusted histogram and the image to be processed includes: The adjusted histogram is subjected to histogram equalization to obtain an equalized histogram; wherein the difference in the number of pixels for each pixel value in the equalized histogram is smaller than the difference in the number of pixels for each pixel value in the adjusted histogram. The target image is determined based on the equalized histogram and the image to be processed.

11. The method according to claim 10, characterized in that, Determining the target image based on the equalized histogram and the image to be processed includes: Determine the second cumulative distribution curve of the equalized histogram; For each pixel value in the second cumulative distribution curve, in response to the cumulative probability corresponding to the pixel value in the second cumulative distribution curve being greater than the probability value corresponding to the pixel value in the preset slope line, the cumulative probability corresponding to the pixel value in the second cumulative distribution curve is updated to the probability value corresponding to the pixel value in the preset slope line, thus obtaining the updated second cumulative distribution curve; The target image is determined based on the updated second cumulative distribution curve and the image to be processed.

12. An image processing apparatus, characterized in that, The device includes: The first determining module is configured to determine the histogram associated with the image to be processed; The second determining module is configured to determine the range of target pixel values ​​to be adjusted in the histogram; wherein the pixel values ​​within the target pixel value range are greater than a first preset pixel threshold. The third determining module is configured to determine target pixel values ​​with a slope greater than a preset slope threshold based on the first cumulative distribution curve corresponding to the histogram, in the direction of decreasing pixel values; wherein, the slope of the pixel value is determined based on the first cumulative distribution curve, representing the rate of change of the number of pixels corresponding to the pixel value. The adjustment module is configured to adjust the number of pixels of each pixel value within the target pixel value range in the histogram based on the target pixel value, thereby obtaining an adjusted histogram; wherein the difference between the number of pixels of each pixel value within the target pixel value range after adjustment is smaller than the difference between the number of pixels of each pixel value within the target pixel value range before adjustment. The fourth determining module is configured to determine the processed target image based on the adjusted histogram and the image to be processed.

13. An electronic device, characterized in that, include: processor; Memory used to store computer programs or instructions; The processor executes the computer program or instructions to implement the steps of the method according to any one of claims 1 to 11.

14. A non-transitory computer-readable storage medium storing a computer program or instructions, characterized in that, When the computer program or instructions in the storage medium are executed by a processor, the steps of the method according to any one of claims 1 to 11 are implemented.

15. A computer program product, comprising a computer program or instructions, characterized in that, When the computer program or instructions are executed by a processor, they implement the steps of the method according to any one of claims 1 to 11.