Machine vision hard real-time gamma implementation method based on approximate compensation method and medium

By using an approximate compensation method, the Gamma algorithm is transformed into addition, subtraction, and shift operations suitable for FPGAs, solving the problems of real-time variable γ coefficients and high resource consumption. This achieves efficient Gamma algorithm calculation and is applicable to data processing and display in the field of machine vision.

CN115439304BActive Publication Date: 2026-03-31HEFEI I TEK OPTOELECTRONICS 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-08-23
Publication Date
2026-03-31

Smart Images

  • Figure CN115439304B_ABST
    Figure CN115439304B_ABST
Patent Text Reader

Abstract

The application discloses a kind of hard real-time Gamma implementation method and medium for machine vision based on approximate compensation method, and the implementation method is transformed by Gamma algorithm basic formula, and the exponential operation is transformed into multiplication and shift operation suitable for processor such as FPGA implementation, the precision lost in transformation process is compensated using Taylor expansion, and lookup table is used to assist calculation for some fixed subitems not suitable for direct calculation, a kind of gamma coefficient real-time variable and change range unlimited Gamma algorithm implementation mode is provided.The RAM and LE resource consumption of the algorithm are moderate, the lookup table used in the algorithm does not change with input bit width, and it is an implementation mode based on current gamma coefficient real-time calculation result to solve the problems existing in the prior art Gamma algorithm, and provide an effective new implementation means of Gamma algorithm for machine vision field data processing and data display.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image data processing methods, specifically to an image data processing method and storage medium based on an optimized Gamma algorithm. Background Technology

[0002] The Gamma algorithm is widely used in data processing / display systems. Figure 1 The image shows the basic formula for the Gamma algorithm and the curves for a typical Gamma coefficient in the display system. From... Figure 1 As can be seen, by setting different Gamma coefficients γ, data in different regions can be stretched, which can improve the regional resolution. This has wide applications in the field of data processing / display.

[0003] In the field of machine vision, a typical approach involves an industrial camera paired with a data acquisition card for data acquisition / preprocessing, followed by computer-based data post-processing, and finally, data analysis (object recognition / detection) to guide industrial production processes. Currently, the Gamma algorithm is generally performed on the computer, but in demanding or production efficiency-sensitive applications, it is usually required to perform the Gamma algorithm on the industrial camera itself. Figure 1 The basic formula of the Gamma algorithm involves exponential operations, resulting in high computational complexity.

[0004] There are several typical implementations of the Gamma algorithm: one is based on a lookup table, and the other is based on the Cordic continuous approximation principle.

[0005] A lookup table (LUT) works by addressing the pre-stored content in the lookup table based on the input, and then outputting the content (i.e., the data) at the corresponding location. The input to a lookup table is an address, and the output is data.

[0006] The lookup table-based implementation is the most widely used, especially in display applications where the γ coefficient is relatively fixed. Only a fixed lookup table needs to be maintained to implement the Gamma algorithm. The basic principle is to pre-calculate the result based on the Gamma formula, store the result in a cache, and then directly query the cache using the input data as the address. The lookup table implementation is also widely used in industrial cameras. Although the γ coefficient is generally required to be variable in industrial applications, a new lookup table can be pre-calculated based on the new γ coefficient and then updated in software. This implementation is simple and effective in some less demanding systems. The implementation based on the Cordic continuous approximation principle is more suitable for some very demanding applications. This method does not require maintaining a lookup table; instead, it calculates the result directly in real-time based on the current γ coefficient. In some demanding applications, the γ coefficient needs to change within 10ms, and new data must be calculated based on the new γ coefficient. If a lookup table-based approach is still used, it is simply impossible to implement in the limited resources of industrial cameras (which do not have high-performance CPUs). The biggest advantage of the implementation based on the Cordic continuous approximation principle is that the γ coefficient can change rapidly in real time. However, in order to ensure data accuracy, the number of iterations is large. According to the error propagation formula, assuming that the final Gamma correction is to achieve an accuracy of ±1, and the range of the γ coefficient is (0,16), then the Cordic algorithm should perform 5 negative iterations and 13 positive iterations, and the register bit width fractional part should be no less than 17 bits.

