Image enhancement method and readable storage medium

By performing image segmentation and histogram equalization, the problem of image quality degradation in low-light scenes is solved, improving the accuracy of image algorithms and the focusing effect of PDAF algorithms.

CN116128773BActive Publication Date: 2026-03-27HOWAY TECH (WUHAN) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-12-01
Publication Date
2026-03-27

Smart Images

  • Figure CN116128773B_ABST
    Figure CN116128773B_ABST
Patent Text Reader

Abstract

The application provides an image enhancement method and a readable storage medium. The image enhancement method comprises the following steps: determining the number of blocks based on the brightness difference of an input image; dividing the input image into blocks based on the number of blocks to obtain a block image; for each block of the block image, sequentially performing histogram statistics and histogram equalization to obtain a histogram mapping function; and calculating each pixel based on the histogram mapping function to obtain a mapping result. The final output result is related to the mapping result. In this way, on the one hand, the image is enhanced by the histogram equalization method, and on the other hand, the adaptive block scheme compensates for the defect that the mutual influence between different parts of the image is not good in the overall enhancement effect caused by the histogram equalization of the whole image. The above scheme solves the problem that there is no suitable image enhancement algorithm in the prior art under dark light.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image processing technology, and in particular to an image enhancement method and a readable storage medium. Background Technology

[0002] In low-light scenes, the images obtained are often affected by noise. The widespread use of small apertures and small pixels on mobile platforms makes the noise problem more serious, resulting in a decrease in image quality and making it difficult to view with the naked eye.

[0003] In addition, a decrease in image quality may cause problems with some image-based algorithms. For example, it may reduce the speed and accuracy of focusing algorithms based on PD RAW (RAW image composed of phase detection points).

[0004] In scenes with weak texture, the subtle differences in texture information can lead to a decrease in the accuracy of focusing algorithms based on PD RAW, such as... Figure 1 As shown, the linearity of the PDAF (Phase Detection Auto Focus) algorithm output drops significantly near the focal point, which will lead to a decrease in algorithm accuracy (especially...). Figure 1 (The area marked by the dashed box in the middle). Figure 1 In the diagram, curve 1 represents the PD output, and curve 2 represents the confidence value corresponding to the PD output.

[0005] In summary, existing technologies suffer from a lack of suitable image enhancement algorithms for low-light scenes. Summary of the Invention

[0006] The purpose of this invention is to provide an image enhancement method and a readable storage medium to solve the problem of the lack of suitable image enhancement algorithms in low-light scenes in the prior art.

[0007] To address the aforementioned technical problems, this invention provides an image enhancement method comprising the following steps: determining the number of blocks based on the brightness differences of the input image; dividing the input image into blocks based on the number of blocks to obtain block images; sequentially performing histogram statistics and histogram equalization on each block image to obtain a histogram mapping function; and calculating the mapping result for each pixel based on the histogram mapping function.

[0008] The final output of the image enhancement method is the mapping result or is calculated based on the mapping result.

[0009] Optionally, the step of determining the number of blocks based on the brightness difference of the input image includes: selecting the number of blocks from a preset set of block numbers, wherein the largest element in the preset set of block numbers is no greater than 8*8 and the smallest element is no less than 4*4.

[0010] Optionally, the input images are the left and right images from a PD RAW image.

[0011] The image enhancement method includes the following steps: obtaining an average image based on the left image and the right image; determining the number of blocks based on the brightness difference of the average image; dividing the left image and the right image into blocks based on the number of blocks to obtain the block images; performing histogram statistics and histogram equalization sequentially on each block image to obtain a histogram mapping function; and calculating the mapping result of the left image and the right image based on the histogram mapping function.

[0012] Optionally, the step of determining the number of blocks based on the brightness difference of the average image includes: dividing the average image into a first number of brightness calculation images; calculating the brightness information of each brightness calculation image; obtaining the mean square error of the brightness information; and if the mean square error is higher than a preset threshold, setting the number of blocks to a second number of blocks; otherwise, setting the number of blocks to the first number of blocks; wherein the second number of blocks is greater than the first number of blocks.

