Automatic exposure control method based on FPGA to realize image entropy value

By implementing image entropy value automatic exposure control on FPGA, using entropy value sorting and exposure time adjustment, the problem of poor exposure of the area of ​​interest in the image is solved, and the image exposure effect and memory utilization are significantly improved.

CN115767281BActive Publication Date: 2024-09-03CHANGCHUN UP OPTOTECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202211402448.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-11-09
Publication Date
2024-09-03
Estimated Expiration
2042-11-09

AI Technical Summary

Technical Problem

It is difficult to accurately identify and optimize the exposure of the area of ​​interest in the image with existing technology, resulting in poor image exposure.

Method used

By implementing the automatic exposure control method of image entropy value on FPGA, Verilog programming is used to sort the image by entropy value, identify the area of ​​interest, and adjust the exposure time according to the entropy value calculation formula to improve the image exposure effect.

Benefits of technology

It greatly improves the image exposure effect, simplifies the negative sorting operation of FPGA, improves the utilization of random access memory, reduces the computational complexity, and significantly improves the exposure quality of the area of ​​interest.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115767281B
    Figure CN115767281B
Patent Text Reader

Abstract

The present invention provides an automatic exposure control method for realizing image entropy value based on FPGA, which mainly uses Verilog in FPGA to realize the sorting of image entropy value, and accurately obtains the region of interest of the whole image under complex background, and specifically includes the following steps: S1, dividing the original image into multiple small images; S2, simplifying the entropy value calculation formula; S3, using FPGA to sort the entropy values ​​of the selected small images; S4, drawing the grayscale histogram of the selected small images; S5, obtaining the reference grayscale value according to the grayscale histogram, and performing automatic exposure according to the size relationship between the reference grayscale value and the set brightness threshold. The present invention realizes automatic exposure control of image entropy value by using FPGA, which greatly improves the exposure effect of the picture; in the process of entropy value sorting, absolute value sorting is adopted to avoid the tedious operation of FPGA sorting negative numbers; ping-pong operation is adopted for pixel statistics, which improves the utilization rate of random access memory; the definition of the same type of grayscale value reduces the tediousness of operation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of image exposure, and specifically provides an automatic exposure control method for realizing image entropy value based on FPGA. Background Art

[0002] According to the characteristics of the human visual system, human vision usually strives to maximize the information obtained from images. Based on this visual characteristic, the high-complexity area containing rich gray levels in the visual image is the main body of the image, that is, the area of ​​interest; and the low-complexity area containing a small amount of gray levels is the area of ​​no interest. In fact, the accurate exposure of the image is the accurate exposure of the area of ​​interest in the image. How to improve the accurate exposure of the area of ​​interest in the image has become an important research direction. Summary of the invention

[0003] In order to solve the above problems, the present invention provides an automatic exposure control method for image entropy values ​​based on FPGA, which mainly uses Verilog in FPGA to sort the image entropy values, and accurately obtains the area of ​​interest of the entire image under complex backgrounds.

[0004] The automatic exposure control method for realizing image entropy value based on FPGA provided by the present invention comprises the following steps:

[0005] S1, set the resolution to , the original image with data width n is divided into , a small image with a data width of n;

[0006] S2. Determine the final entropy value calculation formula. The specific process is as follows:

[0007] Set the grayscale of the thumbnail to 2 n , i Represents the gray value, i= 0, 1, 2, …, 2 n -1, x i Indicates the gray value is i The number of pixels;

[0008] Define a number of adjacent grayscale values ​​as the same type of grayscale value. The sum of the pixels corresponding to the a number of adjacent grayscale values ​​is equal to the number of pixels of the same type of grayscale value. a is a positive integer. The probability of occurrence of the same type of grayscale value in the small image is The calculation formula is as follows:

[0009] (1);

[0010] The entropy calculation formula is as follows:

[0011] (2);

[0012] Among them, H represents the entropy value;

[0013] Substituting formula (2) into formula (1), we get:

[0014] (3);

[0015] Simplify formula (3) to obtain the final entropy value calculation formula:

[0016] (4);

[0017] S3, calculated according to formula (4) The entropy value of a small graph is realized by using FPGA The entropy values ​​of the small images are sorted, and the w small images with the largest entropy values ​​are calibrated as the regions of interest, where the value range of w is 5%~50% of the number of small images, and w is an integer;

[0018] S4, draw a grayscale histogram of the same type of grayscale value and the corresponding number of pixels in w small images;

[0019] S5. Obtain a reference grayscale value according to the grayscale histogram, and determine the relationship between the reference grayscale value and the set brightness threshold:

