Image processing method, processor, and non-transitory computer-readable storage medium
By block processing of the image data, calculating the average brightness value and pixel proportion value, calculating the weight value and weighted average, the problem of image overexposure is solved and the image is better visibility is achieved.
Patent Information
- Application Number
- CN202111147439.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-09-28
- Publication Date
- 2025-04-29
- Estimated Expiration
- 2041-09-28
AI Technical Summary
In scenes with high contrast, images are prone to overexposed, which makes it impossible for users to clearly see the content in the image.
By dividing the image data into multiple blocks, the average brightness value and pixel proportion value of each block are calculated, the weight value of the block is calculated based on these values, and the adjusted brightness value is calculated by weighting average, and the automatic exposure program is finally executed to generate the final image data.
Effectively prevent image overexposure, improve image visibility, and make the image clearer by adjusting exposure time and gain.
Smart Images

Figure CN115883983B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to an image processing technology, and in particular to an image processing method capable of preventing image overexposure. Background Art
[0002] With the development of technology, many electronic devices are equipped with image capture devices (such as cameras). However, in some scenes with high contrast, the image is easily overexposed, causing users to be unable to clearly see the content in the image. Summary of the invention
[0003] Some embodiments of the present disclosure are related to an image processing method. The image processing method is executed by a processor. The image processing method includes the following operations: generating an average brightness value for each of a plurality of blocks in image data; generating a pixel ratio value based on the image data, wherein the pixel ratio value is a ratio of a first pixel number to a second pixel number, the second pixel number is the number of a plurality of pixels, and the first pixel number is the number of pixels among these pixels that exceed a brightness threshold; generating a weight value for each of these blocks based on the pixel ratio value, a first brightness weight, and a second brightness weight; generating an adjusted brightness value for the image data based on the average brightness value and the weight value of these blocks; and performing an automatic exposure procedure based on the adjusted brightness value to generate final image data. The final image data is used for display on a display.
[0004] Some embodiments of the present disclosure are related to a processor. The processor is used to generate an average brightness value for each of a plurality of blocks in image data, generate a pixel ratio value based on the image data, generate a weight value for each of these blocks according to the pixel ratio value, a first brightness weight, and a second brightness weight, generate an adjusted brightness value for the image data according to the average brightness value and the weight value of these blocks, and execute an automatic exposure procedure according to the adjusted brightness value to generate final image data. The final image data is used for display on a display. The pixel ratio value is a ratio of a first pixel number to a second pixel number, the second pixel number is the number of a plurality of pixels, and the first pixel number is the number of pixels among these pixels that exceed a brightness threshold.
[0005] Some embodiments of the present disclosure are related to a non-transitory computer-readable storage medium. The non-transitory computer-readable storage medium is used to store one or more computer programs containing multiple instructions. When the processor executes these instructions, the processor performs the following operations: generating an average brightness value for each of multiple blocks in the image data; generating a pixel ratio value based on the image data, wherein the pixel ratio value is a ratio of a first pixel number to a second pixel number, the second pixel number is the number of multiple pixels, and the first pixel number is the number of pixels among these pixels that exceed a brightness threshold; generating a weight value for each of these blocks based on the pixel ratio value, the first brightness weight, and the second brightness weight; generating an adjusted brightness value for the image data based on the average brightness value and the weight value of these blocks; and performing an automatic exposure procedure based on the adjusted brightness value to generate final image data. The final image data is used for display on a display. BRIEF DESCRIPTION OF THE DRAWINGS
[0006] In order to make the above and other purposes, features, advantages and embodiments of the present disclosure more clearly understood, the accompanying drawings are described as follows:
[0007] Figure 1 is a schematic diagram of an electronic device according to some embodiments of the present disclosure;
[0008] Figure 2 is a flowchart of an image processing method according to some embodiments of the present disclosure;
[0009] Figure 3 is a flowchart of an image processing method according to some embodiments of the present disclosure; and
[0010] Figure 4 is a diagram showing the relationship between weight ratio values and pixel ratio values according to some embodiments of the present disclosure. DETAILED DESCRIPTION
[0011] As used herein, the term “coupled” may also refer to “electrically coupled”, and the term “connected” may also refer to “electrically connected.” “Coupled” and “connected” may also refer to two or more components cooperating or interacting with each other.
[0012] refer to Figure 1 . Figure 1 is a schematic diagram of an electronic device 100 according to some embodiments of the present disclosure.
[0013] by Figure 1 For example, the electronic device 100 includes a memory 110 , a processor 120 , and a display 130 . The processor 120 is coupled to the memory 110 and the display 130 .
[0014] In some embodiments, the memory 110 can be implemented using a non-transient computer-readable storage medium, such as a read-only memory, a flash memory, a floppy disk, a hard disk, an optical disk, a flash disk, a flash drive, a magnetic tape, a database readable from a network, or any storage medium with the same function that a person of ordinary skill in the art to which the present disclosure belongs can think of. The memory 110 is used to store one or more computer programs CP containing multiple instructions. In some embodiments, the processor 120 can be implemented using a central processor or a microprocessor. In some embodiments, the display 130 can be implemented using a display panel, a touch display panel, or other various display devices.
[0015] refer to Figure 1 as well as Figure 2 . Figure 2 is a flowchart of an image processing method 200 according to some embodiments of the present disclosure. In some embodiments, the image processing method 200 is applied to Figure 1 The electronic device 100 is provided, but the present disclosure is not limited thereto. Figure 1 Have a discussion.
[0016] In some embodiments, when the computer program CP in the memory 110 is executed by the processor 120, a computer or other electronic device, the image processing method 200 is executed. Figure 2 For example, the image processing method 200 includes operation S210 , operation S220 , operation S230 , operation S240 , and operation S250 .
[0017] In operation S210, the processor 120 generates an average brightness value for each of a plurality of blocks in the image data MD. In some embodiments, the image data MD may come from a camera or from the memory 110. The processor 120 may divide the image data MD into N×N or N×M blocks, where N or M is a positive integer equal to or greater than 1. The processor 120 may perform sampling for each block. For example, each block may include a plurality of pixels, and each pixel may have a brightness value. The processor 120 may sample K sampled pixels from the pixels in the block, and generate the average brightness value of the block according to the following formula (1):
[0018]
[0019] Where K is the number of sampled pixels in this block, y j are the brightness values of these sampled pixels, y nmean[i] The average brightness value of this block. On the other hand, the processor 120 can sort the average brightness values of these blocks (for example, from small to large). i is the index value of these blocks. When the average brightness value of the block is larger, the value of i is larger. Conversely, when the average brightness value of the block is smaller, the value of i is smaller.
[0020] The processor 120 applies the above principle to all blocks to generate average brightness values of all blocks.
[0021] When the number of sampled pixels is smaller, the processor 120 can operate faster. When the number of sampled pixels is larger, the subsequent operation result will be more accurate. In some embodiments, operation S210 can be performed without sampling. That is, all pixels in each block are used to generate the average brightness value of the block.
[0022] In operation S220, the processor 120 generates a pixel ratio value based on the image data MD. In some embodiments, the processor 120 may sample some pixels from the entire image data MD. It should be noted that the sampling operation of operation S220 is independent of the sampling operation of S210. Then, the brightness values of the sampled pixels are sorted using a histogram program. In some embodiments, the processor 120 may generate a pixel ratio value according to the following formula (2):
[0023]
[0024] in is the number of pixels sampled from the entire image data MD, is the number of pixels whose brightness value exceeds the brightness threshold among these sampled pixels, and SR is the pixel ratio value. The brightness threshold can be designed according to the actual application.
[0025] When the pixel ratio value is higher, it means that there are more pixels with higher brightness in the image data MD. On the contrary, when the pixel ratio value is lower, it means that there are fewer pixels with higher brightness in the image data MD.
[0026] Similarly, when the number of sampled pixels is smaller, the processor 120 can operate faster. When the number of sampled pixels is larger, the subsequent operation result will be more accurate. In some embodiments, operation S220 can be performed without sampling. That is, all pixels in the entire image data MD are used to generate pixel ratio values.
[0027] In operation S230, the processor 120 generates a weight value for each block according to the pixel ratio value, the low brightness weight, and the high brightness weight generated in operation S220. In some embodiments, the processor 120 may generate a weight value for each block according to the following formula (3):
[0028] weight[i]=(1-SR)×weight_low[i]+SR×weight_high[i]…Formula (3)
[0029] Wherein SR is the pixel ratio value generated in operation S220, i is the index value of the block (as mentioned above, the larger the i, the larger the average brightness value of the block), weight_low[i] is the low brightness weight of the block, weight_high[i] is the high brightness weight of the block, and weight[i] is the weight value of the block.
[0030] The low brightness weight weight_low[i] and high brightness weight weight_high[i] of each block can be designed according to the actual application. In some embodiments, when the average brightness value of a block is greater than the average brightness value of another block, the high brightness weight weight_high[i] of this block can be greater than the high brightness weight weight_high[i] of another block, and the low brightness weight weight_low[i] of each block can be the same. In some other embodiments, the low brightness weight weight_low[i] of each block can also be designed to be different.
[0031] In operation S240, the processor 120 generates an adjusted brightness value of the image data MD according to the average brightness values of the blocks and the weight values. In some embodiments, the processor 120 may generate the adjusted brightness value of the image data MD according to the following formula (4) and using a weighted average procedure;
[0032]
[0033] in is the sum of the weight values of all blocks, is the sum of the products of the brightness values and weight values of all blocks, and Y mean is the adjusted brightness value of the entire image data MD.
[0034] Based on the above formula (4), the adjusted brightness value will be greater than the average brightness value of the original image data MD.
[0035] Next, in operation S250, the processor 120 performs an automatic exposure procedure according to the adjusted brightness value to generate final image data. In some embodiments, the processor 120 may pre-set a target brightness value according to the actual application. As described above, the adjusted brightness value is greater than the average brightness value of the original image data MD. When the adjusted brightness value is greater than the preset target brightness value, the automatic exposure procedure reduces the brightness value of the entire image data MD according to the target brightness value to generate the final image data. The final image data is used for display by the display 130. Since the automatic exposure procedure reduces the brightness value of the entire image data MD, the exposure time and gain of the image sensor can be shortened to darken the originally overexposed image, thereby improving the overexposure problem.
[0036] In some related technologies, when the contrast of image data is too high, brighter areas are prone to overexposure, causing users to be unable to clearly view the content in the image.
[0037] Compared to the above-mentioned related technologies, in the present disclosure, the weight value of each block can be generated according to the pixel ratio value, the low brightness weight and the high brightness weight, and then the average brightness value and the weight value of each block are used for weighted averaging to generate the adjusted brightness value of the image data. Accordingly, the adjusted brightness value will be greater than the average brightness value of the original image data. Then, the automatic exposure procedure is performed on the adjusted brightness value, which can shorten the exposure time and gain of the image sensor, darken the overexposed image, and thus improve the visibility of the image.
[0038] refer to Figure 1 as well as Figure 3 . Figure 3 is a flowchart of an image processing method 300 according to some embodiments of the present disclosure. In some embodiments, the image processing method 300 is applied to Figure 1 The electronic device 100 is provided, but the present disclosure is not limited thereto. Figure 1 Have a discussion.
[0039] In some embodiments, when the computer program CP in the memory 110 is executed by the processor 120, a computer or other electronic device, the image processing method 300 is executed. Figure 3 For example, the image processing method 300 includes operation S310 , operation S320 , operation S332 , operation S334 , operation S340 , and operation S350 .
[0040] Operation S310, operation S320, operation S340, and operation S350 of the image processing method 300 are similar to operation S210, operation S220, operation S240, and operation S250 of the image processing method 200, respectively. Figure 2 The image processing method 200, Figure 3 The image processing method 300 further includes operation S332 and operation S334.
[0041] In operation S332, the processor 120 may perform the following operations according to operation S320 (similar to operation S332). Figure 2 The pixel ratio value generated in operation S220) further generates a weight ratio value.
[0042] refer to Figure 4 . Figure 4 is a diagram showing the relationship between weight ratio values and pixel ratio values according to some embodiments of the present disclosure.
[0043] exist Figure 4 In the example of , the relationship between the weight ratio value and the pixel ratio value is a linear function curve. Specifically, when the pixel ratio value is in range A and range C, the relationship between the weight ratio value and the pixel ratio value is a slanted straight line with a first slope. When the pixel ratio value is in range B, the relationship between the weight ratio value and the pixel ratio value is a slanted straight line with a second slope, wherein the second slope is different from (in Figure 4 Example: less than) the first slope.
[0044] However, this disclosure does not Figure 4 The relationship between the weight ratio value and the pixel ratio value can be designed according to the actual application. In other words, various suitable relationships are within the scope of the present disclosure.
[0045] like Figure 4 As shown, the pixel ratio value may correspond to the weight ratio value. Accordingly, the processor 120 may calculate the pixel ratio value and the weight ratio value according to the pixel ratio value and the weight ratio value. Figure 4 The relationship in produces a weighted proportional value.
[0046] Reference again Figure 3 In operation S334, the processor 120 may generate a weight value for each block according to the weight ratio value, the low brightness weight, and the high brightness weight generated in operation S332. In some embodiments, the processor 120 may generate a weight value for each block according to the following formula (5):
[0047] weight[i]=(1-WR)×weight_low[i]+WR×weight_high[i]…Formula (5)
[0048] Where WR is the weight ratio value generated in operation S323, i is the index value of the block (as mentioned above, the larger the i, the larger the average brightness value of the block), weight_low[i] is the low brightness weight of the block, weight _high[i] is the high brightness weight of the block, and weight[i] is the weight value of the block.
[0049] After the processor 120 generates weight values for all blocks according to the above formula (5), the processor 120 may continue to perform operation S340 (similar to Figure 2 Operation S240) and operation S350 (similar to Figure 2 Operation S250) is performed to generate final image data, thereby improving the overexposure problem.
[0050] Compared to Figure 2 In the image processing method 200, due to Figure 3 The image processing method 300 in the embodiment can further design the relationship between the weight ratio value and the pixel ratio value according to the actual application, so the design is more flexible and can be applied in more scenarios.
[0051] In summary, the image processing method, processor, and non-transient computer-readable storage medium disclosed herein can effectively prevent image overexposure to improve image visibility.
[0052] Although the present disclosure has been disclosed in the implementation mode as above, this is not intended to limit the present disclosure. Any ordinary technician in the field can make various changes and modifications without departing from the spirit and scope of the present disclosure. Therefore, the scope of protection of the present disclosure should be based on the scope defined by the attached claims.
[0053]
Explanation of symbols
[0054] 100: Electronic devices
[0055] 110: Memory
[0056] 120: Processor
[0057] 130: Display
[0058] 200, 300: Image processing methods
[0059] CP: Computer Program
[0060] MD: Image Data
[0061] A, B, C: Range
[0062] S210, S220, S230, S240, S250, S310, S320, S332, S334, S340, S350: operation.
Claims
1. An image processing method, executed by a processor, comprising: generating an average brightness value for each of a plurality of blocks in the image data; Generating a pixel ratio value based on the image data, wherein the pixel ratio value is a ratio of a first pixel number to a second pixel number, the second pixel number is the number of a plurality of pixels, and the first pixel number is the number of pixels among the pixels that exceed a brightness threshold; generating a weight value of each of the blocks according to the pixel ratio value, the first brightness weight and the second brightness weight; generating an adjusted brightness value of the image data according to the average brightness value of the blocks and the weight value; as well as Execute an automatic exposure procedure according to the adjusted brightness value to generate final image data, The final image data is used for displaying on a display. The weight value of the corresponding block in these blocks is obtained according to the following formula: weight[i]=(1-SR)×weight_low[i]+SR×weight_high[i] Wherein SR is the pixel ratio value, weight_low[i] is the first brightness weight of the corresponding block, weight_high[i] is the second brightness weight of the corresponding block, and weight[i] is the weight value of the corresponding block.
2. The image processing method as claimed in claim 1, wherein the average brightness value of the corresponding block in the blocks is obtained according to the following formula: Where K is the number of sampled pixels in the corresponding block, y j is the brightness value of the corresponding sampled pixel in these sampled pixels, y mean [i] is the average brightness value of the corresponding block, i is an index value and corresponds to the corresponding block.
3. The image processing method as described in claim 1, wherein the blocks include a first block and a second block, wherein when the average brightness value of the second block is greater than the average brightness value of the first block, the second brightness weight of the second block is greater than the second brightness weight of the first block, and wherein the first brightness weight of the second block is equal to the first brightness weight of the first block.
4. The image processing method as claimed in claim 1, wherein the operation of generating the weight value of each of the blocks according to the pixel ratio value, the first brightness weight and the second brightness weight comprises: generating a weight ratio value according to the pixel ratio value; and The weight value of each of the blocks is generated according to the weight ratio value, the first brightness weight, and the second brightness weight.
5. The image processing method as claimed in claim 4, wherein the weight value of the corresponding block in the blocks is obtained according to the following formula: weight[i]=(1-WR)×weight_low[i]+WR×weight_high[i] Wherein WR is the weight ratio value, weight_low[i] is the first brightness weight of the corresponding block, weight_high[i] is the second brightness weight of the corresponding block, and weight[i] is the weight value of the corresponding block.
6. The image processing method as described in claim 5, wherein the blocks include a first block and a second block, wherein when the average brightness value of the second block is greater than the average brightness value of the first block, the second brightness weight of the second block is greater than the second brightness weight of the first block, and wherein the first brightness weight of the second block is equal to the first brightness weight of the first block. 7 . The image processing method as claimed in claim 1 , wherein the adjusted brightness value is greater than an average brightness value of the image data.
8. A processor, wherein when executing one or more computer programs comprising a plurality of instructions, the processor is used to: generate an average brightness value for each of a plurality of blocks in image data, generate a pixel ratio value based on the image data, generate a weight value for each of the blocks according to the pixel ratio value, a first brightness weight, and a second brightness weight, generate an adjusted brightness value for the image data according to the average brightness value of the blocks and the weight value, and execute an automatic exposure procedure according to the adjusted brightness value to generate final image data, wherein the final image data is used for display on a display, The pixel ratio value is a ratio of a first pixel number to a second pixel number, the second pixel number is the number of a plurality of pixels, and the first pixel number is the number of pixels exceeding a brightness threshold among the pixels, The weight value of the corresponding block in these blocks is obtained according to the following formula: weight[i]=(1-SR)×weight_low[i]+SR×weight_high[i] Wherein SR is the pixel ratio value, weight_low[i] is the first brightness weight of the corresponding block, weight_high[i] is the second brightness weight of the corresponding block, and weight[i] is the weight value of the corresponding block.
9. A non-transitory computer-readable storage medium storing one or more computer programs comprising a plurality of instructions which, when executed by a processor, cause the processor to: generating an average brightness value for each of a plurality of blocks in the image data; Generating a pixel ratio value based on the image data, wherein the pixel ratio value is a ratio of a first pixel number to a second pixel number, the second pixel number is the number of a plurality of pixels, and the first pixel number is the number of pixels among the pixels that exceed a brightness threshold; generating a weight value of each of the blocks according to the pixel ratio value, the first brightness weight and the second brightness weight; generating an adjusted brightness value of the image data according to the average brightness value of the blocks and the weight value; as well as Execute an automatic exposure procedure according to the adjusted brightness value to generate final image data, The final image data is used for displaying on a display. The weight value of the corresponding block in these blocks is obtained according to the following formula: weight[i]=(1-SR)×weight_low[i]+SR×weight_high[i] Wherein SR is the pixel ratio value, weight_low[i] is the first brightness weight of the corresponding block, weight_high[i] is the second brightness weight of the corresponding block, and weight[i] is the weight value of the corresponding block.
Citation Information
Patent Citations
Image processing device
CN101494725A
Local enhancement apparatus, multiple exposure image system and local enhancement method
CN105323493A