[0007] Field-Programmable Gate Arrays (FPGAs) are currently a very popular type of programmable device. Their flexible configuration and programmability make them widely used in various fields. Because FPGAs are a hardware implementation method with high parallel processing capabilities, they can handle high-speed data acquisition / processing scenarios. Therefore, FPGAs are widely used in industrial cameras, where they typically handle the entire process of data acquisition, preprocessing, and transmission. While FPGAs are programmable hardware devices with powerful parallel processing capabilities, they are not well-suited for iterative computations. To support iterative computations, resources must be traded for speed; each iteration requires copying a processing unit, so the more iterations, the more resources are consumed and the greater the latency.

[0008] In summary, when implemented in hardware, the lookup table-based Gamma algorithm is RAM-intensive and unsuitable for applications requiring real-time variable γ coefficients. The Cordic-based Gamma algorithm, to maintain a certain level of accuracy, requires numerous iterations and a sufficiently wide register to retain enough decimal places. This prevents significant discrepancies in the final result due to error accumulation during iterations, making it a logic (LE) resource-intensive algorithm. Furthermore, it has limitations regarding the range of γ coefficient variation; increasing the γ coefficient requires increasing the number of iterations to maintain accuracy, thus limiting its applicability. Summary of the Invention

[0009] The present invention proposes a real-time Gamma algorithm for machine vision based on approximate compensation method, which can at least solve one of the above-mentioned technical problems.

[0010] To achieve the above objectives, the present invention adopts the following technical solution:

[0011] After obtaining the pixel data T and γ coefficients, the following processing is performed:

[0012] Step 1, calculate lnT:

[0013] Calculate lnT using the following formula:

[0014]

[0015] In formula (1), n ​​is obtained by taking the position where the highest bit of T is 1, 1000β=(1000T)>>n, and log2β is obtained by looking up a table:

[0016] The lookup address for the Log table with pre-stored log2β values ​​is: R = 1000β - 1000 = [(1000T) >> n] - 1000;

[0017] The value of log2β is obtained by querying the Log table based on R.

[0018] The value of lnT can be calculated using formula (1);

[0019] Step 2: Calculate the output value S:

[0020] The output value S is calculated using the following formula:

[0021] S = 2 K e P (2)

[0022] Where P = γlnT - K × ln2;

[0023] Using formula The value of K is calculated;

[0024] Pre-stored e P The lookup address for the Exp table value is: Q = 1000P = 1000γlnT - 693K; where e P The value is updated based on the γ coefficient;

[0025] Based on Q, e is obtained from the Exp table. P Value; calculate the output value S using formula (2);

[0026] Output the value S after processing by the Gamma algorithm.

[0027] Furthermore, regarding e P Perform Taylor expansion to the second level, i.e., e P =1+P+P 2 / 2;

[0028] e is updated in real time based on the γ coefficient. P When the value is 1+P+P, use 1+P+P 2 The value of / 2 replaces e P The true value here transforms complex exponential operations into simple addition / subtraction / multiplication operations that consume less processor resources, which can greatly save processor resources and allows for real-time configuration of the lookup table based on the changing γ coefficient.

[0029] Furthermore, the pre-stored value in the Log table can be the amplified value of log2β. The amplification factor can be adjusted according to the required precision. When log2β is amplified by 1024 times, the lookup table is configured as 1024w×10bit; w is the item in the lookup table, × is the multiplication sign, and 10bit is the size of each item in the lookup table. When log2β is amplified by 32768 times, the lookup table is configured as 1024w×16bit.

[0030] Furthermore, the EXP table has a length of 694, corresponding to e P | P∈[0.000,0.694] The address is Q = 1000P∈[0,694].

[0031] e P The maximum value does not exceed 4 (e) P | P=0.694 If each value is represented using 16 bits, the lookup table configuration is 1024w × 16 bits, which means it will consume 16kb.

[0032] Furthermore, the obtained pixel data consists of n parallel pixel data points: T1, T2, ..., T n The output value is n parallel processed pixel data S1, S2, ..., S n .

[0033] Furthermore, the above algorithm can be executed on an FPGA, where addition and subtraction operations are implemented using the FPGA's adder. K The calculations are implemented using a bucket shifter in the FPGA, and the storage and retrieval of the Log and Exp tables are implemented using table lookup in the FPGA.

[0034] In another aspect, the present invention also discloses a computer-readable storage medium, which, when executed by a processor, causes the processor to perform the above-described method for implementing hard real-time Gamma in machine vision based on approximate compensation.

[0035] The specific explanation of this invention is as follows: The basic formula of the Gamma algorithm is S = T γ Where T is the input, S is the output, and the γ coefficient can be configured in real time.

[0036] Let γlnT = K × ln2 + P, where K is an integer, then we have:

