Image processing method and device, computer equipment and readable storage medium
By constructing the target mapping curve, the image brightness is adjusted based on the number of pixel points in the image brightness interval, which solves the problem of details disappearing caused by histogram equalization, and improves the accuracy and equipment applicability of image contrast adjustment.
Patent Information
- Application Number
- CN202410135547.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-01-31
- Publication Date
- 2025-08-01
AI Technical Summary
When adjusting image contrast using histogram equalization method in the prior art, it is easy to cause details to disappear and information to be lost, affecting the accuracy of the image.
By counting the number of pixel points in each brightness interval in the image, a target mapping curve is constructed, and the brightness adjustment of the image is performed based on this curve to avoid the problems of grayscale merging and grayscale disappearance.
It achieves the accuracy of image contrast adjustment, retains the original image information, is suitable for devices with less computing power, and has good real-time and applicability.
Smart Images

Figure CN120410941A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image processing technology. Specifically, it relates to an image processing method, apparatus, computer device, and readable storage medium. Background Art
[0002] Image contrast refers to the measurement of different brightness levels between the brightest white and the darkest black in the light and dark areas of an image. The larger the difference range, the greater the contrast, and the smaller the difference range, the smaller the contrast. Images with different contrasts have significant differences in visual effects. Therefore, the image contrast can be adjusted, that is, the brightness values of each pixel point in the original image can be adjusted to enhance its visual effect.
[0003] In the known technology, the histogram equalization method is commonly used to adjust the image contrast. However, when directly using the histogram equalization method, due to the merging of gray levels, problems such as the disappearance of details may occur, that is, the original information of the processed image may be lost and the accuracy may be reduced. Therefore, how to improve the accuracy of image contrast adjustment has become an urgent technical problem to be solved. Summary of the Invention
[0004] This application provides an image processing method, apparatus, computer device, and readable storage medium to improve the accuracy of image contrast adjustment. The specific technical solutions are as follows.
[0005] In a first aspect, an embodiment of this application provides an image processing method, which includes:
[0006] Obtain the image to be processed;
[0007] According to the brightness values of all pixel points of the image to be processed, count the number of pixel points located in preset brightness intervals; the total number of the brightness intervals is greater than or equal to 3;
[0008] According to the number of pixel points in each brightness interval, fuse the basic mapping curves corresponding to each of the brightness intervals that are pre-constructed to obtain the target mapping curve corresponding to the image to be processed;
[0009] >Based on the target mapping curve, perform brightness adjustment on the image to be processed to obtain the processed image.
[0010] In the embodiments of the present application, after obtaining the image to be processed, the number of pixels located in each brightness interval can be counted based on the brightness values of each pixel in the image. That is to say, the overall brightness situation of the image can be obtained. Further, according to the number of pixels in each brightness interval, the mapping curves corresponding to each pre-constructed brightness interval are fused, and a target mapping curve matching the brightness situation of the image to be processed can be obtained. Therefore, after using the target mapping curve to adjust the brightness of the image to be processed, the processed image obtained can retain the original image information to the greatest extent and ensure the accuracy of the processed image. Moreover, the algorithm provided by the embodiments of the present application is simple and clear in overall implementation, with a small amount of calculation, very suitable for being implanted on end devices with less computing power, having high applicability, and can achieve good real-time performance.
[0011] Optionally, the step of fusing the basic mapping curves corresponding to each pre-constructed brightness interval according to the number of pixels in each brightness interval to obtain the target mapping curve corresponding to the image to be processed includes:
[0012] Calculate the pixel ratio of each brightness interval according to the number of pixels in each brightness interval;
[0013] Fuse the basic mapping curves corresponding to each pre-constructed brightness interval according to the pixel ratio of each brightness interval to obtain the target mapping curve corresponding to the image to be processed.
[0014] Optionally, the step of calculating the pixel ratio of each brightness interval according to the number of pixels in each brightness interval includes:
[0015] Determine the total number of pixels included in the image to be processed;
[0016] For each brightness interval, determine the ratio of the number of pixels in this brightness interval to the total number of pixels as the pixel ratio of this brightness interval.
[0017] Optionally, the step of fusing the basic mapping curves corresponding to each pre-constructed brightness interval according to the pixel ratio of each brightness interval to obtain the target mapping curve corresponding to the image to be processed includes:
[0018] Calculate the mapped pixel value map corresponding to any original pixel value in the target mapping curve according to the following formula:
[0019]
[0020] where n is the total number of the brightness intervals, C i is the pixel ratio of the i-th brightness interval, and map i is the mapped pixel value of the original pixel value on the basic mapping curve corresponding to the i-th brightness interval.
[0021] Optionally, the process of constructing the basic mapping curves corresponding to the respective brightness intervals includes:
[0022] For each of the brightness intervals, obtain the respective basic images corresponding to the brightness interval; wherein, the peak of the brightness histogram of each of the basic images is located within the brightness interval;
[0023] For each of the brightness intervals, calculate the average value of the mapping curves of all the basic images corresponding to the brightness interval as the basic mapping curve corresponding to the brightness interval.
[0024] Optionally, the method further includes:
[0025] For each of the brightness intervals, display the basic mapping curve corresponding to the brightness interval, receive an adjustment operation on the basic mapping curve, and adjust the basic mapping curve according to the adjustment operation.
[0026] In this embodiment, the basic mapping curve can be adjusted independently. Since it is sufficiently smooth, it can well solve the problems of gray level merging and gray level disappearance caused by traditional mapping algorithms.
[0027] In a second aspect, an embodiment of the present application provides an image processing apparatus, and the apparatus includes:
[0028] An image acquisition module, configured to acquire an image to be processed; <L
[0029] A pixel statistics module, configured to count the number of pixels located in preset respective brightness intervals according to the brightness values of all pixel points of the image to be processed; the total number of the brightness intervals is greater than or equal to 3;
[0030] A curve fusion module, configured to fuse the basic mapping curves corresponding to the respective brightness intervals pre-constructed according to the number of pixels in the respective brightness intervals to obtain a target mapping curve corresponding to the image to be processed;
[0031] A brightness adjustment module, configured to adjust the brightness of the image to be processed based on the target mapping curve to obtain a processed image.
[0032] Optionally, the curve fusion module includes:
[0033] A ratio calculation sub-module, configured to calculate the pixel ratios of the respective brightness intervals according to the number of pixels in the respective brightness intervals;
[0034] A curve fusion sub-module, configured to fuse the basic mapping curves corresponding to the respective brightness intervals pre-constructed according to the pixel ratios of the respective brightness intervals to obtain a target mapping curve corresponding to the image to be processed.
[0035] Optionally, the ratio calculation sub-module is specifically configured to:
[0036] Determine the total number of pixel points included in the image to be processed;
[0037] For each of the luminance intervals, determine the ratio of the number of pixel points in the luminance interval to the total number of pixel points as the pixel ratio of the luminance interval.
[0038] Optionally, the curve fusion sub-module is specifically configured to:
[0039] Calculate the mapped pixel value map corresponding to any original pixel value in the target mapping curve according to the following formula:
[0040]
[0041] where n is the total number of the luminance intervals, C i is the pixel ratio of the i-th luminance interval, and map i is the mapped pixel value of the basic mapping curve corresponding to the original pixel value in the i-th luminance interval.
[0042] Optionally, the apparatus further includes:
[0043] A basic image acquisition module, configured to, for each of the luminance intervals, acquire each basic image corresponding to the luminance interval; wherein, the peak of the luminance histogram of each basic image is located within the luminance interval;
[0044] A mapping curve calculation module, configured to, for each of the luminance intervals, calculate the average value of the mapping curves of all the basic images corresponding to the luminance interval as the basic mapping curve corresponding to the luminance interval.
[0045] Optionally, the apparatus further includes:
[0046] A mapping curve adjustment module, configured to, for each of the luminance intervals, display the basic mapping curve corresponding to the luminance interval, receive an adjustment operation on the basic mapping curve, and adjust the basic mapping curve according to the adjustment operation.
[0047] In a third aspect, an embodiment of the present application provides a computer device, including: a memory and a processor, the memory and the processor being coupled;
[0048] The memory is used to store one or more computer instructions;
[0049] The processor is used to execute the one or more computer instructions to implement the image processing method as described in the first aspect.
[0050] Fourthly, an embodiment of the present application provides a computer-readable storage medium, on which one or more computer instructions are stored, and the instructions are executed by a processor to implement the image processing method as described in the first aspect above.
[0051] Fifthly, the present application provides a computer program product, which includes a computer program, and when the computer program is executed by a processor, it implements the image processing method as described in the first aspect. Description of the Drawings
[0052] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings required for the description of the embodiments or the prior art. Obviously, the drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0053] Figure 1 It is a schematic flowchart of an image processing method provided by an embodiment of the present application;
[0054] Figure 2 It is an image with different brightness levels and corresponding histograms in an embodiment of the present application;
[0055] Figure 3 In an embodiment of the present application Figure 2 The mapping curve corresponding to the image shown;
[0056] Figure 4 It is a schematic diagram of the overall algorithm architecture of dynamic contrast enhancement in an embodiment of the present application;
[0057] Figure 5 It is the enhanced image and the corresponding histogram in an embodiment of the present application;
[0058] Figure 6 It is a schematic structural diagram of an image processing device provided by an embodiment of the present application;
[0059] Figure 7 It is a schematic structural diagram of a computer device provided by an embodiment of the present application. Detailed Embodiments
[0060] The following will clearly and completely describe the technical solutions in the embodiments of the present application with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments of the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts belong to the scope of protection of the present application.
[0061] It should be noted that the terms "including" and "having" and any variations thereof in the embodiments of the present application and the accompanying drawings are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or device that includes a series of steps or units is not limited to the listed steps or units, but optionally further includes steps or units not listed, or optionally further includes other steps or units inherent to these processes, methods, products, or devices.
[0062] The embodiments of the present application disclose an image processing method, apparatus, computer device, and readable storage medium, which can accurately adjust the image contrast. The embodiments of the present application will be described in detail below.
[0063] In the known art, the most commonly used method for image contrast enhancement is histogram equalization. However, there are certain problems with directly using histogram equalization. For example, the disappearance of details due to gray level merging; or, for some images, such as those with a peak in the histogram, after processing the contrast, noise amplification and over-enhancement of artifacts due to excessive stretching of gray levels. It is found that the essence of histogram equalization is actually to form a mapping curve based on the cumulative histogram distribution to map the original brightness values. Based on this, in the embodiments of the present application, a dynamic mapping curve is formed according to the brightness histogram distribution of the image, so as to dynamically adjust the brightness of the original image and avoid the above problems.
[0064] Figure 1 FIG. is a schematic flow chart of an image processing method provided by an embodiment of the present application. This method can be applied to an electronic device, and the method includes the following steps:
[0065] S110: Obtain an image to be processed.
[0066] The above image to be processed may include a grayscale image or a color image. When the image to be processed is a grayscale image, when adjusting its brightness, the adjusted value is the pixel value of each pixel point, which can also be called the gray value or the brightness value. When the image to be processed is a color image, when adjusting its brightness, the adjusted value is the V channel in its HSV (Hue, Saturation, Value, hue, saturation, brightness) channel, that is, the brightness value.
[0067] S120: According to the brightness values of all pixel points of the image to be processed, count the number of pixel points located in preset brightness intervals; the total number of brightness intervals is greater than or equal to 3.
[0068] In the embodiments of the present application, in order to ensure that in the process of adjusting the brightness of the image, problems such as the disappearance of details due to gray level merging are avoided, the image to be processed can be processed according to the brightness distribution characteristics of the pixel points included in the image to be processed.
[0069] Specifically, it can be understood that the reason for the different image brightnesses is that the brightness values of the individual pixel points included therein are different. When any image includes a relatively large number of pixel points with high brightness values, the overall brightness of the image is relatively high; when any image includes a relatively small number of pixel points with high brightness values, the overall brightness of the image is relatively low. Therefore, the number of pixel points in different brightness intervals in the image can reflect the high or low brightness of the image. Moreover, there are obvious differences in the histograms corresponding to high-brightness images and low-brightness images. For example, the positions where the histogram peaks are located are quite different.
[0070] In the embodiments of the present application, multiple brightness intervals can be preset. For example, in order to ensure the accuracy of brightness differentiation, at least 3 brightness intervals can be set, namely, the low-brightness, medium-brightness, and high-brightness intervals. Or, in order to make the image processing results more accurate, more brightness intervals can be set, which is acceptable. The embodiments of the present application do not limit the number of brightness intervals.
[0071] Taking a grayscale image as an example, the grayscale value range of each pixel point in the image is 0 - 255. When 3 brightness intervals, namely, the low-brightness, medium-brightness, and high-brightness intervals, are set, specifically, the low-brightness interval can be [0, th1], the medium-brightness interval can be (th1, th2), and the high-brightness interval can be [th2, 255]. Among them, the values of th1 and th2 can be set according to the actual situation. For example, th1 can be set to 54, 55, 58, etc., and th2 can be set to 178, 180, 181, etc., which is acceptable. The embodiments of the present application do not make specific limitations on the range of each interval.
[0072] When processing the image to be processed, for each pixel point thereof, its brightness value can be determined, and it can be judged which preset brightness interval range the pixel value is located in. Finally, the number of pixel points located in each brightness interval can be statistically obtained. Or, the brightness histogram of the image to be processed can be determined, and based on the brightness histogram, the number of pixel points located in each brightness interval can be statistically obtained.
[0073] S130: According to the number of pixel points in each brightness interval, fuse the basic mapping curves corresponding to each pre-constructed brightness interval to obtain the target mapping curve corresponding to the image to be processed.
[0074] When enhancing the contrast of an image, its mapping curve can represent the corresponding relationship of the brightness values before and after image processing. It can be understood that for images with different brightnesses, their corresponding mapping curves are also quite different. In the embodiments of the present application, mapping curves corresponding to multiple brightness intervals can be pre-constructed, which can be called basic mapping curves, so as to enhance the contrast of images with any brightness.
[0075] Specifically, when constructing the basic mapping curve, for each brightness interval, the corresponding basic images can be obtained first; among them, the peak of the brightness histogram of each basic image is located within the brightness interval; then, for each brightness interval, the average value of the mapping curves of all the basic images corresponding to the brightness interval is calculated as the basic mapping curve corresponding to the brightness interval.
[0076] Among them, for each brightness interval, the number of basic images obtained can be set according to the actual situation. For example, it can be 800, 900, 1200, etc. All of these are acceptable, and the embodiments of the present application do not limit the specific value. When calculating the average value of the mapping curves of all the basic images corresponding to any brightness interval, for example, for each brightness value, in the mapping curve corresponding to each basic image, the corresponding mapped brightness value can be found, and the average value of all the mapped brightness values can be solved.
[0077] Optionally, after obtaining the basic mapping curves corresponding to each brightness interval, the basic mapping curves can be smoothed. For example, for each brightness interval, the corresponding basic mapping curve can be displayed, and an adjustment operation on the basic mapping curve can be received, and the basic mapping curve can be adjusted according to the adjustment operation.
[0078] That is to say, the mapping curve can be smoothed manually. Specifically, for any brightness interval, after the corresponding basic mapping curve is displayed, the part with poor smoothness can be adjusted manually, and during the adjustment process, the basic image of the brightness interval can be enhanced in contrast using the basic mapping curve, and further, the mapping curve can be adjusted according to the enhancement effect. After multiple adjustments, when the contrast enhancement effect on the basic image meets the requirements, the final basic mapping curve is obtained.
[0079] In this embodiment, the basic mapping curve can be adjusted autonomously. Because it is smooth enough, it can well solve the problems of gray level merging and gray level disappearance caused by traditional mapping algorithms.
[0080] When enhancing the contrast of the image to be processed, after the number of pixel points located in each brightness interval is counted, the basic mapping curves corresponding to each brightness interval pre-constructed can be fused according to the number of pixel points in each brightness interval to obtain the target mapping curve corresponding to the image to be processed.
[0081] It can be understood that the number of pixels in each brightness interval can reflect the overall brightness of the image. When the number of pixels in any brightness interval is small, it indicates that the brightness of the image has a low degree of match with that brightness interval. When the number of pixels in any brightness interval is large, it indicates that the brightness of the image has a high degree of match with that brightness interval. Therefore, based on the number of pixels in each brightness interval, the matching degree between the image to be processed and each brightness interval can be determined, or it can be called the weight of the image to be processed corresponding to each brightness interval. Moreover, the number of pixels in any brightness interval of the image to be processed is proportional to the weight of the image to be processed corresponding to that brightness interval.
[0082] For example, the number of pixels in each brightness interval can be directly used as the weight of the image to be processed corresponding to that brightness interval; or, the number of pixels in each brightness interval can also be normalized, and the normalization result can be used as the weight of the image to be processed corresponding to each brightness interval.
[0083] In one implementation, the pixel ratio of each brightness interval can be calculated according to the number of pixels in each brightness interval; and then, based on the pixel ratios of each brightness interval, the basic mapping curves corresponding to each brightness interval pre-constructed can be fused to obtain the target mapping curve corresponding to the image to be processed.
[0084] Among them, when calculating the pixel ratio of each brightness interval, specifically, the total number of pixels included in the image to be processed can be determined; and for each brightness interval, the ratio of the number of pixels in that brightness interval to the total number of pixels can be determined as the pixel ratio of that brightness interval. That is to say, the ratio of the number of pixels included in each brightness interval to the total number of all pixels can be used as the weight of the image to be processed corresponding to each brightness interval.
[0085] When calculating the target mapping curve corresponding to the image to be processed according to the pixel ratios of each brightness interval and the basic mapping curves corresponding to each brightness interval pre-constructed, the mapping brightness value map corresponding to any original brightness value in the target mapping curve can be calculated according to the following formula:
[0086]
[0087] where n is the total number of brightness intervals, C i is the pixel ratio of the i-th brightness interval, and map i is the mapping brightness value of the original brightness value on the basic mapping curve corresponding to the i-th brightness interval.
[0088] S140: Based on the target mapping curve, perform brightness adjustment on the image to be processed to obtain the processed image.
[0089] In the target mapping curve, the abscissa of each point is the original brightness value, and the ordinate is the mapped brightness value, that is, the adjusted brightness value. For each pixel point in the image to be processed, the corresponding mapped brightness value is found in the target mapping curve and adjusted to the mapped brightness value, and then the image with enhanced contrast can be obtained, which can be called the processed image.
[0090] In the embodiments of the present application, after the image to be processed is obtained, the number of pixel points in each brightness interval can be counted based on the brightness values of the pixel points in the image. That is to say, the overall brightness situation of the image can be obtained. Further, according to the number of pixel points in each brightness interval, the mapping curves corresponding to the pre-constructed brightness intervals are fused to obtain a target mapping curve that matches the brightness situation of the image to be processed. Therefore, after using the target mapping curve to adjust the brightness of the image to be processed, the processed image obtained can retain the original image information to the greatest extent and ensure the accuracy of the processed image. Moreover, the algorithm provided in the embodiments of the present application is simple and clear as a whole, with a small amount of calculation, very suitable for being implanted on end devices with low computing power, high applicability, and can achieve good real-time performance.
[0091] The following combines a specific embodiment to illustrate the image processing method provided in the embodiments of the present application. In this embodiment, a grayscale image is used and 3 brightness intervals are preset by way of example, which does not constitute a limitation to the solution of the present application.
[0092] It is assumed that common typical images are generally divided into three categories: low-brightness, medium-brightness, and high-brightness images. As Figure 2 shown, it successively shows low-brightness, medium-brightness, and high-brightness images, as well as the corresponding histograms. Among them, the abscissa of the histogram is the grayscale value, and the ordinate is the number of pixel points corresponding to any grayscale value. From Figure 2 it can be seen that the peak distributions of the histograms of these three types of images have obvious characteristics, and their peaks are respectively located in the low-brightness area, medium-brightness area, and high-brightness area, so there are very obvious features.
[0093] An optimized fixed mapping curve can be designed for each of the three typical images. When processing an actual image, its histogram distribution includes the characteristics of the histogram distributions of the three types of images. Therefore, according to the proportion of the histogram in different intervals, the three curves can be fused according to a certain weight to obtain an adaptive mapping curve.
[0094] As Figure 3 shown, it shows the Figure 2 three basic mapping curves corresponding to the three types of typical images shown. Moreover, the sources of these three curves are obtained by slightly manually adjusting on the basis of ordinary histogram mapping. Therefore, they can be made smoother, avoiding overexposure or disappearance of certain gray levels in actual use.
[0095] Up to this point, the preparatory work has been completed. Next, the overall algorithm architecture of dynamic contrast enhancement will be introduced. As Figure 4 shown, the algorithm may include the following steps:
[0096] Step 1: Statistically analyze the distribution of the histogram of the original image on 0 - 255.
[0097] Step 2: Calculate the weights of the histogram distribution in three basic regions (low - brightness region [0, th1], medium - brightness region [th1, th2], and high - brightness region [th2, 255]). Among them, th1 and th2 can be set according to empirical values, that is
[0098] Ci = Ni / T
[0099] where i = 1, 2, 3, Ni represents the number of pixels in the i - th brightness region, and T represents the total number of pixels in the image.
[0100] Step 3: According to the weights C1, C2, and C3, perform weighted summation on the three basic mapping curves to obtain a new dynamic mapping curve map.
[0101] Step 4: According to the dynamic mapping curve map, map the gray levels [0 - 255] of the original image to obtain the final enhancement result:
[0102] Y = map(x) x ∈ [0, 255]
[0103] Figure 5 is the enhanced image, and the corresponding histogram. From Figure 5 it can be seen that the enhanced image has a better visual effect, and from the histogram, it can be seen that its gray - level values are evenly distributed.
[0104] As Figure 6 shown, it shows a schematic structural diagram of an image processing device provided by an embodiment of the present application. The device includes:
[0105] An image acquisition module 610, configured to acquire an image to be processed;
[0106] A pixel statistics module 620, configured to statistically analyze the number of pixels located in preset brightness intervals according to the brightness values of all pixel points of the image to be processed; the total number of the brightness intervals is greater than or equal to 3;
[0107] A curve fusion module 630, configured to fuse the basic mapping curves corresponding to the respective brightness intervals constructed in advance according to the number of pixels in the respective brightness intervals to obtain a target mapping curve corresponding to the image to be processed;
[0108] A brightness adjustment module 640, configured to adjust the brightness of the image to be processed based on the target mapping curve to obtain a processed image.
[0109] In the embodiments of the present application, after obtaining the image to be processed, the number of pixels in each brightness interval can be counted based on the brightness values of the pixels in the image. That is to say, the overall brightness situation of the image can be obtained. Further, according to the number of pixels in each brightness interval, the mapping curves corresponding to the pre-constructed brightness intervals are fused, and a target mapping curve matching the brightness situation of the image to be processed can be obtained. Thus, after using the target mapping curve to adjust the brightness of the image to be processed, the processed image obtained can retain the original image information to the greatest extent and ensure the accuracy of the processed image. Moreover, the overall algorithm provided in the embodiments of the present application is simple and clear to implement, with a small amount of calculation, very suitable for being implanted in end devices with relatively low computing power, having high applicability, and can achieve good real-time performance.
[0110] Optionally, the curve fusion module 630 includes:
[0111] A ratio calculation sub-module, configured to calculate the pixel ratio of each brightness interval according to the number of pixels in each brightness interval;
[0112] A curve fusion sub-module, configured to fuse the basic mapping curves corresponding to the pre-constructed brightness intervals according to the pixel ratios of each brightness interval to obtain the target mapping curve corresponding to the image to be processed.
[0113] Optionally, the ratio calculation sub-module is specifically configured to:
[0114] Determine the total number of pixels included in the image to be processed;
[0115] For each of the brightness intervals, determine the ratio of the number of pixels in the brightness interval to the total number of pixels as the pixel ratio of the brightness interval.
[0116] Optionally, the curve fusion sub-module is specifically configured to:
[0117] Calculate the mapped pixel value map corresponding to any original pixel value in the target mapping curve according to the following formula:
[0118]
[0119] where n is the total number of the brightness intervals, C i is the pixel ratio of the i-th brightness interval, and map i is the mapped pixel value of the original pixel value in the basic mapping curve corresponding to the i-th brightness interval.
[0120] Optionally, the device further includes:
[0121] A basic image acquisition module, configured to acquire, for each of the luminance intervals, the respective basic images corresponding to the luminance interval; wherein, the peak value of the luminance histogram of each of the basic images is located within the luminance interval;
[0122] A mapping curve calculation module, configured to calculate, for each of the luminance intervals, the average value of the mapping curves of all the basic images corresponding to the luminance interval as the basic mapping curve corresponding to the luminance interval.
[0123] Optionally, the apparatus further includes:
[0124] A mapping curve adjustment module, configured to display, for each of the luminance intervals, the basic mapping curve corresponding to the luminance interval, and receive an adjustment operation on the basic mapping curve, and adjust the basic mapping curve according to the adjustment operation.
[0125] The above apparatus embodiment corresponds to the method embodiment and has the same technical effect as the method embodiment. For specific descriptions, please refer to the method embodiment. The apparatus embodiment is obtained based on the method embodiment. For specific descriptions, please refer to the method embodiment section and will not be elaborated here.
[0126] Next, a computer device provided in an embodiment of the present application will be introduced. Please refer to Figure 7 , Figure 7 which is a schematic structural diagram of the computer device provided in an embodiment of the present application. The computer device includes:
[0127] One or more processors 40;
[0128] The processor 40 is coupled to a storage device 41, and the storage device 41 is configured to store one or more programs.
[0129] When the one or more programs are executed by the one or more processors 40, the electronic device implements the technical solution of an image processing method as Figures 1 to 5 described.
[0130] An embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored. When the program is executed by a processor, the technical solution of an image processing method as Figures 1 to 5 described is implemented.
[0131] The present application provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the technical solution of an image processing method as Figures 1 to 5 described is implemented.
[0132] Those of ordinary skill in the art can understand that the accompanying drawings are only schematic diagrams of one embodiment, and the modules or processes in the drawings are not necessarily essential for implementing the present application.
[0133] Those of ordinary skill in the art can understand that the modules in the devices in the embodiments can be distributed in the devices in the embodiments as described in the embodiments, or can be correspondingly changed to be located in one or more devices different from the present embodiment. The modules in the above embodiments can be combined into one module, or can be further split into multiple sub-modules.
[0134] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them; although the present application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions recorded in the foregoing embodiments, or perform equivalent replacements on some of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. An image processing method, characterized in that, The method includes: Obtaining an image to be processed; According to the brightness values of all pixel points of the image to be processed, counting the number of pixel points located in each preset brightness interval; the total number of the brightness intervals is greater than or equal to 3; According to the number of pixel points in each brightness interval, fusing the basic mapping curves corresponding to each of the brightness intervals pre-constructed to obtain a target mapping curve corresponding to the image to be processed; Based on the target mapping curve, performing brightness adjustment on the image to be processed to obtain a processed image.
2. The method according to claim 1, characterized in that, The step of fusing the basic mapping curves corresponding to each of the brightness intervals pre-constructed according to the number of pixel points in each brightness interval to obtain a target mapping curve corresponding to the image to be processed includes: According to the number of pixel points in each brightness interval, calculating the pixel ratio of each brightness interval; According to the pixel ratios of each brightness interval, fusing the basic mapping curves corresponding to each of the brightness intervals pre-constructed to obtain a target mapping curve corresponding to the image to be processed.
3. The method according to claim 2, wherein The step of calculating the pixel ratio of each brightness interval according to the number of pixel points in each brightness interval includes: Determining the total number of pixel points included in the image to be processed; For each of the brightness intervals, determining the ratio of the number of pixel points in the brightness interval to the total number of pixel points as the pixel ratio of the brightness interval.
4. The method according to claim 2, wherein The step of fusing the basic mapping curves corresponding to each of the brightness intervals according to the pixel ratios of each brightness interval to obtain a target mapping curve corresponding to the image to be processed includes: According to the following formula, calculating the mapped pixel value map corresponding to any original pixel value in the target mapping curve: where n is the total number of the luminance intervals, and C i is the pixel ratio of the i-th luminance interval, and map i is the mapped pixel value of the basic mapping curve corresponding to the original pixel value in the i-th luminance interval.
5. The method according to any one of claims 1-4, characterized in that, The construction process of the basic mapping curves corresponding to each of the brightness intervals includes: For each of the brightness intervals, obtaining each basic image corresponding to the brightness interval; wherein, the peak of the brightness histogram of each of the basic images is located within the brightness interval; For each of the brightness intervals, calculating the average value of the mapping curves of all basic images corresponding to the brightness interval as the basic mapping curve corresponding to the brightness interval.
6. The method according to claim 5, characterized in that, The method further includes: For each of the brightness intervals, displaying the basic mapping curve corresponding to the brightness interval, receiving an adjustment operation on the basic mapping curve, and adjusting the basic mapping curve according to the adjustment operation.
7. An image processing apparatus, characterized in that, The device includes: An image acquisition module for obtaining an image to be processed; A pixel statistics module for counting the number of pixel points located in each preset brightness interval according to the brightness values of all pixel points of the image to be processed; the total number of the brightness intervals is greater than or equal to 3; A curve fusion module for fusing the basic mapping curves corresponding to each of the brightness intervals pre-constructed according to the number of pixel points in each brightness interval to obtain a target mapping curve corresponding to the image to be processed; A brightness adjustment module for performing brightness adjustment on the image to be processed based on the target mapping curve to obtain a processed image.
8. The device according to claim 7, characterized in that, The curve fusion module includes: A ratio calculation sub-module for calculating the pixel ratio of each brightness interval according to the number of pixel points in each brightness interval; A curve fusion sub-module, configured to fuse the basic mapping curves corresponding to the respective luminance intervals pre-constructed according to the pixel ratio of the respective luminance intervals, to obtain a target mapping curve corresponding to the image to be processed.
9. A computer device, characterized in that, Comprising: A memory and a processor, the memory being coupled to the processor; The memory is used for storing one or more computer instructions; The processor is used for executing the one or more computer instructions to implement the image processing method according to any one of claims 1 to 6.
10. A readable storage medium having one or more computer instructions stored thereon, characterized in that, The instruction is executed by the processor to implement the image processing method according to any one of claims 1 to 6.