[0013] Optionally, the image enhancement method is used to input the enhancement results of the left image and the right image into the PDAF algorithm.

[0014] Optionally, the step of dividing the input image into blocks based on the number of blocks to obtain the block images includes: dividing the input image into blocks based on a preset overlap size, such that adjacent block images have common pixels.

[0015] The step of calculating the mapping result for each pixel based on the histogram mapping function includes: for pixels belonging to only one block image, calculating the mapped gray value based on the corresponding histogram mapping function; for pixels belonging to at least two block images, calculating the mapped gray value based on at least two corresponding histogram mapping functions and their positions in at least two block images.

[0016] Optionally, the image enhancement method further includes the following step: stitching and fusing the mapped block images to obtain the enhancement result.

[0017] Optionally, the step of calculating the mapped grayscale value of a pixel belonging to at least two of the said block images based on its corresponding at least two said histogram mapping functions and its position interpolated in at least two of the said block images includes: when the pixel belongs to two of the said block images, calculating according to the following formula: S p =wGa(r p )+(1-w)Gb(r p ), where w = a / (a+b); when the pixel belongs to one of the four image blocks, it is calculated according to the following formula: S p =w1w2Ga(r p )+(1-w1)w2Gb(r p )+w1(1-w2)Gc(r p )+(1-w1)(1-w2)Gd(r p ), where w1=a / (a+b), w2=c / (c+d).

[0018] Among them, S p r represents the mapped grayscale value. p Let represent the pixel, Ga(r) represent the histogram mapping function of the first block image to which the pixel belongs, Gb(r) represent the histogram mapping function of the second block image to which the pixel belongs, Gc(r) represent the histogram mapping function of the third block image to which the pixel belongs, Gd(r) represent the histogram mapping function of the fourth block image to which the pixel belongs, a represent the distance of the pixel from the edge of the first block image along the direction pointing to the second block image, b represent the distance of the pixel from the edge of the second block image along the direction pointing to the first block image, c represent the distance of the pixel from the edge of the first block image along the direction pointing to the third block image, and d represent the distance of the pixel from the edge of the third block image along the direction pointing to the first block image.

[0019] Optionally, the histogram statistics step includes: calculating the histogram based on segment points.

[0020] The steps for determining the segmentation points include: obtaining the number of segments N, the maximum slope slope_max, and the minimum slope slope_min.

[0021] Obtain the cumulative probability distribution function F(x) of the segmented image, where the value of x ranges from 0 to (2^bit_len-1), and bit_len represents the bit length of the container storing the grayscale value of the pixel.

[0022] Assign values ​​to x0 and y0 such that y0 = 0 and x0 = 0.