[0037]

[0038] In the above formula, INT is the floor function, which rounds down to the nearest integer. Integers; let Q = 1000P = 1000γlnT - 1000 × Kln2 = 1000γlnT - 693K.

[0039] Then we have: S = T γ =e γlnT =e Kln2+P =2 K e P =2 K e Q / 100n .

[0040] Where e P =e Q / 1000 This can be obtained by looking up a table; the table length is 694, corresponding to e. P | P∈[0.000,0.694] The address is Q = 1000P∈[0,694].

[0041] e P The maximum value does not exceed 4 (e) P | P=0.694 If each value is represented using 16 bits, the maximum value is 65536 / 4 = 16384, and the precision can reach 0.00003 * 2048 = 0.0625, that is, the maximum error does not exceed 0.1.

[0042] At this point, the lookup table is configured to be 1024w×16bit, which means it requires 16kb.

[0043] For eP | P∈[0.000,0.694] If some precision is sacrificed, the lookup table can be further reduced; that is, since the maximum value of P is 0.694, the lookup table can be reduced for e. P Perform Taylor expansion to the second level, i.e., e P ≈1+P+P 2 / 2.

[0044] Let e P =1+P+P 2 / 2,P max =0.693, e P | P=0.693 = (1+P+P2 / 2 / P=0.693=1.9331, which differs from the true value of 1.9997 by 0.0665.

[0045] The above describes how exponential operations are transformed into addition / subtraction / multiplication and shift operations. When the γ coefficient changes, it is no longer necessary to perform exponential operations that consume a lot of RAM; only addition / subtraction / multiplication and shift operations with moderate RAM consumption are required.

[0046] For lnT, we continue to use the lookup table method to solve it. If the input bit width is 12 bits, then the value range of T is 0 to 4095, so the length of the table is 4096. However, we can continue to simplify and reduce the length of the table.

[0047] Let T = β2 n Then there is

[0048] For the calculation of n, take the position where the highest bit of T is 1. Once n is determined, let α = 1000β = (1000T) >> n, where >> indicates a right shift calculation. From T = β² n Given that β∈[1.000,2.000), we have α=1000β∈[1000,2000), so the query address is R=(α-1000)∈[0,1000). That is, the length of each table is 1000, corresponding to log2β| β∈[1.000,2.000) The address is R = (1000β - 1000) ∈ [0, 1000).

[0049] For log2β, the maximum value of β is 2, so the maximum value of log2β is 1. With a magnification of 1024, each element only needs 10 bits to represent. And since the value of β is in the range of 1 to 2, there are at most 1000 elements. Therefore, the lookup table is configured as 1024w×10bit. If the precision is increased by a magnification of 32768, each element is defined as 16 bits wide. That is, the lookup table is also configured as 1024w×16bit, which requires 16kb of RAM resources.

[0050] Therefore, the total RAM consumption required for the lookup table of fixed sub-items is 32kb.

[0051] Based on the values ​​of n and log2β, we can... The lnT is calculated, and further calculations are performed based on the configured γ coefficients:

[0052]

[0053] Q = 1000P = 1000γlnT - 693K

[0054] e can be obtained from the Q value by looking up the table. Q / 1000 =e P The values ​​of K and e Q / 1000 Substitute into the formula:

[0055] S = T γ =e γlnT =e Kln2+P =2 K e P =2 K e Q / 1000

[0056] Finally, the output S is calculated.

[0057] For ease of calculation and to better facilitate table lookup, the above formula can also be modified as follows:

[0058] Let T = β2 n Then there is

[0059] Let m = log₂β, then

[0060] Let γ1 = 5909γ, γ2 = 1000γ, then we have:

[0061]

[0062]

[0063] Let U = 16384e P ,but:

[0064]

[0065] In summary, this invention presents a novel Gamma algorithm implementation with a real-time variable γ coefficient and an unlimited range of variation. This algorithm consumes moderate amounts of RAM and LE resources, and the lookup table used in the algorithm does not require updating and does not change with the input bit width. It is an implementation method that calculates the result in real time based on the current γ coefficient, thus solving the problems existing in current Gamma algorithms and providing a new and effective Gamma algorithm implementation method for data processing and data display in the field of machine vision.

[0066] This invention transforms the basic formula of the Gamma algorithm, converting exponential operations into multiplication and shift operations suitable for processors such as FPGAs. Taylor expansion is used to compensate for the precision loss during the transformation, and lookup tables are employed to assist calculation for certain fixed sub-items unsuitable for direct calculation. This provides a Gamma algorithm implementation where the γ coefficient is variable in real-time with an unlimited range of variation. The algorithm consumes moderate amounts of RAM and LE resources, and the lookup table used does not change with the input bit width. It is an implementation method that calculates the result in real-time based on the current γ coefficient, addressing the problems existing in current Gamma algorithms. This provides an effective new implementation of the Gamma algorithm for data processing and display in the field of machine vision. Attached Figure Description

[0067] Figure 1 This includes the basic formula and typical curves of the Gamma algorithm;

[0068] Figure 2 This is a flowchart of a method for implementing real-time Gamma in machine vision based on the approximate compensation method. Detailed Implementation

[0069] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are some embodiments of the present invention, but not all embodiments.

[0070] This invention presents a novel Gamma algorithm implementation with a real-time variable γ coefficient and an unlimited range of variation. This algorithm consumes moderate amounts of RAM and LE resources. The lookup table used in the algorithm does not need to be updated and does not change with the input bit width. It is an implementation method that calculates the result in real time based on the current γ coefficient, thus solving the problems existing in current Gamma algorithms. This provides a new and effective Gamma algorithm implementation method for data processing and data display in the field of machine vision. Examples are given below:

[0071] Example 1:

[0072] After obtaining pixel data T and configuring the γ coefficient of the Gamma algorithm in real time, the following processing is performed:

[0073] Step 1, calculate lnT:

[0074] Calculate lnT using the following formula:

[0075]

[0076] In formula (1), n ​​is obtained by taking the position where the highest bit of T is 1, 1000β=(1000T)>>n, and log2β is obtained by looking up a table:

[0077] The lookup address for the Log table with pre-stored log2β values ​​is: R = 1000β - 1000 = [(1000T) >> n] - 1000;

[0078] The value of log2β is obtained by querying the Log table based on R.

[0079] The value of lnT can be calculated using formula (1);

[0080] Step 2: Calculate the output value S:

[0081] The output value S is calculated using the following formula:

[0082] S = 2 K e P (2)

[0083] Where P = γlnT - K × ln2;

[0084] Using formula The value of K is calculated;

[0085] Pre-stored e updated in real time based on the γ coefficient P The Exp table lookup address for the value is: Q = 1000, P = 1000, γlnT - 693K;

[0086] Based on Q, e is obtained from the Exp table. P Value; calculate the output value S using formula (2);

[0087] Output the value S after processing by the Gamma algorithm.

[0088] Specifically, regarding e P Perform Taylor expansion to the second level, i.e., e P =1+P+P 2 / 2;

[0089] e is updated in real time based on the γ coefficient. P When the value is 1+P+P, use 1+P+P 2 The value of / 2 replaces e PThe true value here transforms complex exponential operations into simple addition / subtraction / multiplication operations that consume less processor resources, which can greatly save processor resources and allows for real-time configuration of the lookup table based on the changing γ coefficient.

[0090] The value stored in the Log table can be the amplified value of log2β. The amplification factor can be adjusted according to the required precision. When log2β is amplified by 1024 times, the lookup table is configured as 1024w×10bit; when log2β is amplified by 32768 times, the lookup table is configured as 1024w×16bit.

[0091] The EXP table has a length of 694, corresponding to e P | P∈[0.000,0.694] The address is Q = 1000P∈[0,694].

[0092] e P The maximum value does not exceed 4 (e) P | P=0.694 If each value is represented using 16 bits, the lookup table configuration is 1024w × 16 bits, which means it will consume 16kb.

[0093] like Figure 2 As shown, the obtained pixel data consists of n parallel pixel data points: T1, T2, ..., T n Based on the configured γ coefficient, a Gamma algorithm based on approximate compensation is executed on each pixel, and the output value is n parallel processed pixel data S1, S2, ..., S n .

[0094] The above algorithm can be executed on an FPGA, where addition and subtraction operations are implemented using the FPGA's adder. K The calculations are implemented using a bucket shifter in the FPGA, and the storage and retrieval of the Log and Exp tables are implemented using table lookup in the FPGA.

[0095] In another aspect, the present invention also discloses a computer-readable storage medium, which, when executed by a processor, causes the processor to perform the above-described method for implementing hard real-time Gamma in machine vision based on approximate compensation.

[0096] Example 2:

[0097] After obtaining pixel data T and configuring the γ coefficient of the Gamma algorithm in real time, the following processing is performed:

[0098] 1. Calculate n and α based on the input data T: n is obtained by taking the position where the highest bit of T is 1, and α = (1000T) >> n.

[0099] 2. Calculate the lookup address of the Log table based on α, which is R = (α - 1000).

[0100] α=1000β=(1000T)>>n, from T=β2 n Given that β∈[1.000,2.000), we have α=1000β∈[1000,2000), so the query address is R=(α-1000)∈[0,1000); that is, the length of each table is 1000, corresponding to log2β| β∈[1.000,2.000) The address is R = (1000β - 1000) ∈ [0, 1000);

[0101] The log2β value m, magnified by 32768 times, is read from the Log table which contains a pre-stored log2β value magnified by 32768 times. The accuracy of the calculation is improved by magnifying the log2β value.

[0102] 3. Calculate 32768n+m and substitute it into the following formula:

[0103]

[0104] Obtain the value of lnT.

[0105] 4. Calculated based on lnT

[0106] 5. Based on lnT and K, we can calculate Q = 1000P = 1000γlnT - 693K = γ2lnT - 693K;

[0107] 6. Using Q as the address, query the pre-stored e value magnified 16384 times. P The Exp table yields U = 16384e P :

[0108] The EXP table has a length of 694, corresponding to e P |P∈[0.000,0.694], address Q=1000P∈[0,694],e P The maximum value does not exceed 4 (e) P | P=0.694 ).