[0020] If the reference grayscale value is greater than or equal to the brightness threshold, reduce the exposure time of the pixel whose grayscale value is greater than the brightness threshold;

[0021] If the reference grayscale value is less than the brightness threshold, the exposure time of the pixels whose grayscale values ​​are greater than the reference grayscale value is increased.

[0022] Preferably, in S2, the value of a is 2, 4 or 8, that is, 2, 4 or 8 adjacent grayscale values ​​are defined as the same type of grayscale values.

[0023] Preferably, in S3, The entropy values ​​of the small graphs are sorted from large to small.

[0024] Preferably, FPGA is used to implement The process of sorting the entropy values ​​of the small graphs from large to small is as follows:

[0025] The entropy value calculated by formula (4) Take the absolute value, apply for an array in the FPGA, and use a For loop to The absolute values ​​of are stored in the array in ascending order. The entropy values ​​of the small graphs are sorted from large to small.

[0026] Preferably, when drawing the grayscale histogram, a ping-pong operation is used to count the number of pixels corresponding to the same type of grayscale value in the w small images, so as to improve the utilization rate of the random access memory.

[0027] Preferably, the process of obtaining the reference grayscale value is as follows:

[0028] Use a straight line perpendicular to the gray value axis of the gray histogram to divide the gray histogram into two parts. The number of pixels in the left part with a smaller gray value accounts for 90% of the total number of pixels in the gray histogram. The gray value corresponding to the coordinate of the straight line on the gray value axis is the reference gray value.

[0029] Preferably, the brightness threshold is 3800.

[0030] Preferably, if the reference grayscale value is greater than or equal to the brightness threshold, the original image is exposed according to the following formula:

[0031] (5);

[0032] in, It indicates the exposure time result output by FPGA calculation. represents the original exposure time, Y represents the number of pixels with grayscale values ​​greater than 3800 in the w small images, and Z represents the total number of pixels in the w small images. This formula indicates that the exposure rate of pixels with grayscale values ​​greater than 3800 is lowered to reduce the exposure time.

[0033] Preferably, if the reference grayscale value is less than the brightness threshold, the original image is exposed according to the following formula:

[0034] (6);

[0035] Wherein, X represents the number of pixels corresponding to the reference grayscale value, and the formula indicates that the exposure time of pixels whose grayscale values ​​are greater than the reference grayscale value is increased to increase the exposure time.

[0036] Compared with the prior art, the present invention can achieve the following beneficial effects:

[0037] The present invention realizes automatic exposure control of image entropy value by using FPGA, which greatly improves the exposure effect of the picture; in the process of entropy value sorting, absolute value sorting is adopted to avoid the tedious operation of FPGA for sorting negative numbers; ping-pong operation is adopted for pixel statistics to improve the utilization rate of random access memory; the definition of the same type of gray value reduces the complexity of operation. BRIEF DESCRIPTION OF THE DRAWINGS

[0038] Figure 1 is a flow chart of an automatic exposure control method for implementing image entropy value based on FPGA provided in an embodiment of the present invention;

[0039] Figure 2 is a schematic diagram of pixel storage of an original image provided by an embodiment of the present invention;

[0040] Figure 3 is a schematic diagram of a RAM-A memory provided according to an embodiment of the present invention;

[0041] Figure 4 is a schematic diagram of storing the first 32 small images provided according to an embodiment of the present invention;

[0042] Figure 5 is a first clock entropy value comparison schematic diagram provided according to an embodiment of the present invention;

[0043] Figure 6 is a schematic diagram of a second clock entropy value sorting according to an embodiment of the present invention;

[0044] Figure 7 This is a picture exposure effect diagram using traditional methods;

[0045] Figure 8 It is a picture exposure effect diagram using the present invention. DETAILED DESCRIPTION

[0046] Hereinafter, embodiments of the present invention will be described with reference to the accompanying drawings. In the following description, the same modules are represented by the same reference numerals. In the case of the same reference numerals, their names and functions are also the same. Therefore, the detailed description thereof will not be repeated.

[0047] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and specific embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and do not constitute a limitation of the present invention.

[0048] Figure 1 The flowchart of the automatic exposure control method for implementing image entropy value based on FPGA according to an embodiment of the present invention is shown.

[0049] like Figure 1 As shown, the automatic exposure control method for realizing image entropy value based on FPGA provided by the present invention comprises the following steps:

[0050] Figure 2 The figure shows a pixel storage method of an original image provided according to an embodiment of the present invention.

[0051] like Figure 2 As shown, S1, for resolution , the original image with a data width of n is divided into , small images with a data width of n are stored, a total of A small picture.

