Image processing method and device, storage medium and electronic device
By dividing the pixels of an image into multiple groups of histograms and adjusting the display parameters, the resource redundancy problem caused by separate processing of brightness and contrast in the prior art is solved, and targeted adjustment of image display parameters and resource conservation are achieved.
Patent Information
- Application Number
- CN202111402134.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-19
- Publication Date
- 2025-10-10
- Estimated Expiration
- 2041-11-19
AI Technical Summary
In the prior art, the brightness and contrast of an image are mostly processed separately, resulting in resource redundancy and inability to make targeted adjustments, causing problems of large computational complexity and high resource usage.
The pixels of the image are divided into multiple groups of histograms according to the grayscale values. When the distribution of the histogram does not meet the preset rules, the display parameters of the pixels are adjusted. Combined with brightness and contrast processing, the image is adjusted in a targeted manner through the grayscale histogram.
Targeted adjustment of image display parameters is achieved, resource redundancy is reduced, and processing efficiency and image quality are improved.
Smart Images

Figure CN114187193B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computers, and in particular to an image processing method and device, a storage medium, and an electronic device. Background Art
[0002] Generally, image brightness is easily affected by ambient light, resulting in images that are either too dark or too bright. Images that are either too bright or too dark hinder observation and can affect the camera's ability to monitor, track, and identify objects. Therefore, image brightness adjustment is necessary. When observing objects, higher contrast at the edges of an image results in sharper edges and a clearer image. Therefore, image contrast adjustment is necessary. Adjusting image brightness and contrast complement each other; adjusting contrast at the appropriate brightness level yields optimal results.
[0003] Now the brightness contrast of the image is mostly adjusted by the method of curve mapping and histogram equalization. Patent CN107481696A discloses a self-adaptive image processing method based on gamma correlation. According to the exposure amount, the gamma value is adjusted, four gamma curves under different brightness scenes are drawn, four different mapping relationships between the target brightness value and the current scene brightness value are formed, the average brightness of the current scene is calculated, the brightness value of the pixel point is mapped to a new brightness value and is corresponded to the set interval, and then the final brightness is calculated according to the formula. The invention maximizes the restoration of the real environment and realizes the display of high dynamic range images on low dynamic range displays. Patent CN105895054A discloses an output brightness adjustment method, a gamma curve adjustment method and a display device. The image is divided into multiple sub-images, the gray scale value of each pixel point in the sub-image is obtained, and the output brightness of each sub-image is adjusted according to the gray scale value distribution of each sub-image. The brightness of the display image can be adjusted in zones, and the display effect is improved. Patent CN104517268B discloses a method and device for adjusting image brightness. According to the brightness average value of the image, the brightness adjustment ratio of the image is determined, the target value of each pixel in the adjusted image is calculated according to the brightness adjustment ratio value of the image and the initial brightness value of each pixel in the image, and the brightness of each pixel in the image is adjusted according to the target brightness value of each pixel in the image to obtain the image after brightness adjustment. The method reduces the complexity and amount of calculation in the image brightness adjustment process, improves the image brightness adjustment efficiency and display effect. Patent CN106897963A discloses a method, device and terminal equipment for adjusting image brightness. The adjustment range is determined within the brightness value range of the target area, and the brightness of the target area is adjusted according to the adjustment range using a specific adjustment rule, such as adjusting the brightness of the target area by constructing a logarithmic curve within the adjustment range. Since the whole process does not need to perform histogram operation, the adjustment process is simplified, the calculation amount is greatly reduced, the occupancy rate of memory resources is reduced, and the processing efficiency is improved. Patent CN105741245B discloses an adaptive contrast enhancement algorithm based on gray scale transformation. By establishing a function relationship between the contrast enhancement threshold and the image gray scale dynamic range, the threshold is adaptively selected, the gain coefficient required for contrast enhancement of different gray scale dynamic images is determined according to the contrast enhancement threshold and the image characteristics, the input image is linearly transformed in gray scale, the gray scale dynamic range is further corrected combined with the image characteristics after gray scale transformation, and the image brightness is adjusted. It is suitable for adaptive enhancement of gray scale images and color contrast, so that the image contrast is enhanced, the image is clearer, the color tone is more vivid, and the visual effect is effectively improved.Patent CN106033600B discloses a dynamic contrast enhancement method based on function curve change, global histogram statistics are performed on video image frames, a gray scale a is taken, the sum of the total number of pixels in the interval 0 to a and the total pixel points are calculated, or a local histogram of the current frame image is established and the gray mean value is calculated, each pixel gray scale is brought into the formula to obtain the gray scale value of the pixel after adjustment, a standard ratio is set, the ratio of the gradient difference before and after the current frame adjustment is calculated, when a certain relationship is met, the processing is ended, otherwise the above steps are repeated.
[0004] From the above, it is known that the brightness and contrast of the image in the prior art are mostly processed separately, and the common points of their processing are not combined, and the brightness or contrast is processed separately, which may have resource redundancy, occupy more resources, and the gamma processing is mostly adjusted according to the parameters of the whole image, and the image cannot be specifically adjusted.
[0005] In view of the problem that the display parameters of the image in the prior art cannot be adjusted specifically, causing resource redundancy, no effective solution has been proposed in the related art. SUMMARY
[0006] The embodiments of the present application provide a kind of processing method and device of image, storage medium, electronic device, to at least solve the problem of resource redundancy caused by the display parameters of image in related technology cannot be adjusted specifically.
[0007] According to one embodiment of the present application, a processing method of image is provided, comprising: dividing the pixels in the determined image to be processed into multiple groups of histograms according to gray values, wherein the multiple groups of histograms are arranged according to the order of gray values, and each group of histograms includes the number of pixels within a preset order range;In the case where the distribution of the multiple groups of histograms does not satisfy a preset distribution rule, adjust the display parameters of the pixels in the to-be-adjusted histogram in the multiple groups of histograms to obtain multiple groups of target histograms;Adjust the image to be processed based on the multiple groups of target histograms.
[0008] According to another embodiment of the present application, a processing device of image is provided, comprising: a grouping module for dividing the pixels in the determined image to be processed into multiple groups of histograms according to gray values, wherein the multiple groups of histograms are arranged according to the order of gray values, and each group of histograms includes the number of pixels within a preset order range;A first adjusting module for adjusting the display parameters of the pixels in the to-be-adjusted histogram in the multiple groups of histograms to obtain multiple groups of target histograms in the case where the distribution of the multiple groups of histograms does not satisfy a preset distribution rule;A second adjusting module for adjusting the image to be processed based on the multiple groups of target histograms.
[0009] According to still another embodiment of the present application, there is also provided a storage medium having stored therein a computer program, wherein the computer program is arranged to perform the steps of any of the method embodiments described above when executed.
[0010] According to still another embodiment of the present application, there is also provided an electronic device comprising a memory having stored therein a computer program and a processor arranged to execute the computer program to perform the steps of any of the method embodiments described above.
[0011] According to the present application, the pixels in the image to be processed are divided into multiple groups of histograms according to the gray value; in the case that the distribution of the multiple groups of histograms does not satisfy the preset distribution rule, the display parameter of the pixels in the histogram to be adjusted in the multiple groups of histograms is adjusted to obtain multiple groups of target histograms; and the image to be processed is adjusted based on the multiple groups of target histograms. The gray histogram of the image can be used to adjust the histogram to be adjusted. Therefore, the problem that the display parameter of the image cannot be adjusted in a targeted manner in the related art and causes resource redundancy can be solved, the display parameter in the image can be adjusted in a targeted manner, and the effect of saving resources is achieved. BRIEF DESCRIPTION OF DRAWINGS
[0012] The accompanying drawings, which are included to provide a further understanding of the application and are incorporated in and constitute a part of this application, illustrate embodiments of the application and together with the description serve to explain the application. In the drawings:
[0013] Figure 1 is a hardware structure block diagram of a mobile terminal of an image processing method according to an embodiment of the present application;
[0014] Figure 2 is a flowchart of an image processing method according to an embodiment of the present application;
[0015] Figure 3 is a flowchart of ISP processing in the related art;
[0016] Figure 4 is an ISP flowchart in the present embodiment;
[0017] Figure 5 is a flowchart of image processing in the present embodiment;
[0018] Figure 6 is a structural schematic diagram of a dark map histogram distribution according to an embodiment of the present application;
[0019] Figure 7 is a structural schematic diagram of a bright map histogram distribution according to an embodiment of the present application;
[0020] Figure 8is a structural schematic diagram of an original curve and a processed curve according to an embodiment of the present invention;
[0021] Figure 9 1 is a schematic diagram of a curve for processing bright and dark images according to an embodiment of the present invention (I);
[0022] Figure 10 2 is a schematic diagram of a curve for processing bright and dark images according to an embodiment of the present invention;
[0023] Figure 11 is a schematic diagram of a histogram of balanced distribution according to an embodiment of the present invention;
[0024] Figure 12 FIG. 4 is a structural block diagram of an image processing apparatus according to an embodiment of the present invention. DETAILED DESCRIPTION
[0025] The present invention will be described in detail below with reference to the accompanying drawings and in combination with embodiments. It should be noted that, unless there is a conflict, the embodiments and features in the embodiments of the present application can be combined with each other.
[0026] It should be noted that the terms "first", "second", etc. in the description and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.
[0027] The method embodiments provided in the embodiments of the present application can be executed in a mobile terminal, a computer terminal or a similar computing device. Taking running on a mobile terminal as an example, Figure 1 FIG. 1 is a hardware structure block diagram of a mobile terminal of an image processing method according to an embodiment of the present invention. Figure 1 As shown, the mobile terminal 10 may include one or more ( Figure 1 Only one is shown in the figure) processor 102 (processor 102 may include but is not limited to a microprocessor MCU or a programmable logic device FPGA and other processing devices) and a memory 104 for storing data. Optionally, the mobile terminal may also include a transmission device 106 and an input and output device 108 for communication functions. It will be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the mobile terminal. Figure 1 More or fewer components than shown, or with Figure 1 Different configurations shown.
[0028] The memory 104 can be used to store computer programs, for example, software programs and modules of application software, such as the computer program corresponding to the image processing method in the embodiment of the present invention. The processor 102 executes the computer program stored in the memory 104 to execute various functional applications and data processing, that is, to implement the above-mentioned method. The memory 104 may include a high-speed random access memory and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include a memory remotely located relative to the processor 102, and these remote memories may be connected to the mobile terminal 10 via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0029] The transmission device 106 is configured to receive or transmit data via a network. A specific example of the aforementioned network may include a wireless network provided by the telecommunications provider of the mobile terminal 10. In one embodiment, the transmission device 106 includes a network interface controller (NIC), which can be connected to other network devices via a base station to enable communication with the Internet. In another embodiment, the transmission device 106 may be a radio frequency (RF) module, which is configured to communicate with the Internet wirelessly.
[0030] In this embodiment, a method for processing an image is provided. Figure 2 is a flowchart of an image processing method according to an embodiment of the present invention, such as Figure 2 As shown, the process includes the following steps:
[0031] Step S202: dividing the pixels in the determined image to be processed into a plurality of histogram groups according to grayscale values, wherein the plurality of histogram groups are arranged according to the order of grayscale values, and each histogram group includes a number of pixels within a preset order range;
[0032] Step S204, when it is determined that the distribution of the multiple groups of histograms does not satisfy the preset distribution rule, adjusting the display parameters of the pixels in the histograms to be adjusted in the multiple groups of histograms to obtain multiple groups of target histograms;
[0033] Step S206: adjusting the image to be processed based on the multiple sets of target histograms.
[0034] By the above steps, the pixels in the determined to-be-processed image are divided into multiple groups of histograms according to the gray values; in a case where the distribution of the multiple groups of histograms does not satisfy a preset distribution rule, the display parameter of the pixel in the to-be-adjusted histogram in the multiple groups of histograms is adjusted to obtain multiple groups of target histograms; and the to-be-processed image is adjusted based on the multiple groups of target histograms. The gray value histogram of the image can be used to adjust the to-be-adjusted histogram. Therefore, the problem that the display parameter of the image cannot be adjusted in a targeted manner in the related art, causing resource redundancy, can be solved, and the effect of adjusting the display parameter of the image in a targeted manner and saving resources can be achieved.
[0035] Optionally, the execution subject of the above steps can be a terminal or the like, but is not limited thereto.
[0036] In this embodiment, the gray values of the pixels in the to-be-processed image can be counted to obtain a 256-order histogram. The 256-order histogram is evenly divided into 8 groups. The results of every 32 orders are superimposed to finally obtain eight groups of statistical results, that is, multiple groups of histograms. Each group of histograms includes 32-order pixels. Histogram statistics on the to-be-processed image is beneficial to globally adjusting the display parameter of the pixel. The display parameter of the pixel in one histogram is adjusted, that is, the display parameter of the pixel with the same gray value in the to-be-processed image is adjusted. The adjustment on the to-be-processed image can be optimized.
[0037] Optionally, the display parameter of the pixel includes a brightness parameter for adjusting brightness and a contrast parameter for adjusting contrast.
[0038] In an optional embodiment, before the display parameter of the pixel in the to-be-processed image is adjusted, it can be determined whether the pixel in the to-be-processed image needs to be adjusted. It can be determined whether the scene where the to-be-processed image is located changes. Whether the to-be-processed image needs to be adjusted is determined through the scene determination. The resource can be saved without real-time adjustment. Specifically, the pixels in the previous image of the to-be-processed image are divided into multiple groups of histograms according to the gray values, where the multiple groups of histograms of the previous image are arranged according to the order of the gray values, and each group of histograms of the previous image includes the number of pixels in a preset order range; a change rate between the multiple groups of histograms of the previous image and the multiple groups of histograms of the to-be-processed image is determined; and in a case where the change rate is greater than a preset threshold, it is determined that the scene where the to-be-processed image is located changes. For example, the histograms of the previous image of the to-be-processed image are evenly divided into 8 groups, and the change of the pixels is used to determine whether the scene changes. The calculation formula of the change rate ra is as follows:
[0039]
[0040] Hpre i is the eight groups of histograms of the previous image, Hcur iHere are eight histograms of the image to be processed. Set a threshold value, chg. When ra is greater than chg, the scene is considered to have changed; otherwise, the scene has not changed. Smaller values of chg are more sensitive to detecting scene changes, while larger values are less sensitive.
[0041] It should be noted that the previous frame image may be the most original image of the image to be processed, and the image to be processed may be the current image. By comparing with the most original image, it is possible to accurately determine whether the scene has changed.
[0042] In an optional embodiment, when the scene of the image to be processed changes, the display parameters that need to be adjusted for pixels in the image to be processed can be determined based on the distribution between multiple histograms. If the temporal distribution of the multiple histograms is uneven, it can be determined that either the brightness parameter or the contrast parameter needs to be adjusted. For example, if the number of pixels in the histograms within a first preset order range and the number of pixels in the histograms within a second preset order range are not equal among the multiple histograms, the brightness parameters of the pixels in the histograms to be adjusted in the multiple histograms can be adjusted to obtain multiple sets of target histograms. In this embodiment, the histograms within the first preset order range can be the histograms on the left side of the multiple histograms, and the histograms within the second preset order range can be the histograms on the right side of the multiple histograms. When pixels are concentrated on the left side of the histogram, the image brightness is dark and needs to be brightened. When pixels are concentrated on the right side of the histogram, the image brightness is bright and needs to be dimmed. When pixels are concentrated in the middle, the image brightness is optimal and no adjustment is required. Determining brightness not only allows for targeted adjustment of the display parameters of the image to be processed but also saves resources.
[0043] In an optional embodiment, determining whether a pixel's contrast parameter needs to be adjusted can be performed by determining the entropy of each of multiple histograms to obtain multiple entropies; calculating the sum of these entropies to obtain a total entropy value; and, if the total entropy value is less than a first preset value, adjusting the contrast parameters of pixels in the histograms to be adjusted among the multiple histograms to obtain multiple sets of target histograms. In this embodiment, the process of maximizing entropy is also a process where the histograms gradually approach equal probability. That is, when the various variations in the image to be processed appear with equal probability, the various details of the image to be processed can be fully expressed, and the contrast of the image to be processed is optimized. Therefore, the entropy of the histogram can be used to determine the contrast of the image to be processed, and then the histogram can be adjusted to achieve the purpose of adjusting the contrast. Determining whether to adjust the contrast parameter based on entropy allows for targeted adjustment of the contrast parameter and reduces resource redundancy.
[0044] In an optional embodiment, after determining the display parameter that needs to be adjusted, the display parameter can be adjusted in the plurality of histograms, the brightness parameter can be adjusted first, the number of pixels in each group of histograms in the plurality of groups of histograms is determined; the histogram with the number of pixels greater than a second preset value in the plurality of groups of histograms is determined as a to-be-adjusted histogram; the histogram with the number of pixels greater than a third preset value in the to-be-adjusted histogram is determined as a starting histogram of the to-be-adjusted histogram; the display parameter of the pixel in the to-be-adjusted histogram is adjusted according to the order of the gray value from the starting histogram. Through the determination of the to-be-adjusted histogram, the content of the segmented adjustment can be further embodied, and the to-be-adjusted histogram is adjusted in a targeted manner.
[0045] Optionally, when the brightness parameter is adjusted, the brightness parameter can be adjusted in the following manner: the slope of the starting broken line corresponding to the gray value of the starting histogram is determined; the slope of the broken line corresponding to the to-be-adjusted histogram is adjusted in sequence from the starting broken line according to a preset slope parameter, to obtain a plurality of groups of adjusted histograms; the gray value variation of the pixel in the plurality of groups of adjusted histograms is determined; the distribution of the plurality of groups of adjusted histograms and the unadjusted histograms is adjusted again according to the gray value variation, to obtain a plurality of groups of target histograms. The brightness parameter is adjusted by increasing or reducing the slope of the broken line, which not only simplifies the operation process, but also can globally adjust the to-be-processed image.
[0046] In an optional embodiment, after the brightness parameter is adjusted, the distribution of each group of histograms can be updated, and the contrast parameter can be adjusted on the basis of the updated each group of histograms, or the contrast parameter can be adjusted on the basis of the original each group of histograms. Preferably, the contrast parameter is adjusted on the basis of the updated each group of histograms. It should be noted that the brightness parameter and the contrast parameter can be adjusted in the form of adjusting each histogram, and do not need to be adjusted separately.
[0047] Optionally, the contrast parameter is adjusted in the following manner: starting from the starting histogram, the number of pixels between two adjacent to-be-adjusted histograms in the to-be-adjusted histograms is compared; the number of pixels between the two adjacent to-be-adjusted histograms is balanced based on the comparison result, to obtain a plurality of groups of adjusted histograms, and the pixels in the histogram with a larger number of pixels are adjusted to the histogram with a smaller number of pixels; the gray value variation of the pixel in the plurality of groups of adjusted histograms is determined; the distribution of the plurality of groups of adjusted histograms and the unadjusted histograms is adjusted again according to the gray value variation, to obtain a plurality of groups of target histograms; in this embodiment, the adjustment of the contrast parameter by the movement of the number of pixels can optimize the balanced distribution of the histogram.
[0048] In addition, the number of pixels between two adjacent histograms to be adjusted can be balanced based on the comparison result to obtain multiple groups of adjusted histograms in the following manner: when the number of pixels in the starting histogram is not equal to the number of pixels in the adjacent first histogram to be adjusted, the number of pixels between the starting histogram and the first histogram to be adjusted is adjusted; the number of pixels of the adjusted first histogram to be adjusted is compared with the number of pixels of the second histogram to be adjusted, and the pixel distribution between the adjusted first histogram to be adjusted and the second histogram to be adjusted is adjusted based on the comparison result, wherein the adjusted first histogram to be adjusted is adjacent to the second histogram to be adjusted, and the second histogram to be adjusted is different from the starting histogram. In this embodiment, the starting histogram can be the first group of histograms, and the second group of histograms is adjacent to the starting histogram. If the number of pixels in the first group of histograms is greater than the number of pixels in the second group of histograms, a portion of the number of pixels in the first group of histograms is moved to the second group of histograms, otherwise, no adjustment is made. After adjusting the second set of histograms, continue to adjust the number of pixels between the second and third sets of histograms in the same way.
[0049] In an optional embodiment, after adjusting the brightness and contrast parameters described above, the slopes of each histogram after adjusting the brightness parameter and the slopes of each histogram after adjusting the contrast parameter are calculated to obtain multiple sets of target slopes; a mapping relationship is determined between each target slope and the display parameters of the pixels in each target histogram to obtain a mapping relationship table; the mapping relationship table is used to update the preset gamma mapping table of the image to be processed to obtain an updated gamma mapping table; and the updated gamma mapping table is used to adjust the image to be processed. In this embodiment, the adjustment results of the brightness and contrast parameters are fed back to gamma, and the histogram is adjusted in segments during adjustment, allowing for targeted adjustment of the histogram.
[0050] The present invention is described in detail below in conjunction with specific embodiments:
[0051] In image signal processing (ISP), different lens models correspond to different gammas. Since the lens is fixed, the gamma curve is generally fixed, so the brightness and contrast obtained cannot change adaptively according to environmental changes. In order to make the processed image have better visual effects, this method proposes a method to adaptively adjust the brightness and contrast of the image and optimize the gamma.
[0052] In related technologies, algorithms for processing brightness and contrast in images are often separate. Processing brightness or contrast separately can lead to resource redundancy and consume significant resources. This embodiment processes brightness and contrast together, sharing resources and reducing unnecessary redundancy. The resulting gamma is then updated based on the resulting data. This embodiment monitors changes in the image scene when processing multiple frames of video, recalculating only when the scene changes, thus reducing time consumption.
[0053] Figure 3 This is the ISP processing process in related technologies, such as Figure 3 As shown, image sensor capture data input is processed first in the RAW domain, then in the RGB and YUV domains. Gamma is typically in the RGB domain (gamma can exist in different domains, but this example uses the RGB domain).
[0054] The gamma in the ISP typically uses a pre-configured fixed mapping table to map brightness based on scene brightness. This cannot adapt well to changing real-world environments, resulting in image quality that is often partially or globally dark or bright, and lacks contrast. Figure 4 This is the ISP flow chart in this embodiment, such as Figure 4 As shown, in this embodiment, an adaptive control contrast and brightness adjustment module (ACCB) is added to the original ISP processing flow, and the resulting gamma mapping table is fed back to the gamma module, so that the gamma module can adapt to changes in the environment. To avoid the ACCB module constantly calculating and updating the gamma mapping table, which is time-consuming and may cause flickering due to frequent updates, a scene judgment function is added, and the ACCB module is activated only when the scene changes. After the scene stabilizes, the brightness contrast calculation is not performed, and the gamma does not change.
[0055] Figure 5 is a flowchart of the image processing in this embodiment, as shown in FIG. Figure 5 As shown, the following steps are included:
[0056] S501: Count the grayscale value of each pixel in the image to be processed to obtain a 256-level histogram. The 256-level histogram is evenly divided into 8 groups. The results of each 32-level histogram are superimposed to obtain eight groups of statistical results sta1 to sta8. The proportion of each group is calculated to obtain hist1 to hist8.
[0057] S502: Scene judgment. Scene judgment generally uses the most original information of the image to be processed to accurately determine the processing results of the image to be processed. This embodiment performs scene judgment in RAW. Scene judgment uses histogram statistics to evenly divide the histogram into 8 groups. The change in pixels is used to determine whether the scene has changed. It is determined whether the histogram information of the previous frame needs to be retained for the current frame. The change rate is calculated based on the histogram of the previous and next frames. The calculation formula for the change rate ra is as follows:
[0058]
[0059] Where Hprei is the eight-group histogram of the previous frame, and Hcuri is the eight-group histogram of the current frame (the image to be processed). Set a threshold chg. When ra is greater than chg, the scene of the image to be processed is considered to have changed; otherwise, the scene has not changed. Smaller chg values are more sensitive to detecting scene changes, while larger values are less sensitive.
[0060] S503: When the scene changes, the brightness of the image to be processed is determined and the brightness parameter ka is calculated. Since the ACCB module is in the YUV domain, the brightness component Y can be directly used for statistics. The brightness of the image to be processed is determined by the relationship between the eight groups of histograms sta1 to sta8. Figure 6 As shown, when the pixels are mostly concentrated on the left side of the histogram, the brightness of the image to be processed is dark and needs to be brightened. Figure 7 As shown in the figure, when the pixels are mostly concentrated on the right side of the histogram, the brightness of the image to be processed is bright and needs to be dimmed. When the pixels are mostly concentrated in the middle, the brightness of the image to be processed is most suitable for observation.
[0061] The brightness of the image to be processed can be determined by the following formula:
[0062] when When , the image to be processed is a dark image.
[0063] when When , the image to be processed is a bright image.
[0064] Among them, param 1, param 2, param 3, and param 4 are preset parameters. Generally, param 1 = 0.6, param 2 = 0.3, param 3 = 0.6, and param 4 = 0.3. After determining whether the image is a bright image or a dark image, the image is processed separately. In this embodiment, a piecewise linear processing method is used to divide the curve into eight segments, such as Figure 8 As shown, each curve segment can be processed separately according to the actual situation of the image to be processed, and the formula of each segment is a simple linear formula y=kx+b.
[0065] Darkening or brightening the image to be processed is a global processing process. For darker images to be processed, the situation of the first three groups of histogram pixels can be judged to select the lifting curve. For example, if there are more pixels in the first segment, the lifting curve can be started from the first segment. If there are more pixels in the second segment, the lifting curve can be started from the second segment. Darkening generally starts from the first segment, such as Figure 9 、 Figure 10 shown.
[0066] in, Figure 9 、 Figure 10 The solid line in the figure represents the curve corresponding to the original image pixel values, and the dashed line represents the curve corresponding to the processed pixel values. For dark images, the curve is raised to brighten the processed image, while for bright images, the curve is lowered to darken the processed image. Because raising or lowering one segment of the curve causes subsequent segments to also raise or lower, this can cause the maximum value after processing to be greater or less than the maximum value before processing. To avoid this, the curves are gradually brought closer to the original curve in the final segments.
[0067] Initialize the slopes kai of the eight segments of the curves for adjusting brightness and darkness to all be 1. When the image is judged to be dark, the number of pixels in the first three segments is used to determine which segment to start processing:
[0068] like Then it starts to rise from the first section. Param5 is the preset parameter, usually param5 = 0.05;
[0069] like Then the lifting starts from the second section, and the first section is not processed. Param6 is the preset parameter, usually param6 = 0.2;
[0070] Otherwise, start lifting from the third section.
[0071] When the image is judged to be bright, it is darkened starting from the first segment.
[0072] After determining the brightness of the image and knowing the segment to start processing, we need to determine the slope of the segment. The slope formula is as follows:
[0073]
[0074] Y i =(ka i ±e)*X i +b i
[0075] Among them, e is the change value of the slope of this section, X i is the grayscale value in the i-th group histogram, Y iis the value of the i-th group after gray scale processing. In order to make the final value return to the maximum value of the original image, the latter curves need to be processed. In order to avoid the pixel value being squeezed in only one segment, which leads to layering, the original maximum value is generally gradually pressed back or raised in three segments. That is, the slopes of segments 6, 7 and 8 are changed. For example, if the input image is a dark image and the slope is increased at the second segment, the slope of each segment needs to be reduced by e / 3 to make the curve depressed. If the slope is increased by e, the slope of each segment is reduced by e / 3, that is, the formula of each segment is:
[0076]
[0077] The above processing will process the brightness of the image to be processed, and the slope of each segment of the brightness processed curve is ka i .
[0078] After determining the slope, the distribution of the histogram needs to be updated. According to the slope, the change amount of each gray scale is updated to obtain a brightness adjusted histogram for adjusting contrast.
[0079] S504: judging the contrast of the image to be processed and calculating the contrast parameter kc. In the contrast processing of the image to be processed, the present embodiment adjusts and changes the distribution form of the histogram by judging the relationship between the left and right histograms. The histogram equalization is closely related to the entropy maximization theory, and is an approximate implementation of the entropy maximization. The process of entropy maximization is also a gradual approach to equal probability of the histogram, that is, when the information of various changes of the image to be processed appears with equal probability, the various detail information of the image to be processed can be fully expressed, and the contrast of the image to be processed reaches the best effect. Therefore, the entropy of the histogram can be used to judge the contrast of the image to be processed, and the histogram is adjusted to achieve the purpose of adjusting the contrast. The entropy of the histogram is calculated as follows:
[0080]
[0081] If the value of En is less than the set threshold con_thr, it is considered that the contrast of the image to be processed is insufficient, and the contrast needs to be adjusted. In the contrast adjustment of the present embodiment, the 256-order histogram is adjusted, and the 256-order is divided into 8 groups, and the histograms in the left and right groups are moved to realize the adjustment of the image contrast. Although the information can be fully expressed when the histogram is in equal probability distribution, the histogram in equal probability distribution is prone to layering, and for the human eye, the information in the middle zone is easier to distinguish, so when the histogram is similar to Figure 11 , the histogram is more concentrated in the middle, and the information that can be perceived is clearer.
[0082] The contrast starts from the first group and the second group, and then the second and third groups, and so on until the seventh and eighth groups:
[0083] If hist1 > hist2 between groups 1 and 2, it is considered that there are too many pixels in hist1 and they need to be moved backward. If hist2 > param12 * hist1, it is considered that there are many more pixels in hist2 than in hist1 and some of the pixels in hist2 need to be moved to hist1. Otherwise, no processing is performed. Param12 is a preset parameter, usually param12 = 4.
[0084] The adjustment method between groups 2 and 3 and between groups 3 and 4 is the same as the adjustment method between groups 1 and 2.
[0085] Between the fourth and fifth groups, if hist4>param 45*hist5, then move the pixels in hist4 to hist5. If hist5>param45*hist4, similarly, param45 is a preset parameter, generally param45=2.
[0086] The parameters of groups 5, 6, 7, and 8 are symmetrical with those of groups 1, 2, 3, and 4. For example, processing is performed when hist6>hist5 and hist5>param56*hist6, where param56 is a preset parameter, generally param56=4.
[0087] Each time a group is judged and processed, the linear formula is still used for adjustment. The slope kci needs to be calculated. First, the value of kci is initialized to 1. The calculation formula is as follows:
[0088] e=(hist i -a*hist i+1 ) / (2*hist i )
[0089] kc i =kc i ±e
[0090]
[0091] Y i =kc i *X i +b i
[0092] Y i+1 =kc i+1 *X i+1 +b i+1
[0093] or
[0094] e=(hist i+1 -a*hist i ) / (2*histi+1 )
[0095]
[0096] kc i+1 =kc i+1 ±e
[0097] Y i =kc i *X i +b i
[0098] Y i+1 =kc i+1 *X i+1 +b i+1 ;
[0099] Among them, e is the change value of the slope, a is the relationship parameter between the left and right histograms, the first formula above is the formula for moving the left histogram to the right, and the second formula is the formula for moving the right histogram to the left.
[0100] After the left and right histograms are adjusted, the histogram needs to be updated. Since the histogram only moves left and right, only histogram needs to be updated. i and hist i +1 value. Knowing the transformation formula, we can find the position of the movement and recalculate the proportion. And so on, until all eight groups are judged to be calculated and the new kc is obtained. i .
[0101] S505: Calculate the mapping result and update the gamma mapping table. Calculate the brightness slope ka i and the slope of the contrast kc i After that, multiply the slopes to get the final slope k i , that is, k i =ka i *kc i According to k i The values corresponding to the eight histogram nodes [32, 64, 96, 128, 160, 192] can be calculated as [yy0, yy1, yy2, yy3, yy4, yy5]. The mapping table
[256] after adjusting the brightness and contrast of the 256-level grayscale can be calculated according to the following formula.
[0102]
[0103] Update the gamma map using the following formula:
[0104] gamma_new=gamma_old*(Y / Yin);
[0105] Wherein, gamma old is the original gamma value, gamma new is the processed gamma value, Yin is the luminance component of the input YUV, and Y is the processed luminance component.
[0106] In summary, the common points of the luminance and contrast processing are utilized in the embodiment, and they are combined to complement each other. The results of the luminance and contrast adjustment are fed back to the gamma, and the histogram is segmented for adjustment, so that the histogram can be adjusted in a targeted manner.
[0107] From the above description of the embodiments, those skilled in the art can clearly understand that the method according to the above embodiments can be realized by means of software and a necessary general hardware platform, and of course, it can also be realized by hardware, but in many cases, the former is a better embodiment. Based on such understanding, the technical solutions of the present application or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a storage medium (such as a ROM / RAM, a magnetic disk, or an optical disk) and includes a plurality of instructions for causing a terminal device (which can be a mobile phone, a computer, a server, or a network device) to execute the method described in the embodiments of the present application.
[0108] In the embodiment, an image processing device is also provided, which is used to implement the above embodiments and preferred embodiments, and has been described above. As used below, the term "module" can be a combination of software and / or hardware that implements a predetermined function. Although the device described in the following embodiments is preferably implemented in software, hardware or a combination of software and hardware is also possible and is contemplated.
[0109] Figure 12 is a structural block diagram of the image processing device according to the embodiment of the present application, as shown in Figure 12 The device includes a grouping module 1202, a first adjustment module 1204, and a second adjustment module 1206, which are described in detail below:
[0110] The grouping module 1202 is configured to divide the pixels in the determined image to be processed into a plurality of histogram groups according to the gray value, wherein the plurality of histogram groups are arranged according to the order of the gray value, and each histogram group includes the number of pixels within a preset order range.
[0111] The first adjustment module 1204 is connected to the grouping module 1202 described above, and is configured to adjust the display parameter of the pixels in the histogram to be adjusted in the plurality of histogram groups to obtain a plurality of target histogram groups when the distribution of the plurality of histogram groups does not satisfy the preset distribution rule.
[0112] The second adjustment module 1206 is connected to the first adjustment module 1204 described above, and is configured to adjust the image to be processed based on multiple sets of target histograms.
[0113] Through the present invention, the pixels in the determined image to be processed are divided into multiple groups of histograms according to the grayscale values; when it is determined that the distribution of the multiple groups of histograms does not meet the preset distribution rules, the display parameters of the pixels in the histograms to be adjusted in the multiple groups of histograms are adjusted to obtain multiple groups of target histograms; the image to be processed is adjusted based on the multiple groups of target histograms. The histogram that needs to be adjusted can be adjusted using the grayscale histogram of the image. Therefore, the problem in the related art that the display parameters of the image cannot be adjusted in a targeted manner, resulting in resource redundancy, can be solved, and the display parameters in the image can be adjusted in a targeted manner to save resources.
[0114] Optionally, the execution subject of the above steps may be a terminal, etc., but is not limited thereto.
[0115] In this embodiment, the grayscale values of the pixels in the image to be processed can be counted to obtain a 256-level histogram. The 256-level histogram is evenly divided into 8 groups. The results of each 32-level histogram are superimposed to ultimately obtain eight sets of statistical results, i.e., multiple sets of histograms. Each histogram group includes 32 levels of pixels. Histogram statistics of the image to be processed are conducive to global adjustment of pixel display parameters. Adjusting the display parameters of pixels in one histogram can adjust the display parameters of pixels with the same grayscale value in the image to be processed. This can optimize the adjustment of the image to be processed.
[0116] Optionally, the display parameters of the pixel include a brightness parameter for adjusting brightness and a contrast parameter for adjusting contrast.
[0117] In an optional embodiment, before adjusting the display parameters of the pixels in the image to be processed, it is possible to first determine whether the pixels in the image to be processed need to be adjusted, and to first determine whether the scene in which the image to be processed is located has changed. By determining whether the image to be processed needs to be adjusted based on the scene, it is not necessary to make real-time adjustments, which can save resources. Specifically, the pixels in the previous frame of the image to be processed are divided into multiple groups of histograms according to the grayscale values, wherein the multiple groups of histograms of the previous frame are arranged according to the order of the grayscale values, and each group of histograms of the previous frame includes the number of pixels within a preset order range; the rate of change between the multiple groups of histograms of the previous frame and the multiple groups of histograms of the image to be processed is determined; when the rate of change is greater than a preset threshold, it is determined that the scene in which the image to be processed is located has changed. For example, the histogram of the previous frame of the image to be processed is evenly divided into 8 groups, and the change in pixels is used to determine whether the scene has changed. The calculation formula of the rate of change ra is as follows:
[0118]
[0119] Hpre i It is the 8 groups of histograms of the previous frame image, Hcur i Here are eight histograms of the image to be processed. Set a threshold value, chg. When ra is greater than chg, the scene is considered to have changed; otherwise, the scene has not changed. Smaller values of chg are more sensitive to detecting scene changes, while larger values are less sensitive.
[0120] It should be noted that the previous frame image may be the most original image of the image to be processed, and the image to be processed may be the current image. By comparing with the most original image, it is possible to accurately determine whether the scene has changed.
[0121] In an optional embodiment, when the scene of the image to be processed changes, the display parameters that need to be adjusted for pixels in the image to be processed can be determined based on the distribution between multiple histograms. If the temporal distribution of the multiple histograms is uneven, it can be determined that either the brightness parameter or the contrast parameter needs to be adjusted. For example, if the number of pixels in the histograms within a first preset order range and the number of pixels in the histograms within a second preset order range are not equal among the multiple histograms, the brightness parameters of the pixels in the histograms to be adjusted in the multiple histograms can be adjusted to obtain multiple sets of target histograms. In this embodiment, the histograms within the first preset order range can be the histograms on the left side of the multiple histograms, and the histograms within the second preset order range can be the histograms on the right side of the multiple histograms. When pixels are concentrated on the left side of the histogram, the image brightness is dark and needs to be brightened. When pixels are concentrated on the right side of the histogram, the image brightness is bright and needs to be dimmed. When pixels are concentrated in the middle, the image brightness is optimal and no adjustment is required. Determining brightness not only allows for targeted adjustment of the display parameters of the image to be processed but also saves resources.
[0122] In an optional embodiment, determining whether a pixel's contrast parameter needs to be adjusted can be performed by determining the entropy of each of multiple histograms to obtain multiple entropies; calculating the sum of these entropies to obtain a total entropy value; and, if the total entropy value is less than a first preset value, adjusting the contrast parameters of pixels in the histograms to be adjusted among the multiple histograms to obtain multiple sets of target histograms. In this embodiment, the process of maximizing entropy is also a process where the histograms gradually approach equal probability. That is, when the various variations in the image to be processed appear with equal probability, the various details of the image to be processed can be fully expressed, and the contrast of the image to be processed is optimized. Therefore, the entropy of the histogram can be used to determine the contrast of the image to be processed, and then the histogram can be adjusted to achieve the purpose of adjusting the contrast. Determining whether to adjust the contrast parameter based on entropy allows for targeted adjustment of the contrast parameter and reduces resource redundancy.
[0123] In an optional embodiment, after determining the display parameter that needs to be adjusted, the display parameter can be adjusted in the plurality of histograms, the brightness parameter can be adjusted first, the number of pixels in each group of histograms in the plurality of groups of histograms is determined; the histogram with the number of pixels greater than a second preset value in the plurality of groups of histograms is determined as a to-be-adjusted histogram; the histogram with the number of pixels greater than a third preset value in the to-be-adjusted histogram is determined as a starting histogram of the to-be-adjusted histogram; the display parameter of the pixel in the to-be-adjusted histogram is adjusted according to the order of the gray value from the starting histogram. Through the determination of the to-be-adjusted histogram, the content of the segmented adjustment can be further embodied, and the to-be-adjusted histogram is adjusted in a targeted manner.
[0124] Optionally, when the brightness parameter is adjusted, the brightness parameter can be adjusted in the following manner: the slope of the starting broken line corresponding to the gray value of the starting histogram is determined; the slope of the broken line corresponding to the to-be-adjusted histogram is adjusted in sequence from the starting broken line according to a preset slope parameter, to obtain a plurality of groups of adjusted histograms; the gray value variation of the pixel in the plurality of groups of adjusted histograms is determined; the distribution of the plurality of groups of adjusted histograms and the unadjusted histograms is adjusted again according to the gray value variation, to obtain a plurality of groups of target histograms. The brightness parameter is adjusted by increasing or reducing the slope of the broken line, which not only simplifies the operation process, but also can globally adjust the to-be-processed image.
[0125] In an optional embodiment, after the brightness parameter is adjusted, the distribution of each group of histograms can be updated, and the contrast parameter can be adjusted on the basis of the updated each group of histograms, or the contrast parameter can be adjusted on the basis of the original each group of histograms. Preferably, the contrast parameter is adjusted on the basis of the updated each group of histograms. It should be noted that the brightness parameter and the contrast parameter can be adjusted in the form of adjusting each histogram, and do not need to be adjusted separately.
[0126] Optionally, the contrast parameter is adjusted in the following manner: starting from the starting histogram, the number of pixels between two adjacent to-be-adjusted histograms in the to-be-adjusted histograms is compared; the number of pixels between the two adjacent to-be-adjusted histograms is balanced based on the comparison result, to obtain a plurality of groups of adjusted histograms, and the pixels in the histogram with a larger number of pixels are adjusted to the histogram with a smaller number of pixels; the gray value variation of the pixel in the plurality of groups of adjusted histograms is determined; the distribution of the plurality of groups of adjusted histograms and the unadjusted histograms is adjusted again according to the gray value variation, to obtain a plurality of groups of target histograms; in this embodiment, the adjustment of the contrast parameter by the movement of the number of pixels can optimize the balanced distribution of the histogram.
[0127] In addition, the number of pixels between two adjacent histograms to be adjusted can be balanced based on the comparison result to obtain multiple groups of adjusted histograms in the following manner: when the number of pixels in the starting histogram is not equal to the number of pixels in the adjacent first histogram to be adjusted, the number of pixels between the starting histogram and the first histogram to be adjusted is adjusted; the number of pixels of the adjusted first histogram to be adjusted is compared with the number of pixels of the second histogram to be adjusted, and the pixel distribution between the adjusted first histogram to be adjusted and the second histogram to be adjusted is adjusted based on the comparison result, wherein the adjusted first histogram to be adjusted is adjacent to the second histogram to be adjusted, and the second histogram to be adjusted is different from the starting histogram. In this embodiment, the starting histogram can be the first group of histograms, and the second group of histograms is adjacent to the starting histogram. If the number of pixels in the first group of histograms is greater than the number of pixels in the second group of histograms, a portion of the number of pixels in the first group of histograms is moved to the second group of histograms, otherwise, no adjustment is made. After adjusting the second set of histograms, continue to adjust the number of pixels between the second and third sets of histograms in the same way.
[0128] In an optional embodiment, after adjusting the brightness and contrast parameters described above, the slopes of each histogram after adjusting the brightness parameter and the slopes of each histogram after adjusting the contrast parameter are calculated to obtain multiple sets of target slopes; a mapping relationship is determined between each target slope and the display parameters of the pixels in each target histogram to obtain a mapping relationship table; the mapping relationship table is used to update the preset gamma mapping table of the image to be processed to obtain an updated gamma mapping table; and the updated gamma mapping table is used to adjust the image to be processed. In this embodiment, the adjustment results of the brightness and contrast parameters are fed back to gamma, and the histogram is adjusted in segments during adjustment, allowing for targeted adjustment of the histogram.
[0129] It should be noted that the above modules can be implemented through software or hardware. For the latter, it can be implemented in the following ways, but not limited to: the above modules are all located in the same processor; or the above modules are located in different processors in any combination.
[0130] An embodiment of the present invention further provides a storage medium storing a computer program, wherein the computer program is configured to execute the steps of any of the above method embodiments when running.
[0131] Optionally, in this embodiment, the above-mentioned storage medium may be configured to store a computer program for executing the above steps.
[0132] Optionally, in this embodiment, the above-mentioned storage medium may include but is not limited to: a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk, and other media that can store computer programs.
[0133] An embodiment of the present invention further provides an electronic device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.
[0134] Optionally, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor, and the input / output device is connected to the processor.
[0135] Optionally, in this embodiment, the processor may be configured to execute the above steps through a computer program.
[0136] Optionally, specific examples in this embodiment may refer to the examples described in the above embodiments and optional implementation modes, and this embodiment will not be described in detail here.
[0137] Obviously, those skilled in the art will appreciate that the various modules or steps of the present invention described above can be implemented using a general-purpose computing device, centralized on a single computing device, or distributed across a network of multiple computing devices. Alternatively, they can be implemented using program code executable by a computing device, which can then be stored in a storage device and executed by the computing device. In some cases, the steps shown or described can be performed in a different order than that shown, or can be fabricated as separate integrated circuit modules, or multiple modules or steps can be fabricated as a single integrated circuit module. Thus, the present invention is not limited to any particular combination of hardware and software.
[0138] The foregoing description is merely a preferred embodiment of the present invention and is not intended to limit the present invention. Those skilled in the art will readily appreciate that various modifications and variations of the present invention are possible. Any modifications, equivalent substitutions, or improvements made within the principles of the present invention are intended to be within the scope of protection of the present invention.
Claims
1. A method for processing an image, characterized in that: include: Dividing the pixels in the determined image to be processed into a plurality of histogram groups according to grayscale values, wherein the plurality of histogram groups are arranged according to the orders of grayscale values, and each histogram group includes a number of pixels within a preset order range; When it is determined that the distribution of the multiple groups of histograms does not satisfy the preset distribution rule, adjusting the display parameters of the pixels in the histograms to be adjusted among the multiple groups of histograms to obtain multiple groups of target histograms, wherein the display parameters include brightness parameters and contrast parameters; Adjusting the image to be processed based on the multiple sets of target histograms; Among them, adjusting the image to be processed based on the multiple sets of target histograms includes: determining the slopes of the broken lines corresponding to the multiple sets of target histograms to obtain multiple sets of target slopes; determining the mapping relationship between each target slope and the display parameters of the pixels in each target histogram to obtain a mapping relationship table; using the mapping relationship table to update the preset gamma mapping table of the image to be processed to obtain an updated gamma mapping table; and using the updated gamma mapping table to adjust the image to be processed.
2. The method according to claim 1, characterized in that When it is determined that the distribution of the multiple groups of histograms does not satisfy the preset distribution rule, adjusting the display parameters of the pixels in the histograms to be adjusted in the multiple groups of histograms to obtain the multiple groups of target histograms includes: When the number of pixels of the histograms included in the first preset order range in the multiple groups of histograms is not equal to the number of pixels of the histograms included in the second preset order range, the brightness parameters of the pixels in the histograms to be adjusted in the multiple groups of histograms are adjusted to obtain the multiple groups of target histograms.
3. The method according to claim 2, characterized in that When the number of pixels of the histograms included in the first preset order range in the multiple sets of histograms is not equal to the number of pixels of the histograms included in the second preset order range, adjusting the brightness parameters of the pixels in the histograms to be adjusted in the multiple sets of histograms, and obtaining the multiple sets of target histograms includes one of the following: When the number of pixels of the histograms within the first preset order range is greater than the number of pixels of the histograms within the second preset order range in the multiple sets of histograms, adjusting the brightness parameters of the pixels of the histograms within the first preset order range to obtain the multiple sets of target histograms; When the number of pixels of the histogram included in the first preset order range in the multiple groups of histograms is less than the number of pixels of the histogram included in the second preset order range, the brightness parameters of the pixels of the histogram within the second preset order range are adjusted to obtain multiple groups of the target histograms.
4. The method according to claim 1, wherein When it is determined that the distribution of the multiple groups of histograms does not satisfy the preset distribution rule, adjusting the display parameters of the pixels in the histograms to be adjusted in the multiple groups of histograms to obtain the multiple groups of target histograms includes: Determining the entropy of each histogram in the plurality of groups of histograms to obtain a plurality of entropies; Calculating the sum of the multiple entropies to obtain a total entropy value; When the total entropy value is less than a first preset value, the contrast parameters of the pixels in the to-be-adjusted histograms among the multiple groups of histograms are adjusted to obtain the multiple groups of target histograms.
5. The method according to claim 1, wherein Adjusting display parameters of pixels in the histograms to be adjusted in the multiple sets of histograms to obtain multiple sets of target histograms includes: determining a number of pixels in each of the plurality of sets of histograms; Determining a histogram having a number of pixels greater than a second preset value among the multiple groups of histograms as the histogram to be adjusted; Determining a histogram in which the number of pixels in the histogram to be adjusted is greater than a third preset value as a starting histogram of the histogram to be adjusted; Starting from the starting histogram, the display parameters of the pixels in the histogram to be adjusted are adjusted according to the order of grayscale values to obtain the multiple groups of target histograms.
6. The method according to claim 5, characterized in that Adjusting the display parameters of the pixels in the histogram to be adjusted according to the order of grayscale values starting from the starting histogram to obtain the multiple groups of target histograms includes: Determining the slope of a starting broken line corresponding to the grayscale value of the starting histogram; Adjusting the slopes of the broken lines corresponding to the histograms to be adjusted sequentially from the starting broken line according to a preset slope parameter to obtain multiple groups of adjusted histograms; Determining grayscale value changes of pixels in the multiple groups of adjusted histograms; The distributions of the multiple groups of adjusted histograms and unadjusted histograms are readjusted according to the grayscale value changes to obtain the multiple groups of target histograms.
7. The method according to claim 5, characterized in that Adjusting the display parameters of the pixels in the histogram to be adjusted according to the order of grayscale values starting from the starting histogram to obtain the multiple groups of target histograms includes: Starting from the starting histogram, comparing the number of pixels between two adjacent histograms to be adjusted in the histogram to be adjusted; equalizing the number of pixels between the two adjacent histograms to be adjusted based on the comparison result to obtain multiple groups of adjusted histograms; Determining grayscale value changes of pixels in the multiple groups of adjusted histograms; The distribution of the multiple groups of adjusted histograms and unadjusted histograms is readjusted according to the grayscale value variation to obtain multiple groups of target histograms.
8. The method according to claim 7, characterized in that The number of pixels between the two adjacent histograms to be adjusted is balanced based on the comparison result, and a plurality of groups of adjusted histograms are obtained, including: When the number of pixels in the starting histogram is not equal to the number of pixels in the adjacent first histogram to be adjusted, adjusting the number of pixels between the starting histogram and the first histogram to be adjusted; The adjusted first histogram to be adjusted is compared with the second histogram to be adjusted in terms of the number of pixels, and the pixel distribution between the adjusted first histogram to be adjusted and the second histogram to be adjusted is adjusted based on the comparison result, wherein the adjusted first histogram to be adjusted is adjacent to the second histogram to be adjusted, and the second histogram to be adjusted is different from the starting histogram.
9. The method according to claim 1, characterized in that When it is determined that the distribution of the multiple groups of histograms does not satisfy the preset distribution rule, before adjusting the display parameters of the pixels in the histograms to be adjusted in the multiple groups of histograms to obtain the multiple groups of target histograms, the method further includes: Dividing pixels in a previous frame of the image to be processed into a plurality of histograms according to grayscale values, wherein the plurality of histograms of the previous frame are arranged according to the order of grayscale values, and each histogram of the previous frame includes a number of pixels within a preset order range; It is determined that the scene of the image to be processed has changed by using the multiple groups of histograms of the previous frame image and the multiple groups of histograms of the image to be processed.
10. The method according to claim 9, characterized in that Determining whether the scene of the image to be processed has changed by using the multiple groups of histograms of the previous frame image and the multiple groups of histograms of the image to be processed includes: Determining the rate of change between the multiple groups of histograms of the previous frame image and the multiple groups of histograms of the image to be processed; When the rate of change is greater than a preset threshold, it is determined that the scene of the image to be processed has changed.
11. An image processing device, characterized in that: include: a grouping module, configured to group pixels in the determined image to be processed into a plurality of histogram groups according to grayscale values, wherein the plurality of histogram groups are arranged according to the order of grayscale values, and each histogram group includes a number of pixels within a preset order range; A first adjustment module is configured to adjust display parameters of pixels in the to-be-adjusted histograms among the multiple histograms to obtain multiple sets of target histograms when it is determined that the distribution of the multiple histograms does not satisfy a preset distribution rule, wherein the display parameters include a brightness parameter and a contrast parameter; A second adjustment module, configured to adjust the image to be processed based on the multiple sets of target histograms; Among them, the second adjustment module is further used to determine the slopes of the broken lines corresponding to the multiple groups of target histograms to obtain multiple groups of target slopes; determine the mapping relationship between each target slope and the display parameter of the pixel in each target histogram to obtain a mapping relationship table; use the mapping relationship table to update the preset gamma mapping table of the image to be processed to obtain an updated gamma mapping table; and use the updated gamma mapping table to adjust the image to be processed.
12. A storage medium, characterized in that: The storage medium stores a computer program, wherein the computer program is configured to execute the method according to any one of claims 1 to 10 when executed.
13. An electronic device comprising a memory and a processor, characterized in that: A computer program is stored in the memory, and the processor is configured to run the computer program to perform the method according to any one of claims 1 to 10.
Citation Information
Patent Citations
Method and device for adjusting image brightness
CN104517268B
Adaptive Contrast Enhancement Algorithm Based on Gray Scale Transformation
CN105741245B
Adjustment method of output brightness, adjustment method of Gamma curve and display device
CN105895054A
Dynamic Contrast Enhancement Method Based on Function Curve Transformation
CN106033600B
Image brightness adjustment method and device, and terminal equipment
CN106897963A