[0109] For e P | P∈[0.000,0.694] If some precision is sacrificed, the lookup table can be further reduced; that is, since the maximum value of P is 0.694, the lookup table can be reduced for e. P Perform Taylor expansion to the second level, i.e., e P ≈1+P+P 2 / 2, let e P =1+P+P 2 / 2,Pmax =0.693, e P |P=0.693=1.9331, it can be seen that after Taylor expansion e P The value differs from the true value of 1.9997 by 0.0665; therefore, 1+P+P 2 The value of / 2 replaces e P The value is approximated and e is updated in real time based on the γ coefficient. P When the value is 1+P+P, use 1+P+P 2 The value of / 2 replaces e P The actual value is the value stored in the EXP table after being magnified 16384 times to improve accuracy. P approximation.

[0110] 7. Calculate the final output value.

[0111] like Figure 2 As shown, the obtained pixel data consists of n parallel pixel data points: T1, T2, ..., T n Based on the configured γ coefficient, a Gamma algorithm based on approximate compensation is executed on each pixel, and the output value is n parallel processed pixel data S1, S2, ..., S n ;

[0112] The above algorithm can be executed on an FPGA, where addition and subtraction operations are implemented using the FPGA's adder. K The calculations are implemented using a bucket shifter in the FPGA, and the storage and retrieval of the Log and Exp tables are implemented using table lookup in the FPGA.