[0023] k takes values ​​from 0 to (N-1) sequentially, and in each value selection, the following steps are performed: A value is assigned to make y... k+1 = (2^bit_len-1)*k / N, x k+1 =F -1 (y k+1 / (2^bit_len-1)), where F -1 (x) represents the inverse function of F(x); calculate m k =(y k+1 -y k ) / (x k+1 -x k If m k If the slope is less than the minimum slope, then for m... k Reassigning the value to m k =slope_min; if m k >slope_max, then for m k Reassigning the value to m k =slope_max; if neither of the above two conditions is met, then m k Keep the original value; and, if m k If it is reassigned, then for y k+1 Reassigning the value makes y k+1 =y k +m k (x k+1 -x k ), and re-accord according to x k+1 =F -1 (y k+1 Calculate x using / (2^bit_len-1) k+1 .

[0024] x corresponding to all values ​​of k k+1 After the calculation is complete, x0~x N Set as the segment point.

[0025] To address the aforementioned technical problems, according to a second aspect of the present invention, a readable storage medium is provided, on which a program is stored, wherein when the program is executed, the aforementioned image enhancement method is performed.

[0026] Compared with existing technologies, the image enhancement method and readable storage medium provided by this invention include the following steps: determining the number of blocks based on the brightness differences of the input image; dividing the input image into blocks based on the number of blocks to obtain block images; sequentially performing histogram statistics and histogram equalization on each block image to obtain a histogram mapping function; and calculating the mapping result for each pixel based on the histogram mapping function. The final output result is related to the mapping result. This configuration, on the one hand, enhances the image through histogram equalization, and on the other hand, compensates for the defect of poor overall enhancement effect caused by mutual interference between different parts of the image due to histogram equalization of the entire image, through an adaptive block division scheme. The above solution solves the problem of the lack of suitable image enhancement algorithms in low-light scenes in existing technologies. Attached Figure Description

[0027] Those skilled in the art will understand that the accompanying drawings are provided to better understand the invention and do not constitute any limitation on the scope of the invention. Wherein:

[0028] Figure 1 This is the output curve of the PDAF algorithm in weak texture scenes in existing technology;

[0029] Figure 2 This is a schematic flowchart of an image enhancement algorithm according to an embodiment of the present invention;

[0030] Figure 3 This is a flowchart illustrating an image enhancement algorithm according to another embodiment of the present invention;

[0031] Figure 4 This is a schematic diagram of the image overlap region according to an embodiment of the present invention;

[0032] Figure 5 This is yet another schematic diagram of the image overlap region according to an embodiment of the present invention;

[0033] Figure 6 This is a schematic diagram of the segmentation point calculation process according to an embodiment of the present invention;

[0034] Figure 7a This is an image enhancement effect diagram according to an embodiment of the present invention;

[0035] Figure 7b This is an image enhancement effect diagram according to an embodiment of the present invention;

[0036] Figure 7c This is an image enhancement effect diagram according to an embodiment of the present invention;

[0037] Figure 8a This is a schematic diagram of a PD RAW image;

[0038] Figure 8b This is a schematic diagram of yet another PD RAW image;

[0039] Figure 9a This is a PDAF algorithm involved in an embodiment of the present invention. Figure 8a The output curve of the PD RAW image shown is the result of processing.

[0040] Figure 9b This is a PDAF algorithm involved in an embodiment of the present invention. Figure 8b The output curve of the PD RAW image shown is the result of processing.

[0041] In the attached image:

[0042] 1-PD output; 2-Confidence value; 3-First block image; 4-Second block image; 5-Third block image; 6-Fourth block image; 7-Pixel;

[0043] 11 - PD output before enhancement; 21 - Confidence value corresponding to PD output before enhancement; 12 - PD output after enhancement; 22 - Confidence value corresponding to PD output after enhancement. Detailed Implementation

[0044] To make the objectives, advantages, and features of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and specific embodiments. It should be noted that the drawings are all in a very simplified form and are not drawn to scale, and are only used to facilitate and clarify the explanation of the embodiments of the invention. Furthermore, the structures shown in the drawings are often part of the actual structures. In particular, different figures may emphasize different aspects and may sometimes use different scales.

[0045] As used in this invention, the singular forms “a,” “an,” and “the” include plural objects; the term “or” is generally used to mean “and / or”; the term “a number” is generally used to mean “at least one”; and the term “at least two” is generally used to mean “two or more”. Furthermore, the terms “first,” “second,” and “third” are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Thus, a feature defined as “first,” “second,” or “third” may explicitly or implicitly include one or at least two of that feature. “One end” and “the other end,” as well as “proximal end” and “distal end,” generally refer to two corresponding parts, including not only endpoints. The terms “installed,” “connected,” and “joined” should be interpreted broadly, for example, as a fixed connection, a detachable connection, or an integral part; a mechanical connection or an electrical connection; a direct connection or an indirect connection through an intermediate medium; or a connection within two elements or an interaction between two elements. Furthermore, as used in this invention, the phrase "one element is disposed on another element" generally only indicates that there is a connection, coupling, cooperation, or transmission relationship between the two elements, and the connection, coupling, cooperation, or transmission between the two elements can be direct or indirect through an intermediate element. It should not be construed as indicating or implying a spatial positional relationship between the two elements, i.e., one element can be located arbitrarily inside, outside, above, below, or to one side of the other element, unless otherwise explicitly stated. Those skilled in the art can understand the specific meaning of the above terms in this invention according to the specific circumstances.

[0046] The core idea of ​​this invention is to provide an image enhancement method and a readable storage medium to solve the problem of the lack of suitable image enhancement algorithms in low-light scenes in the prior art.

[0047] The following description refers to the accompanying drawings.

[0048] Please refer to Figure 2 This embodiment provides an image enhancement method, which includes the following steps:

[0049] S10: Specifically includes steps S11 and S12.

[0050] S11: Calculate the average image based on the left and right images in the PD RAW image.

[0051] S12: Determine the number of blocks based on the brightness difference of the average image.

[0052] S20: Based on the number of blocks, divide the left image and the right image into blocks respectively to obtain block images.

[0053] S30: For each of the image blocks, perform histogram statistics and histogram equalization sequentially to obtain the histogram mapping function.

[0054] Furthermore, S40 calculates for each pixel based on the histogram mapping function to obtain the mapping result of the left image and the mapping result of the right image, respectively.

[0055] The final output of the image enhancement method is the mapping result or is calculated based on the mapping result.

[0056] This configuration enhances the image through histogram equalization on the one hand, and compensates for the shortcomings of poor overall enhancement caused by mutual interference between different parts of the image due to histogram equalization of the whole image on the other hand through an adaptive block scheme.

[0057] The above embodiments are used to input the enhancement results of the left and right images into the PDAF algorithm, which can improve the focusing results of the PDAF algorithm. However, based on the same design concept, more extensive enhancement methods can also be designed, such as... Figure 3 The example shown. Figure 3 The illustrated embodiments can also be applied to other similar scenarios that require image enhancement.

[0058] Figure 3 The image enhancement method includes the following steps:

[0059] S10: Determine the number of blocks based on the brightness differences of the input image.

[0060] S20: Based on the number of blocks, the input image is divided into blocks to obtain a block image.

[0061] S30: For each of the image blocks, perform histogram statistics and histogram equalization sequentially to obtain the histogram mapping function.

[0062] And, S40: Calculate the mapping result for each pixel based on the histogram mapping function.

[0063] Among them, step S10 and Figure 2 The steps S11 and S12 correspond to each other.

[0064] In a preferred embodiment, step S10, which determines the number of blocks based on the brightness difference of the input image, includes selecting the number of blocks from a preset set of block numbers, wherein the largest element in the preset set of block numbers is no greater than 8*8, and the smallest element is no less than 4*4. For example, an exemplary preset set of block numbers is {4*4, 4*6, 6*6, 6*8, 8*8}. The form L*W means that the image is divided into L blocks along its length and W blocks along its width, for a total of L*W blocks.

[0065] Since too many block selections do not actually significantly improve the final enhancement effect, after testing, the inventors believe that the preset block number set of {4*4, 8*8} can achieve better results and greatly reduce the computational cost.

[0066] When the preset set of the number of blocks is {4*4, 8*8}, step S12, which determines the number of blocks based on the brightness difference of the average image, includes: dividing the average image into 4*4 brightness calculation images; calculating the brightness information of each brightness calculation image; obtaining the mean square error of the brightness information; and, if the mean square error is higher than a preset threshold, setting the number of blocks to 8*8; otherwise, setting the number of blocks to 4*4. In other words, calculations are first performed using 4*4, and if the condition is not met (the difference is too high), the scheme is changed to 8*8.

[0067] Based on the above embodiments, the following scheme can also be abstracted: Step S12, which determines the number of blocks based on the brightness difference of the average image, includes: dividing the average image into a first number of brightness calculation images; calculating the brightness information of each brightness calculation image; obtaining the root mean square error of the brightness information; and, if the root mean square error is higher than a preset threshold, setting the number of blocks to the first number of blocks; otherwise, setting the number of blocks to a second number of blocks; wherein the second number of blocks is greater than the first number of blocks. That is, in this scheme, there are only two alternative schemes, namely the first number of blocks and the second number of blocks.

[0068] Furthermore, considering that mutually exclusive segmentation methods may lead to abrupt changes at the boundaries of two segmented images, step S20, which involves segmenting the input image into blocks based on the number of blocks to obtain the segmented images, includes: segmenting the input image into blocks based on a preset overlap size, such that adjacent segmented images share common pixels. The overlap size can be a pixel value, a ratio, or a function based on the input image and the number of blocks.

[0069] Please refer to Figure 4 and Figure 5 Each of the image blocks in the figure is filled with a diagonal line in one direction, and the area in the figure that has diagonal lines in two directions is the overlapping area. The pixels in the overlapping area are the common pixels of the adjacent image blocks.

[0070] For example, if an input image is 1024*512 pixels in size, the resulting block image after being divided into two blocks may have a size of 640*512 pixels.

[0071] The steps for histogram statistics include: calculating histograms based on segment points.

[0072] The steps for determining the segmentation points include: obtaining the number of segments N, the maximum slope (slope_max), and the minimum slope (slope_min). These parameters can be obtained through external input or calculated based on preset rules using parameters such as the size of the input image.

[0073] Obtain the cumulative probability distribution function F(x) of the segmented image, where x ranges from 0 to (2^bit_len-1), and bit_len represents the bit length of the container storing the grayscale value of the pixel. For example, generally, one byte is used to store the grayscale value, then bit_len = 8, 2^bit_len-1 = 255, but other possible storage methods are not excluded. Please refer to [reference needed]. Figure 6 , Figure 6 The curve in the figure is the F(x) curve.

[0074] Assign values ​​to x0 and y0 such that y0 = 0 and x0 = 0.

[0075] k takes values ​​from 0 to (N-1) sequentially, and the following steps are performed for each value taken:

[0076] The assignment makes y k+1 = (2^bit_len-1)*k / N, x k+1 =F -1 (y k+1 / (2^bit_len-1)), where F -1 (x) represents the inverse function of F(x). For ease of understanding, let's label y at this point. k+1 The value is y k+1 (1), x k+1 The value is x k+1 (1). In Figure 6 In, (x k+1 y k+1 The point represented by ) is point B. In fact, Figure 6 In the diagram, the vertical axis represents the value y / (2^bit_len-1), but for ease of description, point B can be considered to represent (x... k+1 yk+1 This approach can be used to understand other points in the subsequent content.

[0077] Calculate m k =(y k+1 -y k ) / (x k+1 -x k For ease of understanding, let's label m at this point. k The value is m k (1). Figure 6 In, (x k y k The point represented by ) is point A, and m k (1) is the slope of line segment AB.

[0078] If m k If the slope is less than the minimum slope, then for m... k Reassigning the value to m k =slope_min; if m k >slope_max, then for m k Reassigning the value to m k =slope_max. In Figure 6 In the example shown, the slope of line segment AC is slope_max, therefore, m at this time k >slope_max, depending on the setting, m k =slope_max, for ease of understanding, let's label m at this point. k The value is m k (2). m k (2) = slope_max = the slope of line segment AC.

[0079] If neither of the above two conditions is met, then m k Keep the original value; and, if m k If it is reassigned, then for y k+1 Reassigning the value makes y k+1 =y k +m k (x k+1 -x k ), and re-accord according to x k+1 =F -1 (y k+1 Calculate x using / (2^bit_len-1) k+1 .exist Figure 6 middle, y k+1 Recalculated, new y k+1 =y k+1 (2), at this time, (x) k+1 y k+1The point represented by ) is point C, and then it is recalculated according to x. k+1 =F -1 (y k+1 Calculate x using / (2^bit_len-1) k+1 After the calculation, x k+1 =x k+1 (2), at this time, (x) k+1 y k+1 The point represented by ) is point D.

[0080] m k The case of <slope_min can also be analyzed using the process described above.

[0081] x corresponding to all values ​​of k k+1 After the calculation is complete, x0~x N Set as the segment point.

[0082] After obtaining the histogram based on the segmented points, histogram equalization is performed. The specific process of histogram equalization can be understood by referring to common knowledge in this field. After histogram equalization, a mapping function G(r) is obtained, which is called the histogram mapping function. By inputting each pixel into this function, the grayscale value of the equalized pixel can be obtained. The grayscale values ​​of pixels in the overlapping region are calculated according to the interpolation method described above.

[0083] Meanwhile, the final mapping calculation needs further clarification. Specifically, step S40, which calculates the mapping result for each pixel based on the histogram mapping function, includes: for pixels belonging to only one image block, calculating the mapped grayscale value based on their corresponding histogram mapping function; for pixels belonging to at least two image blocks, calculating the mapped grayscale value based on at least two corresponding histogram mapping functions and their positions in at least two image blocks using interpolation.

[0084] The step of calculating the mapped grayscale value of a pixel belonging to at least two of the said block images based on its corresponding at least two said histogram mapping functions and its position in at least two said block images includes:

[0085] When the pixel belongs to two of the image blocks, it is calculated according to the following formula: S p =wGa(r p )+(1-w)Gb(r p ), where w=a / (a+b);

[0086] When the pixel belongs to one of the four image blocks, it is calculated according to the following formula: S p =w1w2Ga(rp )+(1-w1)w2Gb(r p )+w1(1-w2)Gc(r p )+(1-w1)(1-w2)Gd(r p ), where w1=a / (a+b), w2=c / (c+d).

[0087] Among them, S p r represents the mapped grayscale value. p This represents the pixel.

[0088] Please combine Figure 4 and Figure 5 Ga(r) represents the histogram mapping function of the first block image 3 to which the pixel belongs, Gb(r) represents the histogram mapping function of the second block image 4 to which the pixel belongs, Gc(r) represents the histogram mapping function of the third block image 5 to which the pixel belongs, and Gd(r) represents the histogram mapping function of the fourth block image 6 to which the pixel belongs.

[0089] a represents the distance of pixel 7 from the edge of the first segmented image 3 along the direction pointing to the second segmented image 4; b represents the distance of pixel 7 from the edge of the second segmented image 4 along the direction pointing to the first segmented image 3; c represents the distance of pixel 7 from the edge of the first segmented image 3 along the direction pointing to the third segmented image 5; and d represents the distance of pixel 7 from the edge of the third segmented image 5 along the direction pointing to the first segmented image 3. Figure 4 and Figure 5 The measurement methods for a, b, c, and d are shown. It should be understood that the relative positions of the first segmented image 3, the second segmented image 4, the third segmented image 5, and the fourth segmented image 6 are top left, top right, bottom left, and bottom right, respectively.

[0090] The Ga(r), Gb(r), Gc(r) and Gd(r) mentioned above are obtained based on histogram equalization calculation.

[0091] After step S40, the mapping result can be output as the final result. However, in a preferred embodiment, the image enhancement method further includes the following steps:

[0092] The mapped image blocks are then stitched together to obtain the enhanced result. This stitching and fusion further eliminates edge differences between the image blocks, resulting in a more natural enhancement. The stitching and fusion targets the overlapping areas of the image blocks.

[0093] The term "image stitching and fusion" refers to obtaining a weighted average image by weighting the overlapping areas of an image according to distance, thereby reducing the segmentation effect. Because the segmented images will differ after segmentation, an interpolation and stitching / fusion process is designed to minimize this effect.

[0094] Based on the above method, the PD RAW image is enhanced, and the enhanced effect is as follows. Figures 7a-7c As shown. The left image is the image before enhancement (can be interpreted as either the left or right image), and the right image is the image after enhancement. From... Figures 7a-7c As can be seen, the enhanced image is clearer from the perspective of naked-eye observation.

[0095] To further confirm the effectiveness of the method in this embodiment, for Figure 8a and Figure 8b The PD RAW image shown was subjected to PDAF calculation, and the results before and after enhancement were calculated respectively. Figure 8a and Figure 8b The box in the diagram represents the input window, i.e., the effective focus travel. The calculation results are as follows: Figure 9a and Figure 9b As shown.

[0096] Figure 9a In the diagram, curve 11 represents the PD output before enhancement, and curve 21 represents the confidence value corresponding to the PD output before enhancement; curve 12 represents the PD output after enhancement, and curve 22 represents the confidence value corresponding to the PD output after enhancement. From the confidence values, it can be seen that the two methods are quite similar. From the PD output, it can be seen that the straightness of the enhanced PD output is higher, especially in the area marked by the dashed line. The calculated straightness of curve 11 is 0.991834, and the straightness of curve 12 is 0.994042. The calculation results also show that curve 12 has higher straightness. Therefore, the enhanced image is more conducive to phase-detection autofocus.

[0097] Figure 9b In the diagram, the meanings of curves 11, 12, 21, and 22 are... Figure 9a Same. From Figure 9b It can also be seen that curve 12 performs better, especially in the area marked by the dashed line. The straightness of curve 11 is calculated to be 0.994005, while that of curve 12 is 0.994407. The calculation results also show that curve 12 has higher straightness. Therefore, the enhanced image is more conducive to phase-detection autofocus.

[0098] This embodiment also provides a readable storage medium storing a program that, when executed, performs the image enhancement method described above. Therefore, the readable storage medium can also enhance images, solving the problems existing in the prior art.

[0099] In summary, this embodiment provides an image enhancement method and a readable storage medium. The image enhancement method includes the following steps: determining the number of blocks based on the brightness differences of the input image; dividing the input image into blocks based on the number of blocks to obtain block images; performing histogram statistics and histogram equalization sequentially on each block image to obtain a histogram mapping function; and calculating the enhancement result for each pixel based on the histogram mapping function. This configuration enhances the image through histogram equalization while mitigating the overall poor enhancement effect caused by mutual interference between different parts of the image due to histogram equalization of the entire image via an adaptive block division scheme. The above solution addresses the problem of the lack of suitable image enhancement algorithms in low-light scenes in existing technologies.

[0100] The above description is only a description of preferred embodiments of the present invention and is not intended to limit the scope of the present invention in any way. Any changes or modifications made by those skilled in the art based on the above disclosure shall fall within the protection scope of the present invention.

Claims

1. An image enhancement method characterized by, The image enhancement method comprises the following steps: determining the number of blocks based on the brightness difference of the input image; blocking the input image based on the number of blocks to obtain a blocked image; for each block of the blocked image, sequentially performing histogram statistics and histogram equalization to obtain a histogram mapping function; and calculating each pixel based on the histogram mapping function to obtain a mapping result; The final output result of the image enhancement method is the mapping result or a result calculated based on the mapping result; The input image is the left image and the right image in the PD RAW image; The image enhancement method comprises the following steps: obtaining an average image based on the left image and the right image; determining the number of blocks based on the brightness difference of the average image; blocking the left image and the right image respectively based on the number of blocks to obtain the blocked image; for each block of the blocked image, sequentially performing histogram statistics and histogram equalization to obtain a histogram mapping function; and calculating each pixel based on the histogram mapping function to obtain the mapping result of the left image and the mapping result of the right image respectively; The image enhancement method is used to input the enhancement results of the left image and the right image to the PDAF algorithm to improve the focusing result of the PDAF algorithm; The step of histogram statistics includes: based on the segmentation point, the histogram is counted; The step of determining the segmentation point comprises: obtaining the number of segments N, the maximum slope slope_max and the minimum slope slope_min; obtaining the cumulative probability distribution function F(x) of the blocked image, wherein the value range of x is 0~(2^bit_len-1), and bit_len represents the bit length of the container for storing the gray value of the pixel; x0 and y0 are assigned values, so that y0=0 and x0=0; k takes values from 0 to (N-1) in turn, and at each value, the following steps are performed: The assignment is such that y k+1 = (2^bit_len - 1) * k / N, x k+1 = F -1 (y k+1 / (2^bit_len - 1)), where F -1 (x) represents the inverse function of F(x); Compute m k = (y k+1 - y k ) / (x k+1 - x k ); if m k < slope_min, then m k is re-assigned such that m k = slope_min; if m k > slope_max, then m k is re-assigned such that m k = slope_max; if neither of the above two conditions is met, then m k remains unchanged; and If m k is re-assigned, then y k+1 is re-assigned such that y k+1 = y k + m k (x k+1 - x k ) and x k+1 is recalculated as x -1 = F k+1 (y k+1 / (2^bit_len-1)); all values of k k+1 After the calculation, x0~x N is set as the segmentation point.

2. The image enhancement method of claim 1, wherein, The step of determining the number of blocks based on the brightness difference of the input image comprises: selecting the number of blocks from a preset set of block numbers, wherein the largest element in the preset set of block numbers is not greater than 8*8, and the smallest element is not less than 4*4.

3. The image enhancement method of claim 1, wherein, The step of determining the number of blocks based on the brightness difference of the average image comprises: dividing the average image into a first number of brightness calculation images; calculating the brightness information of each block of the brightness calculation image; obtaining the mean square deviation of the brightness information; and if the mean square deviation is higher than a preset threshold, the number of blocks is set to a second number of blocks; otherwise, the number of blocks is set to the first number of blocks; wherein the second number of blocks is greater than the first number of blocks.

4. The image enhancement method of claim 1, wherein, The step of blocking the input image based on the number of blocks to obtain the blocked image comprises: blocking the input image based on a preset overlap size, so that adjacent blocked images have common pixels; The step of calculating each pixel based on the histogram mapping function to obtain a mapping result comprises: only from the pixels belonging to one of the sub-images, the mapped gray value is calculated based on the corresponding histogram mapping function; from the pixels belonging to at least two of the sub-images, the mapped gray value is calculated based on the corresponding at least two histogram mapping functions and the position interpolation of the pixels in the at least two sub-images.

5. The image enhancement method of claim 4, wherein, The image enhancement method further comprises the following steps: The mapped sub-images are spliced and fused to obtain an enhancement result.

6. The image enhancement method of claim 4, wherein, The step of calculating the mapped gray value from the pixels belonging to at least two of the sub-images based on the corresponding at least two histogram mapping functions and the position interpolation of the pixels in the at least two sub-images comprises: When the pixel belongs to two of the sub-images, the following formula is used for calculation: S p = wGa(r p ) + (1 - w)Gb(r p ), where w = a / (a+b). When the pixel belongs to four of the sub-images, the following formula is used for calculation: S p = w1w2Ga(r p ) + (1 - w1)w2Gb(r p ) + w1(1 - w2)Gc(r p ) + (1 - w1)(1 - w2)Gd(r p ), where w1 = a / (a+b), w2 = c / (c+d). wherein S p represents the mapped gray value, r p represents the pixel, Ga(r) represents a histogram mapping function of a first of the block images to which the pixel belongs, Gb(r) represents a histogram mapping function of a second of the block images to which the pixel belongs, Gc(r) represents a histogram mapping function of a third of the block images to which the pixel belongs, Gd(r) represents a histogram mapping function of a fourth of the block images to which the pixel belongs, a represents a distance of the pixel from an edge of the first of the block images in a direction pointing to the second of the block images, b represents a distance of the pixel from an edge of the second of the block images in a direction pointing to the first of the block images, c represents a distance of the pixel from an edge of the first of the block images in a direction pointing to the third of the block images, and d represents a distance of the pixel from an edge of the third of the block images in a direction pointing to the first of the block images.

7. A readable storage medium characterized by, The readable storage medium has a program stored thereon, and the program, when executed, performs the image enhancement method according to any one of claims 1-6.

Citation Information

Patent Citations

  • Histogram equalization based image enhancement method and device

    CN101706953A

  • Contrast enhancement method, device and equipment

    CN114140348A