[0052] S2. Determine the final entropy value calculation formula. The specific process is as follows:

[0053] The image is a two-dimensional information source. Pixels at different positions have different gray levels. The gray level of the small image is set to 2. n ,use i Indicates the gray value of the pixel (DN value), i= 0, 1, 2, …, 2 n -1, x i Indicates the gray value is i The number of pixels.

[0054] If eight adjacent grayscale values ​​are defined as the same grayscale value, the sum of the pixels corresponding to the eight adjacent grayscale values ​​is equal to the number of pixels of the same grayscale value. In addition, two, four or other adjacent grayscale values ​​can be defined as the same grayscale value. The probability of occurrence of the same grayscale value in the small figure is The calculation formula is as follows:

[0055] (1);

[0056] The entropy calculation formula is as follows:

[0057] (2);

[0058] Among them, 0≤P( x i )≤1, H represents the entropy value;

[0059] Since the log function is an increasing function, substituting formula (2) into formula (1) yields:

[0060] (3);

[0061] Since the present invention only sorts the entropy values, and does not need to accurately calculate the entropy values, formula (3) can be simplified to obtain the final entropy value calculation formula:

[0062] (4).

[0063] S3, calculated according to formula (4) The entropy value of a small graph is realized by using FPGA The entropy value ranking of the small graphs can be seen from formula (4): is a negative number. Since it is difficult for FPGA to process negative numbers, the present invention Take the absolute value, that is, remove the negative sign, and change the order. The entropy value sorting target is from large to small, so apply for an array in FPGA and use the For loop to The absolute values ​​of are stored in the array in ascending order. The absolute values ​​of the entropy values ​​of the small images are sorted from small to large. The w small images with the largest entropy values ​​are calibrated according to the sorting order, i.e., the regions of interest, where the value range of w is 5% to 50% of the number of small images; in this embodiment, the value of w is 10% of the number of small images.

[0064] For entropy calculation, we need to calculate log( x i ) value. There is a floating-point IP core in FPGA that can calculate the logarithmic function, but its input data type must be a floating-point number, and the existing data is an integer. Therefore, it is necessary to perform a number conversion to convert the integer data into floating-point data. After the logarithmic operation, the floating-point data is converted into integer data. The converted integer data is multiplied according to formula (4), and the number obtained is the entropy value, which is stored.

[0065] Figure 3 A RAM-A memory provided according to an embodiment of the present invention is shown.

[0066] like Figure 3 As shown, the DN value of the small image is stored, and the specific implementation method in FPGA is as follows:

[0067] The traditional processing method requires storing the same DN value of all small graphs in random access memory, which requires applying for a depth of P × Q , bit width n RAM, for example, this embodiment uses M=N= 1024, P=Q= 32, n=12, then you need to apply for 1024 RAMs with a depth of 1024 and a bit width of 12. This method has a very low RAM utilization rate and is prone to insufficient RAM resources. Based on the above problems, the present invention reduces 1024 RAMs to 1, with a bit width of 12 and a depth of 2. 12 ×32, store every 32 small images in RAM.

[0068] Figure 4 The storage of the first 32 small pictures provided according to an embodiment of the present invention is shown.

[0069] like Figure 4 As shown, the present invention sets every 8 adjacent widths of DN values ​​to the same type of DN value, so the RAM depth deepth currently required to be applied is at least (2 n / 8)×(N / Q), when M=N= 1024, P=Q=32, when n=12, depth=16384, at this time, it is necessary to judge whether the function can be realized by using one RAM based on the maximum depth of RAM. Assume that the maximum RAM depth that a certain model of FPGA can apply for is D max , the bit width is , if D max <(2 n / 8)×(N / Q), then according to (2 n / 8)×(N / Q) / D max The number of RAMs is determined by the result. If the result is an integer, the number of RAMs required is m, and the depth of RAM is D. max If the result still has a remainder, the number of RAMs required is m+1, where the depth of m RAMs is D max , the depth of the remaining RAM is at least not less than the remainder. M=N= 1024, P=Q= 32, when n=12, for Xilinx's xc7k325tffg676-2FPGA, since the maximum depth of its IP core RAM is 8192, it is necessary to apply for 2 widths of bit, RAM-A and RAM-A1 with a depth of 8192. Compared with applying for 1024 RAMs, the processing method of the present invention has greatly improved the RAM utilization rate.