[0113] Traditional Gamma algorithms are primarily used to correct color differences in displays, adapting them to human visual perception. In machine vision, however, Gamma algorithms are used to correct color differences in objects captured in various scenarios, such as large LED displays. This correction is then used in subsequent color difference removal operations. The ability to change the Gamma coefficient in real time to observe the image effects under different Gamma coefficients greatly improves production efficiency and has wide applications in industrial inspection.

[0114] This invention presents a real-time Gamma algorithm for machine vision based on an approximation compensation method, where the γ coefficient is variable in real time and its range is unlimited. This algorithm is an implementation method that calculates the result in real time based on the current γ coefficient, addressing the problems existing in current Gamma algorithms. When the γ coefficient equals 1, the algorithm achieves zero error at all points in 12-bit mode. Specifically, the implementation process of this real-time Gamma algorithm for machine vision based on an approximation compensation method with a variable γ coefficient in real time and its range is detailed in the principle section. In the new algorithm, the γ coefficient is configurable as an external variable, and the algorithm calculates new results in real time based on the currently configured γ coefficient.

[0115] To obtain the optimal working Gamma coefficient, N images need to be acquired continuously. The acquisition time for each image greatly affects production efficiency. Therefore, it is necessary to be able to change the Gamma coefficient in real time and acquire new images. This invention provides a method for changing the Gamma coefficient in real time.

[0116] The Gamma algorithm is widely used. In machine vision, during large-screen inspection, the gamma coefficient is adjusted in real time to apply the Gamma algorithm and obtain a target image that meets the requirements. The implementation steps are as follows:

[0117] 1. The Gamma coefficient is set to 1, which is equivalent to disabling the Gamma algorithm. Image 1 is acquired to obtain the basic color pattern 1 of the target object (large LED screen);

