A method of adjusting contrast of an image, a storage medium and a computer program product
Patent Information
- Application Number
- CN202210398213.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-15
- Publication Date
- 2026-10-23
- Estimated Expiration
- 2042-04-15
AI Technical Summary
[0002]图像局域对比度调整算法是现有的常规技术,相对于全局对比度调整算法(如直方图均衡化),局域对比度调整算法(如CLAHE等)的调整效果更好,但是在设置对比度调整强度比较大的时候,图像局域对比度调整算法会存在一些严重缺陷,例如,出现边缘佛光或者出现局域亮斑或者局域黑斑
[0018]本申请的一些实施例通过对第i原图像块进行分块并统计在各子图像块上纹理的分布情况来得到纹理属性值,提升得到的该值的准确性。
Smart Images

Figure CN116263942B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image processing, and more specifically, embodiments of this application relate to a method for adjusting image contrast, a storage medium, and a computer program product. Background Technology
[0002] Local contrast adjustment algorithms are existing conventional techniques. Compared with global contrast adjustment algorithms (such as histogram equalization), local contrast adjustment algorithms (such as CLAHE) have better adjustment effects. However, when the contrast adjustment intensity is set to be large, local contrast adjustment algorithms will have some serious defects, such as the appearance of edge halos, local bright spots, or local dark spots.
[0003] Therefore, how to effectively improve the display effect of image local contrast adjustment algorithms has become an urgent technical problem to be solved. Summary of the Invention
[0004] The purpose of this application is to provide a method, storage medium, and computer program product for adjusting image contrast. The new image local contrast adjustment algorithm provided by this application effectively improves problems such as halos and local patches.
[0005] In a first aspect, some embodiments of this application provide a method for adjusting image contrast, the method comprising: adjusting the contrast of an i-th original image block according to an image local contrast adjustment algorithm to obtain an i-th image block, wherein the i-th original image block is an arbitrary image block obtained by dividing the original image to be processed; performing brightness correction on the i-th image block to obtain an i-th target image block corresponding to the i-th original image block; and obtaining a target image based on the i-th target image block.
[0006] Some embodiments of this application improve the phenomenon of halo or spots in images obtained by using only the image local contrast adjustment algorithm by adjusting the brightness of image blocks obtained by the image local contrast adjustment algorithm.
[0007] In some embodiments of this application, the step of performing brightness correction on the i-th image block to obtain the i-th target image block corresponding to the i-th original image block includes: obtaining a brightness correction coefficient value, wherein the brightness correction coefficient value is related to the brightness of the i-th original image block; and performing brightness correction on the i-th image block at least according to the brightness correction coefficient value to obtain the i-th target image block corresponding to the i-th original image block.
[0008] Some embodiments of this application determine the brightness correction coefficient value by using the brightness of the i-th original image block, which can make the brightness of the image block after brightness correction as close as possible to that of the surrounding image blocks, thus avoiding the appearance of halo effects or spots.
[0009] In some embodiments, obtaining the brightness correction coefficient value includes: obtaining the brightness feature value of the i-th original image block to obtain the original brightness feature value; obtaining the brightness feature value of the i-th image block to obtain the initial adjusted brightness feature value; and obtaining the brightness correction coefficient value based on the original brightness feature value and the initial adjusted brightness feature value.
[0010] Some embodiments of this application obtain the brightness characteristics of the original image block corresponding to the i-th image block, and then perform brightness correction on the i-th image block according to the brightness characteristics, thereby improving the brightness matching between the obtained i-th target image block and the surrounding neighboring image blocks and avoiding the appearance of halo or spots.
[0011] In some embodiments, obtaining the original brightness feature value from the brightness feature value of the i-th original image block includes: calculating the mean value of the pixel values of all pixels in the i-th original image block to obtain the original average brightness value; obtaining the initial adjusted brightness feature value from the brightness feature value of the i-th image block includes: calculating the mean value of the pixel values of all pixels in the i-th image block to obtain the initial adjusted average brightness value; obtaining the brightness correction coefficient value based on the original brightness feature value and the initial adjusted brightness feature value includes: calculating the ratio of the original average brightness value and the initial adjusted average brightness value to obtain the brightness correction coefficient value; or, calculating the ratio of the initial adjusted average brightness value to the original average brightness value to obtain the initial adjusted average brightness value.
[0012] Some embodiments of this application characterize the original brightness feature value of the i-th original image block by using the average brightness value of the i-th original image block, and characterize the initial adjusted brightness feature value of the i-th image block by using the average brightness value of the i-th image block, which can improve the accuracy of the obtained brightness correction coefficient value.
[0013] In some embodiments, the step of performing brightness correction on the i-th image block at least according to the brightness correction coefficient value to obtain the i-th target image block corresponding to the i-th original image block includes: multiplying or dividing the pixel value of each pixel point on the i-th image block with the brightness correction coefficient value to obtain the value of the corresponding pixel point on the i-th target image block.
[0014] Some embodiments of this application multiply the i-th image block by the obtained brightness correction coefficient value to adjust the brightness of the i-th image block to the average brightness level of the i-th original image block, thus avoiding the appearance of halo or spots in the image after contrast adjustment.
[0015] In some embodiments, the step of correcting the brightness of the i-th image block at least according to the brightness correction coefficient value includes: obtaining a texture attribute value of the i-th original image block, wherein the texture attribute value is used to characterize the distribution characteristics of texture on the i-th original image block; obtaining a target brightness correction coefficient value according to the texture attribute value and the brightness correction coefficient value, and correcting the brightness of the i-th image block according to the target brightness correction coefficient value, wherein the target brightness correction coefficient value is used to characterize the brightness adjustment intensity of the i-th image block.
[0016] Some embodiments of this application also determine the final target brightness correction coefficient value through texture attribute values, thereby further improving the contrast of the obtained image while avoiding phenomena such as halo or spots.
[0017] In some embodiments, obtaining the texture attribute value of the i-th original image block includes: obtaining the edge texture information of the i-th original image block to obtain a texture image block; dividing the texture image block into N sub-image blocks and statistically analyzing the texture distribution features on the N sub-image blocks; and obtaining the texture attribute value based on the texture distribution features.
[0018] Some embodiments of this application obtain texture attribute values by dividing the i-th original image block into sub-blocks and statistically analyzing the distribution of textures on each sub-image block, thereby improving the accuracy of the obtained values.
[0019] In some embodiments, the step of statistically analyzing the texture distribution features on the N sub-image patches includes: determining the proportion of textureless sub-image patches in the N sub-image patches; the step of obtaining the texture attribute value based on the texture distribution features includes: the texture attribute value is positively correlated with the proportion; or, the step of statistically analyzing the texture distribution features on the N sub-image patches includes: determining the proportion of textured sub-image patches in the N sub-image patches; the step of obtaining the texture attribute value based on the texture distribution features includes: the texture attribute value is negatively correlated with the proportion.
[0020] Some embodiments of this application determine the magnitude of texture attribute values by statistically analyzing the proportion of textureless sub-image blocks or textured image blocks, thereby achieving the quantification of texture attribute values.
[0021] In some embodiments, the target brightness correction coefficient value is calculated using the following formula:
[0022] 1.0 + (x - 1.0) * y
[0023] Where x is the brightness correction coefficient value, y is the texture attribute value, and the value of y is greater than or equal to a first value and less than or equal to a second value, wherein the second value is greater than the first value.
[0024] In some embodiments of this application, the step of correcting the brightness of the i-th image block according to the target brightness correction coefficient includes: multiplying or dividing the pixel value of each pixel point in the i-th image block by the target brightness correction coefficient value to obtain the i-th target image block.
[0025] Some embodiments of this application perform brightness correction on the i-th image block by means of a target brightness correction coefficient value. By means of the target brightness correction coefficient value, the brightness of the i-th image block corresponding to the original image block with rich texture is not adjusted, but the brightness of the i-th image block corresponding to the original image block with relatively poor texture is adjusted, which can improve the contrast adjustment effect.
[0026] In some embodiments, repeating the above process to obtain a target image corresponding to the original image includes: repeating the above process to obtain all target image blocks, and stitching all target image blocks together with stitching lines to obtain the target image.
[0027] Some aspects of this application involve stitching together target image blocks using a similar stitching technique to obtain the target image.
[0028] In some embodiments, the image local contrast adjustment algorithm includes a local histogram equalization algorithm.
[0029] Some embodiments of this application employ a local histogram equalization algorithm to implement an image local contrast adjustment algorithm.
[0030] Secondly, some embodiments of this application provide an apparatus for adjusting image contrast, the apparatus comprising: an image local contrast adjustment module configured to adjust the contrast of an i-th original image block according to an image local contrast adjustment algorithm to obtain an i-th image block, wherein the i-th original image block is an arbitrary image block obtained by dividing the original image to be processed; a brightness adjustment module configured to correct the brightness of the i-th image block to obtain an i-th target image block corresponding to the i-th original image block; and a target image acquisition module configured to obtain a target image based on the i-th target image block.
[0031] Thirdly, some embodiments of this application provide a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, can implement the methods described in any of the embodiments of the first aspect above.
[0032] Fourthly, some embodiments of this application provide an electronic device including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the program, can implement the method described in any of the embodiments of the first aspect above.
[0033] Fifthly, some embodiments of this application provide a computer program product, the computer program product including a computer program, wherein the computer program, when executed by a processor, can implement the method described in any of the embodiments of the first aspect above.
[0034] Sixthly, some embodiments of this application provide an image processor configured to implement the method described in any of the embodiments of the first aspect above. Attached Figure Description
[0035] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments of this application will be briefly introduced below. It should be understood that the following drawings only show some embodiments of this application and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0036] Figure 1 This is a schematic diagram of the composition of an image acquisition system provided in an embodiment of this application;
[0037] Figure 2 A flowchart for acquiring a contrast-adjusted image, provided for related technologies;
[0038] Figure 3 The image obtained after contrast adjustment using the image local contrast adjustment algorithm of related technology provided in the embodiments of this application;
[0039] Figure 4 This is one of the flowcharts corresponding to the method for adjusting image contrast provided in the embodiments of this application;
[0040] Figure 5 The second flowchart corresponds to the method for adjusting image contrast provided in the embodiments of this application;
[0041] Figure 6 The third flowchart corresponds to the method for adjusting image contrast provided in the embodiments of this application;
[0042] Figure 7 A block diagram of the apparatus for adjusting image contrast provided in the embodiments of this application;
[0043] Figure 8 This is a schematic diagram of the electronic device provided in the embodiments of this application. Detailed Implementation
[0044] The technical solutions in the embodiments of this application will now be described with reference to the accompanying drawings.
[0045] It should be noted that similar reference numerals and letters in the following figures indicate similar items; therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures. Furthermore, in the description of this application, terms such as "first," "second," etc., are used only to distinguish descriptions and should not be construed as indicating or implying relative importance.
[0046] In recent years, significant progress has been made in research on technologies based on artificial intelligence, such as computer vision, deep learning, machine learning, image processing, and image recognition. Artificial intelligence (AI) is an emerging science and technology that studies and develops theories, methods, technologies, and application systems to simulate and extend human intelligence. AI is a comprehensive discipline involving numerous technologies, including chips, big data, cloud computing, the Internet of Things, distributed storage, deep learning, machine learning, and neural networks. Computer vision, as an important branch of AI, specifically enables machines to recognize the world. Computer vision technologies typically include face recognition, liveness detection, fingerprint recognition and anti-counterfeiting verification, biometric recognition, face detection, pedestrian detection, object detection, image processing, image recognition, image semantic understanding, image retrieval, text recognition, video processing, video content recognition, behavior recognition, 3D reconstruction, virtual reality, augmented reality, simultaneous localization and mapping (SLAM), computational photography, and robot navigation and localization. With the research and advancement of artificial intelligence technology, this technology has been applied in numerous fields, such as security, urban management, traffic management, building management, park management, facial recognition access control, facial recognition attendance, logistics management, warehouse management, robotics, intelligent marketing, computational photography, mobile imaging, cloud services, smart homes, wearable devices, autonomous driving, autonomous driving, smart healthcare, facial payment, facial unlocking, fingerprint unlocking, identity verification, smart screens, smart TVs, cameras, mobile internet, live streaming, beautification, makeup, medical aesthetics, and intelligent temperature measurement.
[0047] The inventors of this application discovered in their research that image contrast adjustment algorithms (e.g., global histogram equalization or local histogram equalization) can cause uncontrollable and significant changes in brightness while enhancing image contrast. Therefore, it is understandable that when local image contrast adjustment is performed based on region blocks, the brightness of a certain image block may be significantly different from the surrounding area. This will result in an unnatural transition in the final image on these region blocks, manifested as the appearance of halo-like or bright black patches on the image after contrast adjustment.
[0048] To address the aforementioned issues, some embodiments of this application adjust the brightness of image blocks obtained using the local contrast adjustment algorithm to improve abnormal local blocks, ultimately improving the image quality after local contrast adjustment. Some embodiments of this application also use texture information analysis to determine the intensity of brightness correction for image blocks obtained using the local contrast adjustment algorithm, ensuring the contrast adjustment algorithm's effectiveness is maintained as much as possible without the appearance of halos or abnormal patches.
[0049] Please refer to Figure 1 , Figure 1 A system for adjusting image contrast, provided for related technologies, includes: a lens 100, an image sensor 200, and an image processor 300. The following is in conjunction with... Figure 1 The process of acquiring and displaying an image is illustrated by example.
[0050] Figure 1 Sunlight shines on a cup 400, and the light reflected from the cup 400 passes through a lens 100 and reaches an image sensor 200. The image sensor converts the light signal reflected from the cup into an electrical signal to obtain the raw image (i.e., RAW image data, or simply RAW data). Since the raw image acquired by the image sensor cannot be directly used for display, object segmentation, or recognition, etc., ... Figure 1 As shown, the raw image acquired by the image sensor 200 also needs to be processed by the image processor 300 to obtain a target image that can be directly used for display or for target recognition or classification.
[0051] The following section describes the functions of the image processor 300 in the context of a CMOS-type image sensor.
[0052] Depend on Figure 1 The image output by the image sensor is a RAW image, which is the raw data of the light source signal captured by the CMOS or CCD image sensor and converted into a digital signal. Figure 1 The image processor is used at least to obtain an RGB image by color interpolation based on the data of each pixel acquired from the image sensor (i.e., RAW RGB data). In some embodiments, the image processor further converts the RGB image into a YUV format image.
[0053] Understandable, Figure 1The image processor can also be used to perform black level correction, lens vignetting correction, bad pixel correction, automatic white balance, high dynamic range image processing, bit compression, Bayer domain noise reduction, and de-mosaic processing on the input image. The embodiments of this application do not limit the types of processor modules included in the image processor or the sequential order of these processing modules within the image processor.
[0054] After processing by the image processor 300, the target image is obtained. Some of the target image needs to be output to high-definition interfaces such as monitors, mobile phones, and computer displays, while others will be used in image recognition and target localization fields, such as intelligent robots or target positioning. The embodiments of this application do not limit the specific use of the target image.
[0055] In some embodiments of this application, the image processor 300 needs to adjust the image contrast. It should be noted that the image processor 300 uses various algorithms to adjust the image contrast. For example, related technologies disclose algorithms such as global histogram equalization (GHE) or local contrast adjustment algorithms (e.g., local histogram equalization). It is understood that the global histogram equalization algorithm uses the same histogram transformation for all pixels in the entire image, and it works well for images with relatively even pixel value distributions. However, if the image includes areas that are significantly darker or brighter than other areas, the contrast in these areas will not be effectively enhanced. Local histogram equalization algorithms include adaptive histogram equalization (AHE) or contrast-limited adaptive histogram equalization (CLAHE), where AHE equalizes each pixel using the histogram of pixels within a rectangular area surrounding it. CLAHE differs from adaptive histogram equalization primarily in its contrast limiting.
[0056] The following is combined Figure 2 This document exemplifies a method for adjusting image contrast using a local contrast adjustment algorithm. For example... Figure 2As shown, the contrast adjustment process includes: S101, dividing the original image into multiple original image blocks to be adjusted in brightness. For example, the original image (i.e., the image to be contrast adjusted) is divided into 8 equal parts horizontally and vertically to obtain multiple original image blocks. S102, using an image local contrast adjustment algorithm (e.g., a local histogram equalization algorithm) to perform contrast adjustment on each original image block to obtain contrast-adjusted image blocks. For example, the i-th original image block from the previous step is contrast-adjusted using a histogram equalization algorithm to obtain the i-th image block. S103, stitching the contrast-adjusted image blocks together to obtain a contrast-adjusted image. For example, obtaining the contrast-adjusted image blocks corresponding to all original image blocks and stitching all these image blocks together to obtain a contrast-adjusted image.
[0057] Understandably, as described above, when adjusting contrast based on regions, the brightness of a particular region may differ significantly from its surroundings. This can lead to unnatural transitions in the final image across these regions, manifesting as halos or bright black patches on the image after contrast adjustment (e.g.,...). Figure 3 The first region 150 is shown.
[0058] The following is combined Figure 4 An exemplary method for adjusting image contrast performed by an image processor is presented, and unlike the prior art, the halo and spot phenomena on the target image obtained by using this method are significantly improved.
[0059] like Figure 4 As shown, some embodiments of this application provide a method for adjusting image contrast. The method includes: S210, adjusting the contrast of an i-th original image block according to an image local contrast adjustment algorithm to obtain an i-th image block, wherein the i-th original image block is an arbitrary image block obtained by dividing the original image to be processed. S220, performing brightness correction on the i-th image block to obtain an i-th target image block corresponding to the i-th original image block. S230, obtaining a target image based on the i-th target image block; that is, repeating the image processing steps S210 and S220 to obtain a target image corresponding to the original image (i.e., the image to be contrast adjusted).
[0060] It should be noted that, in order to obtain a contrast-adjusted target image corresponding to the original image, S210 and S220 can be repeatedly executed to obtain each target image block. Then, these target image blocks are stitched together using methods such as stitching to obtain the target image. It is understood that, since the target image involved in S230 has undergone brightness correction on each image block obtained using an image local contrast adjustment algorithm (e.g., local histogram equalization algorithm), it can effectively improve problems such as halos and spots in the obtained image.
[0061] The above process is illustrated below by example.
[0062] S210 refers to the original image that requires contrast adjustment; this image is understood to be a grayscale image. For example, using... Figure 1 The lens captures an image and obtains a grayscale image of that image, then adjusts the contrast based on that grayscale image.
[0063] S210 involves the i-th original image block, which is obtained by dividing the original image (i.e., the image that needs contrast adjustment) into blocks. For example, in some embodiments of this application, the original image is divided into N equal parts horizontally and vertically to obtain multiple original image blocks. In some embodiments of this application, the original image is divided into blocks, and the combination of these original image blocks exactly covers the entire original image, and there is no overlap of identical pixels between different original image blocks. In some embodiments of this application, the original image is divided into blocks, and there may be overlapping areas between these original image blocks.
[0064] The image local contrast adjustment algorithms involved in S210 include local histogram equalization algorithm AHE or local histogram equalization CLAHE with added contrast limits.
[0065] In some embodiments of this application, S220 performs brightness correction on the i-th image block at least based on the brightness characteristics of the i-th image block. For example, in some embodiments of this application, S220 performs brightness correction on the i-th image block based on the brightness characteristics of the i-th original image block. In some embodiments of this application, S220 performs brightness correction on the i-th image block based on both the brightness characteristics and texture distribution characteristics of the i-th original image block. For example, a maximum brightness adjustment amount is determined based on the brightness characteristics of the i-th original image block, and a specific brightness adjustment amount is determined based on the texture distribution characteristics of the i-th original image block. In some embodiments of this application, S220 performs brightness correction on the i-th image block based on the brightness characteristics of the i-th original image block and its neighboring original image blocks.
[0066] The implementation process of S220 is illustrated below.
[0067] like Figure 5 The S220 example includes: S221, obtaining a brightness correction coefficient value, wherein the brightness correction coefficient value is related to the brightness of the i-th original image block; and S222, performing brightness correction on the i-th image block at least according to the brightness correction coefficient value to obtain an i-th target image block corresponding to the i-th original image block.
[0068] The following example uses the i-th original image block obtained by dividing the original image as an illustration. Figure 4 Each step.
[0069] The methods for obtaining the brightness correction coefficient value involved in S221 include the following examples.
[0070] In some embodiments of this application, the brightness of the i-th image block is adjusted to the brightness of the i-th original image block, and the corresponding brightness correction coefficient is the ratio of the overall average brightness of the i-th original image block to the overall average brightness of the i-th image block, or the brightness correction coefficient is the ratio of the overall average brightness of the i-th image block to the overall average brightness of the i-th original image block. In some embodiments of this application, the brightness of the i-th image block is adjusted to the average brightness of multiple adjacent original image blocks, including the i-th original image block, and the corresponding brightness correction coefficient is the ratio of the average brightness of the i-th original image block and the multiple original image blocks adjacent to it to the overall average brightness of the i-th image block, or the brightness correction coefficient is the ratio of the overall average brightness of the i-th image block to the average brightness of the i-th original image block and the multiple original image blocks adjacent to it.
[0071] The process of obtaining the brightness correction coefficient value in S221 is illustrated below by taking the example of adjusting the brightness of the i-th image block to a brightness related to that of the i-th original image block.
[0072] For example, in some embodiments of this application, S221 includes:
[0073] The first step is to obtain the brightness feature value of the i-th original image block to obtain the original brightness feature value.
[0074] It should be noted that the original brightness feature value can be the average gray value of all pixels in the entire i-th original image block, or the average gray value of some pixels in the entire i-th original image block.
[0075] For example, the average pixel value of all pixels in the i-th original image block is calculated to obtain the original average brightness value.
[0076] The second step is to obtain the brightness feature value of the i-th image block to obtain the initial adjusted brightness feature value.
[0077] It should be noted that the initial brightness adjustment feature value can be the average gray value of all pixels in the entire i-th image block, or the average gray value of some pixels in the entire i-th image block.
[0078] For example, the initial adjusted brightness average value is obtained by calculating the mean value of the pixel values of all pixels in the i-th image block.
[0079] The third step is to obtain the brightness correction coefficient value based on the original brightness feature value and the initial adjusted brightness feature value.
[0080] For example, the brightness correction coefficient value can be obtained by calculating the ratio of the original average brightness value to the initial adjusted average brightness value; or, the brightness correction coefficient value can be obtained by calculating the ratio of the initial adjusted average brightness value to the original average brightness value.
[0081] It is understood that some embodiments of this application characterize the original brightness feature value of the i-th original image block by using the average brightness value of the i-th original image block, and characterize the initial adjusted brightness feature value of the i-th image block by using the average brightness value of the i-th image block, which can improve the accuracy of the obtained brightness correction coefficient value.
[0082] S222 involves methods for obtaining the i-th target image patch, including the following examples.
[0083] In some embodiments of this application, S222 includes, for example, multiplying the pixel value of each pixel in the i-th image block by the brightness correction coefficient value (if the correction coefficient value is the ratio of the original average brightness value to the initial adjusted average brightness value) or dividing the pixel value by the brightness correction coefficient value (if the correction coefficient value is the ratio of the initial adjusted average brightness value to the original average brightness value) to obtain the i-th target image block. In some embodiments of this application, multiplying or dividing the i-th image block by the obtained brightness correction coefficient value can adjust the brightness of the i-th image block to the average brightness level of the i-th original image block, avoiding the appearance of halo effects or spots in the image after contrast adjustment.
[0084] To further improve the effect of the contrast adjustment algorithm, in some embodiments of this application, S222 includes, for example:
[0085] The first step is to obtain the texture attribute value of the i-th original image block, wherein the texture attribute value is used to characterize the distribution characteristics of the texture on the i-th original image block.
[0086] For example, the first step includes: calculating the ratio of the area of the texture region to the area of the i-th original image block to obtain the texture attribute value.
[0087] For example, the first step includes: obtaining the edge texture information of the i-th original image block to obtain a texture image block, dividing the texture image block into N sub-image blocks and statistically analyzing the texture distribution features on the N sub-image blocks, and obtaining the texture attribute value based on the texture distribution features.
[0088] It should be noted that, in some embodiments of this application, the above-mentioned statistical analysis of the texture distribution features on the N sub-image blocks includes, for example, determining the proportion of textureless sub-image blocks in the N sub-image blocks. Correspondingly, the above-mentioned obtaining the texture attribute value based on the texture distribution features includes, for example, setting a larger texture attribute value if the proportion is larger, and setting a larger texture attribute value if the proportion is smaller (i.e., the texture attribute value is positively correlated with the proportion). In some embodiments of this application, the above-mentioned statistical analysis of the texture distribution features on the N sub-image blocks includes, for example, determining the proportion of textureless sub-image blocks in the N sub-image blocks. Correspondingly, the above-mentioned obtaining the texture attribute value based on the texture distribution features includes, for example, setting a larger texture attribute value if the proportion is larger, and setting a smaller texture attribute value if the proportion is smaller (i.e., the texture attribute value is negatively correlated with the proportion).
[0089] In some embodiments of this application, the texture attribute value ranges from greater than or equal to zero to less than or equal to 1, and the size of the texture attribute value is determined according to the proportion. For example, if a texture image block is divided into 10 sub-image blocks, and it is found that 7 of the 10 sub-image blocks do not have texture, then the corresponding texture attribute value is 0.7. For example, if a texture image block is divided into 10 sub-image blocks, and it is found that 3 of the 10 sub-image blocks have texture, then the corresponding texture attribute value is 0.3.
[0090] The second step involves obtaining a target brightness correction coefficient value based on the texture attribute value and the brightness correction coefficient value, and then correcting the brightness of the i-th image block according to the target brightness correction coefficient value. The target brightness correction coefficient value characterizes the intensity of the brightness adjustment applied to the i-th image block. This second step exemplarily includes multiplying or dividing the pixel value of each pixel in the i-th image block by the target brightness correction coefficient value to obtain the i-th target image block.
[0091] The following example illustrates the calculation formula for the target brightness correction coefficient value involved in the second step.
[0092] For example, in some embodiments of this application, the above-mentioned statistical analysis of the texture distribution features on the N sub-image blocks includes: determining the proportion of textureless sub-image blocks in the N sub-image blocks; correspondingly, the above-mentioned obtaining the texture attribute value based on the texture distribution features includes: if the proportion is larger, the texture attribute value is set to be larger; if the proportion is smaller, the texture attribute value is set to be smaller. In this case, the calculation formula for the target brightness correction coefficient value is as follows: 1.0 + (x - 1.0) * y, where x is the brightness correction coefficient value, y is the texture attribute value, and the value of y is greater than or equal to a first value and less than or equal to a second value, where the second value is greater than the first value; if the proportion is 100%, then y is taken as the second value.
[0093] It is understood that some embodiments of this application obtain texture attribute values by dividing the i-th original image block into sub-blocks and statistically analyzing the distribution of texture on each sub-block, thereby improving the accuracy of the obtained value. Some embodiments of this application determine the magnitude of the texture attribute value by statistically analyzing the proportion of textureless sub-blocks, thus achieving the quantification of the texture attribute value. Some embodiments of this application also provide a method for determining texture attribute values by statistically analyzing the proportion of textured sub-blocks, achieving the quantization operation of texture attribute values. Some embodiments of this application perform brightness correction on the i-th image block using a target brightness correction coefficient, achieving brightness correction for image blocks with relatively little texture without adjusting the brightness (which can be considered as brightness correction with a target brightness correction coefficient of 1), while performing brightness correction on image blocks with relatively little texture, ensuring better contrast for the i-th image block corresponding to the texture-rich original image block.
[0094] The following is combined Figure 6 The method of obtaining a contrast-adjusted target image is illustrated by taking the local histogram equalization algorithm as an example.
[0095] like Figure 6 As shown, in some embodiments of this application, the method for adjusting image contrast includes:
[0096] S301, the original image is divided into multiple original image blocks, and the i-th original image block is any one of the original image blocks obtained from the division.
[0097] Specifically, the input original image is divided into 16 equal parts horizontally and vertically to obtain multiple small square images, which are thus multiple original image blocks (that is, the input original image is divided into 16x16 non-overlapping original image blocks). Any one of these original image blocks is represented as ai, where the value of i is greater than or equal to 1 and less than or equal to the total number of image blocks obtained by dividing the image.
[0098] S302, perform histogram equalization on the i-th original image block to obtain the i-th image block.
[0099] Specifically, for each original image block ai obtained in S301, the adjusted histogram after global histogram equalization is calculated to obtain the i-th image block bi (i.e. the i-th image block) corresponding to each image block ai.
[0100] S303, calculate the average brightness ratio parameter value between the i-th original image block and the i-th image block (as an example of the brightness correction coefficient value).
[0101] Specifically, the average brightness ratio parameter x is obtained by calculating the ratio of the average brightness of the i-th original image block ai to the average brightness of the i-th image block bi.
[0102] It should be noted that if x is obtained by "ai average brightness / bi average brightness", then the calculation for brightness correction of the i-th image block based solely on the brightness correction coefficient is: x2 * (values of each pixel in the bi image block). If x is obtained by "bi average brightness / ai average brightness", then the calculation for brightness correction of the i-th image block based solely on the brightness correction coefficient is: (values of each pixel in the bi image block) / x2. It is understandable that if brightness correction of the i-th image block is performed solely based on the brightness correction coefficient value, then the steps S304, S305, and S306 for obtaining texture attributes are unnecessary.
[0103] S304, calculate the edge texture information of the i-th original image block to obtain the edge texture image block.
[0104] Specifically, the texture information of the i-th original image block is calculated using texture extraction algorithms such as edge extraction algorithms, Canny algorithms, or Sobel algorithms.
[0105] It should be noted that the edge texture image patch here is an image patch of the same size as the i-th original image patch ai, used to reflect texture features. The larger the pixel value of each pixel on the image patch, the higher the texture gradient, and vice versa.
[0106] S305, the edge texture image block is further divided into multiple sub-image blocks, and the number of times the edge texture information appears in each sub-image block is counted to obtain the texture distribution parameter value of the i-th original image block (as an example of texture attribute value). This texture distribution parameter value is a parameter value used to characterize the texture distribution.
[0107] For example, the edge texture image can be further divided into small squares to obtain multiple sub-image blocks. These small squares can be non-overlapping, and all small squares can exactly cover the edge texture image. Alternatively, the edge texture image can be further divided into small squares to obtain multiple sub-image blocks, where these small squares may overlap. For overlapping areas, a mean superposition process is performed. The distribution of edge texture is statistically analyzed to see if it exists in every small square. The wider the distribution, the closer the texture distribution parameter value y (or texture attribute value) is to 0.0; conversely, the closer it is to 1.0. For example, if every small square contains edge information, the distribution coefficient parameter value y is 0.0; if none of the small squares contain edge information, the distribution coefficient parameter value y is 1.0. It should be noted that if every sub-image block contains gradient information, it indicates the widest distribution; if no gradient information is found in a sub-image block, it indicates the least widespread distribution. For example, if an edge texture image is divided into 10 sub-image blocks, and edge texture is detected in 3 of these 10 sub-image blocks while no texture information is found in the remaining 7, then the texture attribute value y is 0.7. It can be understood that in some other embodiments of this application, the texture distribution parameter value y can also be 0.3. In this case, the wider the distribution, the closer the texture distribution parameter value y (or texture attribute value) is to 1.0, and vice versa.
[0108] S306, the target brightness correction coefficient value is obtained by using the average brightness ratio parameter value and texture distribution parameter value of the i-th original image block, and the brightness of the i-th image block is adjusted by using the target brightness correction coefficient value to obtain the i-th target image block.
[0109] Specifically, if the brightness correction factor value x represents the average brightness of ai / average brightness of bi, and the texture parameter value y is set to 0 when the texture distribution is wider and 1 otherwise, then the formula for calculating the target brightness correction factor value x2 is:
[0110] X² = 1.0 + (x - 1.0) * y
[0111] Where x is the brightness correction coefficient value and y is the texture attribute value.
[0112] It is understandable that the calculation formula of the target brightness correction coefficient value x2 above represents the following meaning: when the texture parameter value y is 0, it means that the texture information of the texture image sub-block is rich and no brightness correction is needed; when y is 1, it means that the strongest brightness correction is needed.
[0113] If the above formula for calculating the target brightness correction coefficient value x2 is used, then the above-mentioned method of adjusting the brightness of the i-th image block using the target brightness correction coefficient value to obtain the i-th target image block includes: adjusting the overall brightness of the i-th image block bi using the target brightness correction coefficient value x2, that is, multiplying the value of each pixel in the i-th image block bi by the coefficient x2. It can be understood that if the brightness correction coefficient value x represents the average brightness of bi / average brightness of ai, then adjusting the overall brightness of the i-th image block bi using the target brightness correction coefficient value x2 means dividing the value of each pixel in the i-th image block bi by the coefficient x2.
[0114] S307, Repeat the above process to obtain all target image blocks, and process each target image block by stitching with stitching lines to obtain the target image.
[0115] It should be noted that image stitching is performed on all target image blocks to obtain the final contrast-adjusted image. Alternatively, when dividing the original image into blocks, overlapping areas are allowed between each block (i.e., different original image blocks ai can overlap). The stitching problem can be eliminated by taking the average of the overlapping areas iteratively. The method of stitching the target image blocks is existing technology and will not be elaborated upon here.
[0116] Combination Figure 6 As can be seen from the above examples, in some embodiments of this application, the brightness of each contrast-adjusted image block and the overall brightness of the image block before adjustment are calculated separately. The brightness of the adjusted blocks is then corrected back to the original brightness level, ensuring only that there are contrast-related changes, thereby improving problems such as "Buddha's light". However, this approach results in a slightly worse contrast effect in the final image compared to when no adjustment is made. Further analysis by the inventors of this application revealed that "Buddha's light" and similar issues typically occur when a large area of textureless region exists within an image block. Large areas of textureless region do not actually require contrast adjustment. Therefore, some embodiments of this application perform gradient analysis on each original image block. Only in original image blocks with large areas of textureless region (e.g., the i-th original image block) is a relatively strong brightness suppression applied to the corresponding adjusted image block (e.g., the i-th image block). This ensures that even with significant improvement in issues such as "Buddha's light", the contrast adjustment effect remains essentially the same as the original effect.
[0117] Please refer to Figure 7 , Figure 7 The present application illustrates an apparatus for adjusting image contrast according to an embodiment of the present application. It should be understood that this apparatus is similar to the one described above. Figure 4Corresponding to the method embodiments, it can execute the various steps involved in the above method embodiments. The specific functions of the device can be found in the description above. To avoid repetition, detailed descriptions are appropriately omitted here. The device includes at least one software function module that can be stored in the memory or embedded in the device's operating system in the form of software or firmware. The device for adjusting image contrast includes: an image local contrast adjustment module 101, a brightness adjustment module 102, and a target image acquisition module 103.
[0118] The image local contrast adjustment module is configured to adjust the contrast of the i-th original image block according to the image local contrast adjustment algorithm to obtain the i-th image block, wherein the i-th original image block is an arbitrary image block obtained by dividing the original image to be processed.
[0119] The brightness adjustment module 102 is configured to perform brightness correction on the i-th image block to obtain the i-th target image block corresponding to the i-th original image block.
[0120] The target image acquisition module 103 is configured to obtain a target image based on the i-th target image block.
[0121] Those skilled in the art will understand that, for the sake of convenience and brevity, the specific working process of the device described above can be referred to the corresponding process in the aforementioned method, and will not be elaborated further here.
[0122] Some embodiments of this application provide a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, can implement the above-described method for adjusting image contrast.
[0123] Some embodiments of this application provide a computer program product, which includes a computer program, wherein when the computer program is executed by a processor, it can implement the method of adjusting image contrast as described above.
[0124] Some embodiments of this application provide an image processor configured to perform, as... Figure 4 The method shown is for adjusting image contrast.
[0125] like Figure 8 As shown, some embodiments of this application provide an electronic device including a memory 510, a processor 520, a bus 530, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the program, can implement the method of adjusting image contrast as described above.
[0126] Processor 520 can process digital signals and can include various computing architectures. For example, it can be a complex instruction set computer architecture, a reduced instruction set computer architecture, or an architecture that implements multiple instruction set combinations. In some examples, processor 520 can be a microprocessor.
[0127] The memory 510 can be used to store instructions executed by the processor 520 or data related to the execution of instructions. These instructions and / or data may include code used to implement some or all of the functions of one or more modules described in the embodiments of this application. The processor 520 of the embodiments of this disclosure can be used to execute the instructions in the memory 510 to implement… Figure 4 The method shown. Memory 510 includes dynamic random access memory, static random access memory, flash memory, optical memory, or other memory well known to those skilled in the art.
[0128] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can also be implemented in other ways. The apparatus embodiments described above are merely illustrative. For example, the flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order than those marked in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram and / or flowchart, and combinations of blocks in block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or action, or using a combination of dedicated hardware and computer instructions.
[0129] In addition, the functional modules in the various embodiments of this application can be integrated together to form an independent part, or each module can exist independently, or two or more modules can be integrated to form an independent part.
[0130] If the aforementioned functions are implemented as software functional modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0131] The above description is merely an embodiment of this application and is not intended to limit the scope of protection of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of protection of this application. It should be noted that similar reference numerals and letters in the following figures indicate similar items; therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures.
[0132] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
[0133] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
Claims
1. A method for adjusting image contrast, characterized in that the method comprises: The i-th original image block is obtained by adjusting the contrast of the i-th original image block according to the local contrast adjustment algorithm. The i-th original image block is any image block obtained by dividing the original image to be processed. The brightness of the i-th image block is corrected to obtain the i-th target image block corresponding to the i-th original image block; The target image is obtained based on the i-th target image block; The step of performing brightness correction on the i-th image block to obtain the i-th target image block corresponding to the i-th original image block includes: obtaining a brightness correction coefficient value, wherein the brightness correction coefficient value is related to the brightness of the i-th original image block; and performing brightness correction on the i-th image block at least according to the brightness correction coefficient value to obtain the i-th target image block corresponding to the i-th original image block. The step of performing brightness correction on the i-th image block at least according to the brightness correction coefficient value includes: obtaining the texture attribute value of the i-th original image block, wherein the texture attribute value is used to characterize the distribution characteristics of texture on the i-th original image block; obtaining a target brightness correction coefficient value according to the texture attribute value and the brightness correction coefficient value, and performing brightness correction on the i-th image block according to the target brightness correction coefficient value; The step of obtaining the texture attribute value of the i-th original image block includes: obtaining the texture information of the i-th original image block to obtain a texture image block; dividing the texture image block into N sub-image blocks and statistically analyzing the texture distribution features on the N sub-image blocks; and obtaining the texture attribute value based on the texture distribution features. The step of statistically analyzing the texture distribution features on the N sub-image patches includes: determining the proportion of textureless sub-image patches in the N sub-image patches; the step of obtaining the texture attribute value based on the texture distribution features includes: the texture attribute value is positively correlated with the proportion; or, the step of statistically analyzing the texture distribution features on the N sub-image patches includes: determining the proportion of textured sub-image patches in the N sub-image patches; the step of obtaining the texture attribute value based on the texture distribution features includes: the texture attribute value is negatively correlated with the proportion. The formula for calculating the target brightness correction coefficient is as follows: 1.0 + (x-1.0) *y in, x is the brightness correction coefficient value, y is the texture attribute value, and the value of y is greater than or equal to a first value and less than or equal to a second value, wherein the second value is greater than the first value.
2. The method as described in claim 1, characterized in that, The process of obtaining the brightness correction coefficient value includes: Obtain the brightness feature value of the i-th original image block to get the original brightness feature value; Obtain the brightness feature value of the i-th image block to obtain the initial adjusted brightness feature value; The brightness correction coefficient value is obtained based on the original brightness feature value and the initial adjusted brightness feature value.
3. The method as described in claim 2, characterized in that, The step of obtaining the brightness feature value of the i-th original image block to obtain the original brightness feature value includes: The average pixel value of all pixels in the i-th original image block is calculated to obtain the original average brightness value; The process of obtaining the initial adjusted brightness feature value from the brightness feature value of the i-th image block includes: The initial adjusted brightness average value is obtained by calculating the mean value of all pixel values in the i-th image block; The process of obtaining the brightness correction coefficient value based on the original brightness feature value and the initial adjusted brightness feature value includes: The correction coefficient value is obtained by calculating the ratio of the original average brightness value to the initial adjusted average brightness value; or, the correction coefficient value is obtained by calculating the ratio of the initial adjusted average brightness value to the original average brightness value.
4. The method according to any one of claims 2-3, characterized in that, The step of performing brightness correction on the i-th image block at least according to the brightness correction coefficient value to obtain the i-th target image block corresponding to the i-th original image block includes: The pixel value of each pixel in the i-th image block is multiplied or divided by the brightness correction coefficient value to obtain the value of the corresponding pixel in the i-th target image block.
5. The method as described in claim 1, characterized in that, The step of correcting the brightness of the i-th image block according to the target brightness correction coefficient includes: The i-th target image block is obtained by multiplying or dividing the pixel value of each pixel in the i-th image block by the target brightness correction coefficient value.
6. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by a processor, it can implement the method described in any one of claims 1-5.
7. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein, When the processor executes the program, it can implement the method described in any one of claims 1-5.
8. A computer program product, characterized in that, The computer program product includes a computer program, wherein the computer program, when executed by a processor, can implement the method as described in any one of claims 1-5.
9. An image processor, characterized in that, The image processor is configured to implement the method as claimed in any one of claims 1-5.
Citation Information
Patent Citations
Image processing method and device and storage medium
CN107451979A