[0070] After the first P rows of the original image are outputted using FPGA, the two RAMs have already counted the number of occurrences of each type of DN value in each small image. When reading the P+1th row of data, it is necessary to read out the counted number of pixels of the same type of DN value from the RAM, and at the same time, it is necessary to write the number of pixels of the same type of DN value in the current row into the corresponding address, that is, under one image data output clock, it is necessary to write to the RAM and read from the RAM. In order to resolve this contradiction, the present invention proposes to adopt a ping-pong operation, that is, the writing of 1 to P rows of data is carried out in RAM-A; when the writing of 1 to P rows of data is completed, the writing of P+1 to 2P rows of data is carried out in RAM-A1, and at this time the stored data of 1 to P rows in RAM-A is read; when the writing of P+1 to 2P rows of data is completed, the writing of 2P+1 to 3P rows of data is carried out after returning to RAM-A, and at this time the stored data of P+1 to 2P rows in RAM-A1 is read; reading and writing are performed repeatedly in the above manner to ensure that different data reading and writing occur in the same RAM, that is, to avoid data reading and writing occurring simultaneously in RAM-A or RAM-A1.

[0071] Figure 5 A first clock entropy value comparison provided according to an embodiment of the present invention is shown.

[0072] Figure 6A second clock entropy value sorting according to an embodiment of the present invention is shown.

[0073] like Figure 5 and Figure 6 As shown, the implementation process of entropy value sorting using FPGA is as follows:

[0074] First, define an array with a width of 32 bits and a depth of w. In this embodiment, w=1024×10%. At this time, w is a decimal and is rounded up to the nearest integer, so the depth is 103. The array is named Value. The high 12 bits of Value represent the entropy value, the middle 10 bits are the row number of the small image corresponding to the entropy value, and the low 10 bits are the column number of the small image corresponding to the entropy value. Take out any entropy value t and compare it with the data entropy value in the array from top to bottom. If any entropy value t is less than the data entropy value in the array, the value of the corresponding position of scope1 is 0; if any entropy value t is greater than or equal to the data entropy value in the array, the value of the corresponding position of scope1 is 1. That is, in the for loop, the size of the data stored in the arbitrary entropy value t and the value array is judged. After w times of judgment, the size of i is P × Q In order to store the entropy values ​​in the value array in ascending order, when the next clock comes, it is determined that when any entropy value t of Scope1 is less than the jth group of stored data in the value array, the currently compared entropy value t is stored in the jth group of value array. When the third clock comes, the value in Scope1 is XORed with the value in Scope2. If the result of XOR is 1, the currently compared entropy value is stored in the Value array. And so on, until the entropy values ​​of w small pictures are sorted.

[0075] S4, draw a grayscale histogram of the same type of grayscale value and the corresponding number of pixels in w small images;

[0076] S5. Obtain a reference grayscale value based on the grayscale histogram. Use a straight line perpendicular to the grayscale value axis of the grayscale histogram to divide the grayscale histogram into two parts. The number of pixels in the left part with a smaller grayscale value accounts for 90% of the total number of pixels in the grayscale histogram. The grayscale value corresponding to the coordinate of the straight line on the grayscale value axis is the reference grayscale value.

[0077] Determine the relationship between the reference grayscale value and the set brightness threshold, the brightness threshold is 3800:

[0078] If the reference grayscale value is greater than or equal to the brightness threshold, reduce the exposure time of the pixels whose grayscale value is greater than the brightness threshold, and expose the original image according to the following formula:

[0079] (5);

[0080] in, It indicates the exposure time result output by FPGA calculation. represents the original exposure time, Y represents the number of pixels with grayscale values ​​greater than 3800 in the w small images, and Z represents the total number of pixels in the w small images. This formula indicates that the exposure rate of pixels with grayscale values ​​greater than 3800 is lowered to reduce the exposure time.

[0081] If the reference grayscale value is less than the brightness threshold, increase the exposure time of pixels whose grayscale values ​​are greater than the reference grayscale value, and expose the original image according to the following formula:

[0082] (6);

[0083] Wherein, X represents the number of pixels corresponding to the reference grayscale value, and the formula indicates that the exposure time of pixels whose grayscale values ​​are greater than the reference grayscale value is increased to increase the exposure time.

[0084] Figure 7 The image exposure effect using the traditional method is shown.

[0085] Figure 8 The picture exposure effect using the present invention is shown.

[0086] Figure 8 The part enclosed by the small and medium boxes is the part of interest extracted by this method. Figure 7 and Figure 8 By comparison, it can be seen that this method can extract the region of interest under complex background, and the automatic exposure of the region of interest is more obvious, and the overall exposure effect of the image is better.