[0118] 2. Adjust the gamma coefficient in real time, acquire image 2, and obtain a new color pattern 2 for the target object;

[0119] 3. Repeat step 2 to continuously acquire images and obtain new color patterns 3 to N of the target object;

[0120] 4. Compare the target patterns under different Gamma coefficients, and select the Gamma coefficient corresponding to the pattern with the best visual effect as the final working parameter.

[0121] In another aspect, the present invention also discloses a computer-readable storage medium storing a computer program, which, when executed by a processor, causes the processor to perform the steps of any of the methods described above.

[0122] In another aspect, the present invention also discloses a computer device, including a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor performs the steps of any of the methods described above.

[0123] In another embodiment provided in this application, a computer program product containing instructions is also provided, which, when run on a computer, causes the computer to perform the steps of any of the methods described in the above embodiments.

[0124] It is understood that the system provided in the embodiments of the present invention corresponds to the method provided in the embodiments of the present invention, and the explanation, examples and beneficial effects of the relevant content can be referred to the corresponding parts of the above methods.

[0125] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments described above. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), RAMbus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and RAMbus dynamic RAM (RDRAM), etc.

[0126] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0127] The above embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method for implementing hard real-time Gamma based on an approximate compensation method for machine vision, characterized by, After obtaining the pixel data T and the gamma coefficient, the following processing is performed: Step 1, calculating lnT: lnT is calculated by using the following formula: In formula (1), n is obtained by taking the position of the highest bit of T as 1, 1000β=(1000T)>>n, and log2β is obtained by a lookup table method: The lookup address of the Log table pre-storing the value of log2β is R=1000β-1000=[(1000T)>>n-1000; The value of log2β is obtained from the Log table according to R; The value of lnT is obtained by using formula (1); Step 2, calculating the output value S: The output value S is calculated by using the following formula: S = 2 K e P (2) Wherein, P=γlnT-K×ln2; The K value is calculated using the formula K = 1 - (1 - 1 / n) Pre-stored e P The Exp table query address of the value is: Q = 1000 P = 1000 γlnT - 693 K; According to Q, e is queried from the Exp table P The output value S is calculated by using formula (2) The output value S processed by the Gamma algorithm is outputted.

2. The hard real-time Gamma implementation method based on the approximate compensation method for machine vision according to claim 1, wherein, Further comprising: For e P Performing Taylor expansion to second order, i.e. e P = 1 + P + P 2 / 2; Exp e pre-stored P values are replaced by 1 + P + P 2 / 2.

3. The hard real-time Gamma implementation method based on the approximate compensation method for machine vision according to claim 2, characterized in that, The value pre-stored in the Log table is the value of log2β after amplification, when log2β is amplified by 1024 times, the lookup table is configured as 1024w×10-bit; when log2β is amplified by 32768 times, the lookup table is configured as 1024w×16-bit.

4. The hard real-time Gamma implementation method based on the approximate compensation method for machine vision according to claim 2, wherein, The length of the Exp table is 694, and the corresponding P∈[0.000, 0.694], and the address is Q=1000P∈[0, 694].

5. The hard real-time Gamma implementation method based on the approximate compensation method for machine vision according to claim 4, characterized in that, When the e P The configuration of the lookup table is 1024w x 16-bit when each value is 16-bit.

6. The hard real-time Gamma implementation method based on the approximate compensation method for machine vision according to any one of claims 1-5, characterized in that, The obtained pixel data is n parallel pixel data, and the output value is n parallel processed pixel data.

7. The hard real-time Gamma implementation method based on the approximate compensation method for machine vision according to any one of claims 1-5, characterized in that, The hard real-time Gamma implementation method based on the approximate compensation method for machine vision according to any one of claims 1-5 is implemented by using an FPGA, wherein the addition and subtraction operations are implemented by an adder of the FPGA, and the multiplication and division operations are implemented by a multiplier of the FPGA. K The storage and calling of the Log table and the Exp table are implemented by a lookup table of the FPGA.

8. A computer-readable storage medium, characterized in that, The computer program, when executed by a processor, causes the processor to execute the hard real-time Gamma implementation method based on the approximate compensation method for machine vision according to any one of claims 1 to 5.

Citation Information

Patent Citations

  • Method for gamma correction of LCD (Liquid Crystal Display) screen

    CN101976552A

  • Image real-time Gamma correction method based on FPGA

    CN111815541A