Control method, device, apparatus and computer readable storage medium of light emitting device
By using a unique calculation formula and Newton's iteration method, combined with the binary floating-point arithmetic standard, and avoiding the power function pow(), fast and efficient correction of optical information is achieved. This solves the problems of slow speed and large memory consumption of gamma correction algorithms in 8-bit microcontrollers, improving execution speed and reducing memory consumption.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- FOSHAN ELECTRICAL & LIGHTING
- Filing Date
- 2023-05-17
- Publication Date
- 2026-04-28
AI Technical Summary
Existing gamma correction algorithms are slow to execute and consume a lot of memory in 8-bit microcontrollers, making it difficult to meet the actual needs of users.
Using a unique calculation formula out=in2×in(n-16)/8×level(8-n)/8, combined with Newton's iteration method and the binary floating-point arithmetic standard, the optical information is corrected through pointer operations, type casting and bit operations, avoiding the power function pow().
It achieves fast and efficient nonlinear correction of optical information, conforms to the characteristics of human vision, improves execution speed and reduces memory usage.
Smart Images

Figure CN116744508B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of lighting technology, and in particular to a control method, device, apparatus, and computer-readable storage medium for a light-emitting device. Background Technology
[0002] Currently, gamma correction algorithms are commonly used in the market to perform non-linear correction on the brightness and color of lights and screen displays, in order to reduce the impact of uneven changes during dimming and color adjustment, making them closer to the visual perception characteristics of the human eye.
[0003] Accordingly, existing gamma correction algorithms generally use the following formula:
[0004] out = (in ÷ level) γ ×level
[0005] Where in is the input value, level is the level number, γ is the gamma value, and out is the output value.
[0006] The above calculation process includes one floating-point division operation, one exponentiation operation, and one floating-point multiplication operation. In C language, the exponentiation operation requires calling the function pow() in the library file math.h. This function occupies approximately 2KB of memory in the Keil5 compiler, and the internal code of the function has a large amount of computation and a long execution time. For commonly used 8-bit microcontrollers, this is a heavy burden in terms of both memory usage and execution speed.
[0007] In summary, existing correction methods are slow and consume a lot of memory, making it difficult to meet users' actual needs. Therefore, it is necessary to develop a new dimming control method to achieve fast and efficient adjustment of brightness and color. Summary of the Invention
[0008] The technical problem to be solved by the present invention is to provide a control method, device, apparatus and computer-readable storage medium for a light-emitting device, which can perform nonlinear fast and efficient correction on the light information to be adjusted so that the light information to be adjusted conforms to the visual characteristics of the human eye.
[0009] To address the aforementioned technical problems, the present invention provides a control method for a light-emitting device, comprising: acquiring light information to be adjusted from the light-emitting device; and, based on the light information to be adjusted, controlling the light-emitting device using the formula out = in. 2 ×in (n-16) / 8 ×level (8-n) / 8 Calculate optical correction information, where out is the optical correction information, in is the optical information to be adjusted, n is a preset gamma adjustment factor and n is a positive integer, and level is a preset level number; adjust the light output information of the light-emitting device to be consistent with the optical correction information.
[0010] As an improvement to the above scheme, the step of adjusting the light information to be adjusted using the formula out = in... 2 ×in (n-16) / 8 ×level (8-n) / 8 The steps for calculating optical correction information include: constructing and calculating a first reference parameter in based on the optical information to be adjusted and a preset gamma adjustment factor. (n-16) / 8 The second baseline parameter, level, is constructed and calculated based on the preset number of levels and the preset gamma adjustment factor. (8-n) / 8 Based on the first reference parameter, the second reference parameter, and the light information to be adjusted, the formula out = in is used. 2 ×in (n-16) / 8 ×level (8-n) / 8 Calculate optical correction information.
[0011] As an improvement to the above scheme, the first reference parameter in is constructed and calculated based on the light information to be adjusted and the preset gamma adjustment factor. (n-16) / 8 The steps include: calculating in -1 / 8 Approximate value; according to Newton's iteration method, the in -1 / 8 The approximate value is optimized to generate in -1 / 8 The optimized value; according to the in -1 / 8 The optimization value is calculated using the first baseline parameter in. (n-16) / 8 The value of .
[0012] As an improvement to the above scheme, the calculation in -1 / 8 The steps for approximating the value include: defining a first variable of type float, which is a function parameter used to receive the light information to be adjusted; defining a second variable of type float, which is used to store the light information to be adjusted; defining a third variable of type long; performing an address-taking operation on the first variable, forcibly converting the address-taking result of the first variable to type *(long*), and assigning the conversion result of the first variable to the third variable; shifting the value of the third variable to the right by a preset number of bits, subtracting the right-shifted value of the third variable using a preset compensation number, and assigning the difference result to the third variable; performing an address-taking operation on the third variable, forcibly converting the address-taking result of the third variable to type *(float*), and assigning the conversion result of the third variable to the first variable. At this point, the value of the first variable is in. -1 / 8 Approximate value.
[0013] As an improvement to the above scheme, the second variable is a 32-bit float type, the third variable is a 32-bit long type, and the preset number of bits is 3 bits.
[0014] As an improvement to the above scheme, the step of applying Newton's iteration method to the in -1 / 8 The approximate value is optimized to generate in -1 / 8 The steps for optimizing the value include: constructing a function f(y) = (1 / y) with y as the independent variable. 8 If -x = 0, then f'(y) = -8y -9 ; f(y) = (1 / y 8 f'(y) = -8y -9 Substituting into Newton's iterative formula, we get y - (f(y) / f'(y)) = (9y / 8) - (xy) 9 / 8); the in -1 / 8 Substituting the approximate value into the formula y-(f(y) / f'(y))=(9y / 8)-(xy) 9 / 8) Perform iterative processing to generate the in -1 / 8 The optimized value.
[0015] As an improvement to the above scheme, the light information to be adjusted includes grayscale value, brightness value, or color temperature value.
[0016] Accordingly, the present invention also provides a control device for a light-emitting device, comprising: an acquisition module for acquiring light information to be adjusted from the light-emitting device; and a calculation module for calculating the light information to be adjusted using the formula out = in. 2 ×in (n -16) / 8 ×level (8-n) / 8 Calculate optical correction information, where out is the optical correction information, in is the optical information to be adjusted, n is a preset gamma adjustment factor and n is a positive integer, and level is a preset level number; Adjustment module is used to adjust the light output information of the light-emitting device to be consistent with the optical correction information.
[0017] As an improvement to the above scheme, the calculation module includes: a first calculation module, used to construct and calculate a first reference parameter in based on the light information to be adjusted and a preset gamma adjustment factor. (n-16) / 8 The second calculation module is used to construct and calculate the second baseline parameter level based on the preset number of levels and the preset gamma adjustment factor. (8-n) / 8 The third calculation module is used to calculate the optical information to be adjusted based on the first reference parameter, the second reference parameter, and the optical information to be adjusted, using the formula out = in. 2 ×in (n -16) / 8 ×level (8-n) / 8 Calculate optical correction information.
[0018] As an improvement to the above scheme, the first calculation module includes: an approximation calculation unit, used to calculate in -1 / 8An approximate value; an iterative optimization unit, used to optimize the value of in according to Newton's iteration method. -1 / 8 The approximate value is optimized to generate in -1 / 8 The optimized value; parameter calculation unit, used to calculate the value based on the in -1 / 8 The optimization value is calculated using the first baseline parameter in. (n-16) / 8 The value of .
[0019] As an improvement to the above scheme, the approximation calculation unit includes: a first definition subunit for defining a first variable of type float, which is a function parameter used to receive the light information to be adjusted; a second definition subunit for defining a second variable of type float, which stores the light information to be adjusted; a third definition subunit for defining a third variable of type long, performing an address-taking operation on the first variable, forcibly converting the address-taking result of the first variable to *(long*) type, and assigning the conversion result of the first variable to the third variable; a compensation subunit for right-shifting the value of the third variable by a preset number of bits, subtracting the right-shifted value of the third variable from the preset compensation number, and assigning the difference result to the third variable; and a conversion subunit for performing an address-taking operation on the third variable, forcibly converting the address-taking result of the third variable to *(float*) type, and assigning the conversion result of the third variable to the first variable. At this time, the value of the first variable is in. -1 / 8 Approximate value.
[0020] Accordingly, the present invention also provides a light-emitting device, including a control device for the light-emitting device described above.
[0021] Accordingly, the present invention also provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the steps of the control method for the light-emitting device described above.
[0022] Implementing this invention has the following beneficial effects:
[0023] This invention enables non-linear correction of light information (grayscale value, brightness value, or color temperature value) to be adjusted, so that the light information conforms to the visual characteristics of the human eye. Specifically:
[0024] This invention sacrifices the accuracy of the gamma value γ to construct a unique calculation formula and benchmark parameters in order to avoid the power function pow() called in the gamma correction algorithm and achieve nonlinear correction.
[0025] Meanwhile, this invention utilizes the format characteristics of floating-point numbers specified in the binary floating-point arithmetic standard (IEEE 754). A number is stored at a certain address in a 32-bit float type storage format. When it is read out in a 32-bit long type storage format, the read value has a "special correspondence" with the logarithm of that number. Therefore, by directly manipulating the "logarithm" of the number using a compensation number, an approximate value of the number to the power of -1 / 8 can be calculated. Then, Newton's iteration method is used to further approximate its accurate value, thereby realizing in -1 / 8 Its fast and efficient calculations improve the speed of the correction process. Attached Figure Description
[0026] Figure 1 This is a flowchart illustrating an embodiment of the control method for the light-emitting device of the present invention;
[0027] Figure 2 This is a schematic diagram of an embodiment of the control device for the light-emitting device of the present invention;
[0028] Figure 3 This is a schematic diagram of the structure of the first calculation module in the control device of the light-emitting device of the present invention. Detailed Implementation
[0029] To make the objectives, technical solutions, and advantages of the present invention clearer, the present invention will be further described in detail below with reference to the accompanying drawings.
[0030] See Figure 1 , Figure 1 A flowchart illustrating an embodiment of the control method for the light-emitting device of the present invention is shown, comprising:
[0031] S101, Obtain the light information to be adjusted from the light-emitting device;
[0032] It should be noted that the light information to be adjusted can be directly input by the user or collected by the sensor and then uploaded. Preferably, the light information to be adjusted can be a grayscale value, a brightness value, or a color temperature value, but this is not a limitation, and can be adjusted according to actual needs.
[0033] S102, based on the light information to be adjusted, using the formula out = in 2 ×in (n-16) / 8 ×level (8-n) / 8 Calculate optical correction information;
[0034] Where out is optical correction information, in is optical information to be adjusted, n is a preset gamma adjustment factor and n is a positive integer, and level is the preset number of levels;
[0035] Furthermore, step S102 includes:
[0036] S102-1, Construct and calculate the first reference parameter in based on the light information to be adjusted and the preset gamma adjustment factor. (n -16) / 8 ;
[0037] Unlike existing technologies, this invention does not utilize the gamma correction formula out = (in ÷ level) γ Instead of directly calculating ×level, it sacrifices the precision of the gamma value γ to construct a unique calculation formula and benchmark parameters, thereby avoiding the power function pow() called in the gamma correction algorithm, improving execution speed and reducing memory usage.
[0038] Specifically, the first reference parameter in is constructed and calculated based on the light information to be adjusted and the preset gamma adjustment factor. (n -16) / 8 The steps include:
[0039] (1) Calculate in -1 / 8 Approximate value;
[0040] Utilizing the floating-point number format characteristics specified in the IEEE 754 binary floating-point arithmetic standard, number A is stored at a certain address in 32-bit float type storage format. It is then read out in 32-bit long type storage format (i.e., pointer type casting) to obtain number B. Number B is right-shifted by M bits and calculated using a compensation factor. It is then read out again in 32-bit float type storage format (i.e., pointer type casting) to obtain number C. At this point, the value of number C is approximately (1 / 2) of number A. M Therefore, this invention takes M=3, uses 1 / 8 as the smallest γ adjustment unit, and introduces in -1 / 8 It is applicable to the vast majority of situations. Accordingly, calculating in... -1 / 8 The steps for approximating the value include:
[0041] (1.1) Define the first variable of type float;
[0042] The first variable is a 32-bit float type, which is a function parameter used to receive the light information to be adjusted.
[0043] (1.2) Define a second variable of type float;
[0044] The second variable is a 32-bit float type, which is used to store the light information to be adjusted.
[0045] (1.2) Define a third variable of type long, perform a address-taking operation on the first variable, force type conversion of the address-taking result of the first variable to type *(long*), and assign the conversion result of the first variable to the third variable;
[0046] The third variable is a 32-bit long type.
[0047] (1.4) Shift the value of the third variable to the right by a preset number of positions, subtract the value of the third variable after shifting by a preset compensation number, and assign the difference to the third variable;
[0048] Preferably, the preset number of bits is 3 bits, and the compensation number is between 0x40000000 and 0x50000000, but this is not a limitation.
[0049] (1.5) Perform a fetch operation on the third variable, force the type of the fetch result of the third variable to be converted to the *(float*) type, and assign the conversion result of the third variable to the first variable;
[0050] It should be noted that the value of the first variable after assignment in step (1.5) is an approximation of the negative eighth power of the input light information to be adjusted, i.e., in -1 / 8 Approximate value.
[0051] (2) Based on Newton's iteration method, in -1 / 8 The approximate value is optimized to generate in -1 / 8 The optimized value;
[0052] Specifically, based on Newton's iteration method, for in -1 / 8 The approximate value is optimized to generate in -1 / 8 The steps for optimizing the value include:
[0053] (2.1) Construct a function f(y) = (1 / y) with y as the independent variable. 8 If -x = 0, then f'(y) = -8y -9 ;
[0054] Newton's iterative formula is: X n+1 =X n -f(x n ) / f'(x n );
[0055] Because the optimization objective is in -1 / 8 For a number raised to the power of negative 1 / 8, i.e., y = x -1 / 8 Then 1 / y 8 =x; therefore, we can construct a function f(y) = (1 / y) with y as the independent variable. 8 If -x = 0, then f'(y) = -8y -9 .
[0056] (2.2) Let f(y) = (1 / y 8 f'(y) = -8y -9Substituting into Newton's iteration formula and simplifying, we get: y - (f(y) / f'(y)) = (9y / 8) - (xy) 9 / 8);
[0057] (2.3) In -1 / 8 Substituting the approximate value into the formula y-(f(y) / f'(y))=(9y / 8)-(xy) 9 / 8) Perform iterative processing to generate in -1 / 8 The optimized value.
[0058] It should be noted that, thanks to finding in -1 / 8 An approximation of the value can be obtained by simply adding in -1 / 8 Substituting the approximate value into the simplified formula y-(f(y) / f'(y))=(9y / 8)-(xy) 9 / 8) Iteration 1 to 2 times is sufficient to meet the accuracy required for commonly used grade number correction.
[0059] As can be seen from the above, this invention utilizes the format characteristics of floating-point numbers specified in the binary floating-point arithmetic standard (IEEE 754). A number is stored at a certain address in a 32-bit float type storage format. When it is read out in a 32-bit long type storage format, the read value has a "special correspondence" with the logarithm of that number. Therefore, by directly manipulating the "logarithm" of the number using a compensation number, an approximate value of the number to the power of -1 / 8 can be calculated. Then, Newton's iteration method is used to further approximate its accurate value, thereby realizing the in -1 / 8 Its fast and efficient calculations improve the speed of the correction process.
[0060] (3) According to in -1 / 8 The optimization value is calculated using the first baseline parameter in. (n-16) / 8 The value of .
[0061] S102-2, Construct and calculate the second baseline parameter level based on the preset number of levels and the preset gamma adjustment factor. (8 -n) / 8 ;
[0062] Where level is the preset number of levels; for example, if the brightness level of the light-emitting device is 100 levels, then the value of level is 100.
[0063] S102-3, based on the first reference parameter, the second reference parameter, and the light information to be adjusted, the formula out = in is used to... 2 ×in (n-16) / 8 ×level (8-n) / 8 Calculate optical correction information;
[0064] It should be noted that the traditional gamma correction formula is: out = (in ÷ level)γ ×level, assuming γ = n / 8, the gamma correction algorithm can be simplified to: out = in 2 ×in (n-16) / 8 ×level (8-n) / 8 In this case, γ≈2.2 is usually taken, that is, n=18.
[0065] In other words, in is calculated using step S102-1 -1 / 8 Calculate in (n-16) / 8 And calculate level using step S102-2. (8-n) / 8 , then in (n-16) / 8 and level (8-n) / 8 Substituting into the simplified formula out = in 2 ×in (n-16) / 8 ×level (8-n) / 8 This allows us to calculate the optical correction information.
[0066] Therefore, through steps S102-1 to S102-3, the floating-point division, exponentiation, and floating-point multiplication operations of the original correction formula can be converted into simple pointer operations, type casting operations, bitwise operations, and floating-point multiplication / division operations, which greatly increases the efficiency of the calculation.
[0067] S103, adjust the light output information of the light-emitting device to match the light correction information.
[0068] For example, if the calculated corrected brightness (i.e., light correction information) is 100 during the adjustment process, then the brightness of the light-emitting device is adjusted to 100.
[0069] As can be seen from the above, the present invention can perform non-linear correction on the light information (grayscale value, brightness value or color temperature value) to be adjusted, so that the light information to be adjusted conforms to the visual characteristics of the human eye.
[0070] See Figure 2 , Figure 2 The specific structure of the control device 100 for the light-emitting device of the present invention is shown, which includes:
[0071] The acquisition module 1 is used to acquire the light information to be adjusted from the light-emitting device. Preferably, the light information to be adjusted from the light-emitting device can be acquired by a sensor and uploaded to the acquisition module 1; alternatively, the user can input the light information to be adjusted from the light-emitting device through an input device and upload it to the acquisition module 1. Preferably, the light information to be adjusted can be a grayscale value, a brightness value, or a color temperature value, but it is not limited to these and can be adjusted according to actual needs.
[0072] Calculation module 2 is used to calculate the light information to be adjusted using the formula out = in. 2 ×in(n-16) / 8 ×level (8 -n) / 8 Calculate optical correction information; where out is the optical correction information, in is the optical information to be adjusted, n is the preset gamma adjustment factor and n is a positive integer, and level is the preset number of levels;
[0073] Adjustment module 3 is used to adjust the light output information of the light-emitting device to be consistent with the light correction information; for example, if the calculated correction brightness (i.e., light correction information) is 100 during the adjustment process, then the brightness of the light-emitting device is adjusted to 100.
[0074] Furthermore, the calculation module 2 includes a first calculation module 21, a second calculation module 22, and a third calculation module 23, wherein:
[0075] The first calculation module 21 is used to construct and calculate the first reference parameter in based on the light information to be adjusted and the preset gamma adjustment factor. (n-16) / 8 Wherein is the light information to be adjusted, and n is the preset gamma adjustment factor and n is a positive integer;
[0076] The second calculation module 22 is used to construct and calculate the second benchmark parameter level based on the preset number of levels and the preset gamma adjustment factor. (8-n) / 8 Where level is the preset number of brightness levels; for example, if the brightness level of the light-emitting device is 100, then the value of level is 100. (8-n) / 8 It is a constant, and the result can be calculated in advance and used directly in the program.
[0077] The third calculation module 23 is used to calculate the light information to be adjusted based on the first reference parameter, the second reference parameter, and the light information to be adjusted, using the formula out = in. 2 ×in (n-16) / 8 ×level (8-n) / 8 Calculate optical correction information; it should be noted that the gamma correction algorithm is: out = (in ÷ level) γ ×level, assuming γ = n / 8, the gamma correction algorithm can be simplified to: out = in 2 ×in (n-16) / 8 ×level (8-n) / 8 In this case, γ is usually taken to be approximately 2.2, i.e., n = 18; that is, in (n-16) / 8 and level (8-n) / 8 Substituting into the simplified formula out = in 2 ×in (n-16) / 8 ×level (8-n) / 8 This allows us to calculate the optical correction information.
[0078] Unlike existing technologies, this invention does not utilize the gamma correction algorithm out = (in ÷ level). γ Instead of directly calculating ×level, it sacrifices the precision of the gamma value γ to construct a unique calculation formula and benchmark parameters, thereby avoiding the power function pow() called in the gamma correction algorithm, in order to improve execution speed and reduce memory usage.
[0079] As can be seen from the above, the present invention can perform non-linear correction on the light information (grayscale value, brightness value or color temperature value) to be adjusted, so that the light information to be adjusted conforms to the visual characteristics of the human eye.
[0080] like Figure 3 As shown, the first calculation module 21 includes an approximation calculation unit 211, an iterative optimization unit 212, and a parameter calculation unit 213, specifically:
[0081] Approximate value calculation unit 211 is used to calculate in -1 / 8 Approximate value;
[0082] Iterative optimization unit 212 is used to optimize in according to Newton's iteration method. -1 / 8 The approximate value is optimized to generate in -1 / 8 The optimized value;
[0083] Parameter calculation unit 213 is used to calculate parameters based on in -1 / 8 The optimization value is calculated using the first baseline parameter in. (n-16) / 8 The value of .
[0084] Furthermore, the approximation calculation unit 211 includes:
[0085] The first definition subunit 2111 is used to define a first variable of type float. The first variable is a function parameter used to receive the light information to be adjusted. The first variable is of type 32 float.
[0086] The second definition subunit 2112 is used to define a second variable of type float; the second variable is of type 32 float and is used to store the light information to be adjusted.
[0087] The third definition subunit 2113 is used to define a third variable of type long. It performs an address-taking operation on the first variable, forcibly converts the address-taking result of the first variable to type *(long*), and assigns the conversion result of the first variable to the third variable. The third variable is of type 32-bit long.
[0088] The compensation subunit 2114 is used to right-shift the value of the third variable by a preset number of bits, subtract the right-shifted value of the third variable from the preset compensation number, and assign the difference result to the third variable; preferably, the preset number of bits is 3 bits, and the compensation number is between 0x40000000 and 0x50000000, but is not limited thereto.
[0089] The conversion subunit 2115 is used to perform a address-taking operation on the third variable, forcibly converting the address-taking result of the third variable to the *(float*) type, and assigning the conversion result of the third variable to the first variable. At this time, the value of the first variable is in. -1 / 8 The approximate value; the value of the first variable after assignment is an approximate value of the negative eighth power of the input light information to be adjusted, i.e., in -1 / 8 Approximate value.
[0090] Therefore, by using the approximation calculation unit 211, the floating-point division, exponentiation and floating-point multiplication operations of the original correction formula can be converted into simple pointer operations, type casting operations, bit operations and floating-point multiplication / division operations, which greatly increases the efficiency of the operation.
[0091] In addition, the iterative optimization unit 212 includes:
[0092] Function building subunit 2121 is used to construct the function f(y) = (1 / y) with y as the independent variable. 8 If -x = 0, then f'(y) = -8y -9 It should be noted that Newton's iteration formula is: X n+1 =X n -f(x n ) / f'(x n ); due to the optimization objective in -1 / 8 For a number raised to the power of negative 1 / 8, i.e., y = x -1 / 8 Then 1 / y 8 =x; therefore, we can construct a function f(y) = (1 / y) with y as the independent variable. 8 If -x = 0, then f'(y) = -8y -9 .
[0093] Simplified subunit 2122 is used to convert f(y) = (1 / y 8 f'(y) = -8y -9 Substituting into Newton's iteration formula and simplifying, we get: y - (f(y) / f'(y)) = (9y / 8) - (xy) 9 / 8);
[0094] Iterative subunit 2123 is used to transfer in -1 / 8Substituting the approximate value into the formula y-(f(y) / f'(y))=(9y / 8)-(xy) 9 / 8) Perform iterative processing to generate in -1 / 8 The optimized value.
[0095] It should be noted that, thanks to finding in -1 / 8 An approximation of the value can be obtained by simply adding in -1 / 8 Substituting the approximate value into the simplified formula y-(f(y) / f'(y))=(9y / 8)-(xy) 9 / 8) Iterations of 1-2 times are sufficient to approximate in -1 / 8 The accurate value is thus obtained to meet the accuracy required for common grade number corrections.
[0096] As can be seen from the above, the calculation module 2 of this invention utilizes the format characteristics of floating-point numbers specified in the binary floating-point arithmetic standard (IEEE 754). A number is stored at a certain address in a 32-bit float type storage format. When it is read out in a 32-bit long type storage format, the read value has a "special correspondence" with the logarithm of the number. Therefore, by directly manipulating the "logarithm" of the number in combination with the compensation number, an approximate value of the number to the power of -1 / 8 can be calculated. Then, the Newton iteration method is used to further approximate its accurate value, thereby realizing the in -1 / 8 Its fast and efficient calculations improve the speed of the correction process.
[0097] Accordingly, the present invention also discloses a light-emitting device, which includes a control device 100 for the aforementioned light-emitting device, the control device 100 being disposed within the light-emitting device. It should be noted that the light-emitting device can be an illumination device, such as an LED light, and of course, it can also be a display screen, etc., and the present invention does not limit this. Simultaneously, the present invention also discloses a computer-readable storage medium storing a computer program thereon, wherein the computer program, when executed by a processor, implements the steps of the aforementioned control method for the light-emitting device.
[0098] The above description represents the preferred embodiments of the present invention. It should be noted that those skilled in the art can make various improvements and modifications without departing from the principles of the present invention, and these improvements and modifications are also considered to be within the scope of protection of the present invention.
Claims
1. A method for controlling a light-emitting device, characterized in that, include: Acquire the light information to be adjusted from the light-emitting device; Based on the light information to be adjusted, the formula out=in is used. 2 ×in (n-16) / 8 ×level (8-n) / 8 Calculate the optical correction information, where out is the optical correction information, in is the optical information to be adjusted, n is the preset gamma adjustment factor and n is a positive integer, and level is the preset number of levels; Adjust the light output information of the light-emitting device to be consistent with the light correction information; Using the formula out=in 2 ×in (n-16) / 8 ×level (8-n) / 8 The steps for calculating optical correction information include: constructing and calculating a first reference parameter in based on the optical information to be adjusted and a preset gamma adjustment factor. (n-16) / 8 The second baseline parameter, level, is constructed and calculated based on the preset number of levels and the preset gamma adjustment factor. (8-n) / 8 Based on the first reference parameter, the second reference parameter, and the light information to be adjusted, the formula out=in is used. 2 ×in (n-16) / 8 ×level (8-n) / 8 Calculate optical correction information.
2. The control method for the light-emitting device as described in claim 1, characterized in that, The first reference parameter in is constructed and calculated based on the light information to be adjusted and the preset gamma modulation factor. (n-16) / 8 The steps include: Calculate in -1 / 8 Approximate value; According to Newton's iteration method, the in -1 / 8 The approximate value is optimized to generate in -1 / 8 The optimized value; According to the in -1 / 8 The optimization value is calculated using the first baseline parameter in. (n-16) / 8 The value of .
3. The control method for the light-emitting device as described in claim 2, characterized in that, The calculation in -1 / 8 The steps for approximating the value include: S1. Define a first variable of type float, which is a function parameter used to receive the light information to be adjusted; Define a second variable of type float, which is used to store the light information to be adjusted; Define a third variable of type long, take the address of the first variable, cast the address of the first variable to type *(long*), and assign the cast result of the first variable to the third variable; S2. Shift the value of the third variable to the right by a preset number of positions, subtract the value of the third variable after the right shift using a preset compensation number, and assign the difference result to the third variable. S3. Perform a address-taking operation on the third variable, forcibly convert the address-taking result of the third variable to a *(float*) type, and assign the conversion result of the third variable to the first variable. At this time, the value of the first variable is in. -1 / 8 Approximate value.
4. The control method for the light-emitting device as described in claim 3, characterized in that, The first and second variables are 32-bit float types, the third variable is a 32-bit long type, and the preset number of bits is 3.
5. The control method for the light-emitting device as described in claim 2, characterized in that, The method based on Newton's iterations is used to analyze the in. -1 / 8 The approximate value is optimized to generate in -1 / 8 The steps for optimizing the value include: Construct a function f(y) = (1 / y) with y as the independent variable. 8 If -x = 0, then f'(y) = -8y -9 ; f(y) = (1 / y) 8 f'(y) = -8y -9 Substituting into Newton's iterative formula, we get y - (f(y) / f'(y)) = (9y / 8) - (xy) 9 / 8); The in -1 / 8 Substituting the approximate value into the formula y-(f(y) / f'(y))=(9y / 8)-(xy) 9 / 8) Perform iterative processing to generate the in -1 / 8 The optimized value.
6. The control method for the light-emitting device according to any one of claims 1-5, characterized in that, The light information to be adjusted includes grayscale value, brightness value, or color temperature value.
7. A control device for a light-emitting device, characterized in that, include: The acquisition module is used to acquire the light information to be adjusted from the light-emitting device; The calculation module is used to calculate the light information to be adjusted using the formula out=in. 2 ×in (n-16) / 8 ×level (8-n) / 8 Calculate the optical correction information, where out is the optical correction information, in is the optical information to be adjusted, n is the preset gamma adjustment factor and n is a positive integer, and level is the preset number of levels; The adjustment module is used to adjust the light output information of the light-emitting device to be consistent with the light correction information; The calculation module includes: a first calculation module, used to construct and calculate a first reference parameter in based on the light information to be adjusted and a preset gamma adjustment factor. (n-16) / 8 The second calculation module is used to construct and calculate the second baseline parameter level based on the preset number of levels and the preset gamma adjustment factor. (8-n) / 8 The third calculation module is used to calculate the optical information to be adjusted, the first reference parameter, and the second reference parameter using the formula out=in. 2 ×in (n-16) / 8 ×level (8-n) / 8 Calculate optical correction information.
8. The control device for the light-emitting device as described in claim 7, characterized in that, The first computing module includes: Approximate value calculation unit, used to calculate in -1 / 8 Approximate value; Iterative optimization unit, used to optimize the in according to Newton's iteration method -1 / 8 The approximate value is optimized to generate in -1 / 8 The optimized value; Parameter calculation unit, used to calculate the parameter based on the in -1 / 8 The optimization value is calculated using the first baseline parameter in. (n-16) / 8 The value of .
9. The control device for the light-emitting device as described in claim 8, characterized in that, The approximation calculation unit includes: The first definition subunit is used to define a first variable of type float, which is a function parameter used to receive the light information to be adjusted; The second definition subunit is used to define a second variable of type float, which is used to store the light information to be adjusted. The third definition subunit is used to define a third variable of type long, perform a address-taking operation on the first variable, forcibly convert the address-taking result of the first variable to type *(long*), and assign the conversion result of the first variable to the third variable; The compensation subunit is used to right-shift the value of the third variable by a preset number of bits, subtract the right-shifted value of the third variable from the preset compensation number, and assign the difference result to the third variable. The conversion subunit is used to perform an address-taking operation on the third variable, forcibly converting the address-taking result of the third variable to a *(float*) type, and assigning the conversion result of the third variable to the first variable. At this time, the value of the first variable is in. -1 / 8 Approximate value.
10. A light-emitting device, characterized in that, The control device includes the light-emitting device according to any one of claims 7 to 9.
11. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Image gamma correction method and device
CN106960419A
Variable precision floating point function implementation method based on index approximation
CN114723026A