[0087] Although the embodiments of the present invention have been shown and described above, it is understood that the above embodiments are exemplary and cannot be understood as limiting the present invention. Those skilled in the art may change, modify, replace and modify the above embodiments within the scope of the present invention.

[0088] The above specific implementations of the present invention do not constitute a limitation on the protection scope of the present invention. Any other corresponding changes and modifications made based on the technical concept of the present invention should be included in the protection scope of the claims of the present invention.

Claims

1. An automatic exposure control method based on FPGA to realize image entropy value, characterized in that: The following steps are involved: S1, set the resolution to , the original image with data width n is divided into , a small image with a data width of n; S2. Determine the final entropy value calculation formula. The specific process is as follows: Set the grayscale of the thumbnail to 2 n , i Represents the gray value, i= 0, 1, 2, …, 2 n -1, x i Indicates the gray value is i The number of pixels; The adjacent a grayscale values ​​are defined as the same type of grayscale values. The sum of the pixels corresponding to the adjacent a grayscale values ​​is equal to the number of pixels of the same type of grayscale value. a is a positive integer. The probability of occurrence of the same type of grayscale value in the small image is The calculation formula is as follows: (1); The entropy calculation formula is as follows: (2); Where H represents the entropy value; Substituting formula (2) into formula (1), we get: (3); Simplify formula (3) to obtain the final entropy value calculation formula: (4); S3, calculated according to formula (4) The entropy value of the small image is realized by using FPGA The entropy value sorting process of the small graphs is as follows: The entropy value calculated by formula (4) If it is a negative number, take its absolute value, apply for an array in FPGA, and use the For loop to The absolute values ​​of are stored in the array in ascending order. The entropy values ​​of the small images are sorted from large to small, and the w small images with the largest entropy values ​​are calibrated as the regions of interest, wherein the value range of w is 5% to 50% of the number of the small images, and w is an integer; S4, draw a grayscale histogram of the same type of grayscale value and the corresponding pixel number in the w small images; S5. Obtain a reference grayscale value according to the grayscale histogram, and determine the magnitude relationship between the reference grayscale value and a set brightness threshold: If the reference grayscale value is greater than or equal to the brightness threshold, reducing the exposure time of pixels whose grayscale values ​​are greater than the brightness threshold; If the reference grayscale value is less than the brightness threshold, the exposure time of pixels whose grayscale values ​​are greater than the reference grayscale value is increased.

2. The automatic exposure control method based on FPGA to realize image entropy value as claimed in claim 1, characterized in that: In S2, the value of a is 2, 4, or 8, that is, 2, 4, or 8 adjacent grayscale values ​​are defined as the same type of grayscale values.

3. The automatic exposure control method based on FPGA to realize image entropy value as claimed in claim 1, characterized in that: In S3, The entropy values ​​of the small images are sorted from large to small.

4. The automatic exposure control method based on FPGA to realize image entropy value as claimed in claim 1, characterized in that: When drawing the grayscale histogram, a ping-pong operation is used to count the number of pixels corresponding to the same grayscale value in the w small images, so as to improve the utilization rate of the random access memory.

5. The automatic exposure control method based on FPGA to realize image entropy value as claimed in claim 1, characterized in that: The process of obtaining the reference grayscale value is as follows: The grayscale histogram is divided into two parts using a straight line perpendicular to the grayscale value axis of the grayscale histogram. The number of pixels in the left part with a smaller grayscale value accounts for 90% of the total number of pixels in the grayscale histogram. The grayscale value corresponding to the coordinate of the straight line on the grayscale value axis is the reference grayscale value.

6. The automatic exposure control method based on FPGA to realize image entropy value as claimed in claim 1, characterized in that: The brightness threshold is 3800.

7. The automatic exposure control method based on FPGA to realize image entropy value as claimed in claim 6, characterized in that: If the reference grayscale value is greater than or equal to the brightness threshold, the original image is exposed according to the following formula: (5); in, It indicates the exposure time result output by FPGA calculation. represents the original exposure time, Y represents the number of pixels with grayscale values ​​greater than 3800 in the w small images, and Z represents the total number of pixels in the w small images. This formula indicates that the exposure rate of pixels with grayscale values ​​greater than 3800 is lowered to reduce the exposure time.

8. The automatic exposure control method based on FPGA to realize image entropy value as claimed in claim 1, characterized in that: If the reference grayscale value is less than the brightness threshold, the original image is exposed according to the following formula: (6); Among them, X represents the number of pixels corresponding to the reference grayscale value, and the formula represents increasing the exposure time of pixels whose grayscale values ​​are greater than the reference grayscale value to increase the exposure time.