Hardware accelerator, method, device and storage medium for color space conversion

Through a hardware accelerator combined with multiple linear transformations and non-linear transformations, RGB image data is directly converted into LAB image data, which solves the problem of long CPU processing time and achieves high frame rate image processing efficiency.

CN118823142APending Publication Date: 2024-10-22AXERA SEMICON (SHANGHAI) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410800876.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-19
Publication Date
2024-10-22

AI Technical Summary

Technical Problem

Converting RGB image data to LAB image data based on the CPU takes a long time, resulting in low conversion efficiency and inability to achieve high frame rate processing.

Method used

Design a hardware accelerator that converts RGB image data into LAB image data through multiple linear transformations and nonlinear transformations without CPU processing. It uses lookup tables and linear transformation matrices for data processing to improve conversion efficiency.

Benefits of technology

It achieves efficient conversion of RGB image data into LAB image data, solves the problem of long CPU processing time, and improves the frame rate of image processing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118823142A_ABST
    Figure CN118823142A_ABST
Patent Text Reader

Abstract

The invention provides a hardware accelerator, method and device for color space conversion and a storage medium, and the hardware accelerator comprises a first transformation module which is used for processing RGB image data based on a first linear transformation matrix and a second linear transformation matrix to obtain first intermediate image data; the second transformation module is used for processing the first intermediate image data based on a first nonlinear function to obtain a first search result corresponding to the first intermediate image data; the first transformation module is also used for acquiring a first search result, and processing the first search result based on the third linear transformation matrix and the fourth linear transformation matrix to obtain second intermediate image data; the second conversion module is also used for acquiring second intermediate image data to obtain a second search result corresponding to the second intermediate image data; and the first conversion module is also used for obtaining LAB image data. According to the technical scheme, the efficiency of converting the RGB image data into the LAB image data can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of image processing technology, and in particular to a hardware accelerator, method, device and storage medium for color space conversion. Background Art

[0002] Since converting RGB (Red Green Blue, red, green and blue color space) to LAB (CIELAB, standard color mode) color space can bring the integrity of the color space, stability independent of equipment and light, optimization of processing speed and color loss, balance of transition colors, flexibility in editing and conversion, and application advantages in high-end equipment and professional fields, it is often necessary to convert RGB images into LAB images during image processing.

[0003] In order to solve the above technical problems, in the related art, RGB image data is converted into LAB image data based on a CPU (Central Processing Unit, referred to as a central processing unit in Chinese).

[0004] However, in the above method, since the RGB image is large, it is very time-consuming to convert the RGB image data into LAB image data based on the CPU, resulting in low conversion efficiency and thus failure to perform high frame rate conversion. Summary of the invention

[0005] The embodiment of the present application provides a hardware accelerator, method, device and storage medium for color space conversion, which can improve the efficiency of converting RGB image data into LAB image data, and thus can perform high frame rate image processing. The technical solution is as follows:

[0006] According to a first aspect of an embodiment of the present application, a hardware accelerator for color space conversion is provided, the hardware accelerator comprising:

[0007] A first conversion module and a second conversion module electrically connected to each other;

[0008] The first transformation module is used to obtain RGB image data; process the RGB image data based on the first linear transformation matrix and the second linear transformation matrix to obtain first intermediate image data;

[0009] The second transformation module is used to obtain the first intermediate image data; process the first intermediate image data based on a first nonlinear function to obtain a first calculated value, and search a first lookup table based on the first calculated value to obtain a first search result corresponding to the first intermediate image data;

[0010] The first transformation module is further used to obtain the first search result, process the first search result based on the third linear transformation matrix and the fourth linear transformation matrix, and obtain second intermediate image data;

[0011] The second transformation module is further used to obtain the second intermediate image data; process the second intermediate image data based on a second nonlinear function to obtain a second calculated value, and search a second lookup table based on the second calculated value to obtain a second search result corresponding to the second intermediate image data;

[0012] The first transformation module is further used to process the second search result based on the fifth linear transformation matrix and the sixth linear transformation matrix to obtain LAB image data.

[0013] In some possible implementations, the first lookup table includes multiple first arrays, each of the first arrays includes a first lookup value and a first mapping value corresponding to the first lookup value, and the difference between two adjacent first lookup values ​​is negatively correlated with the slope of the first nonlinear function; the first calculated value is used to find the first lookup value in each of the first arrays.

[0014] In some possible implementations, the processing the RGB image data based on the first linear transformation matrix and the second linear transformation matrix to obtain the first intermediate image data includes:

[0015] The first transformation module is used to obtain a linear function, and based on the linear function, obtain the product of the first linear transformation matrix and the RGB image data;

[0016] The first transformation module is further used to obtain the first intermediate image data based on the product of the first linear transformation matrix and the RGB image data and the sum of the second linear transformation matrix.

[0017] In some possible implementations, searching a first lookup table based on the first calculated value to obtain a first search result corresponding to the first intermediate image data includes:

[0018] The first transformation module is used to search the first lookup table based on the first calculated value to obtain the first lookup value adjacent to the first calculated value;

[0019] The first transformation module is further used to obtain the first mapping value corresponding to each first search value based on the first search table; and perform interpolation calculation on each first mapping value to obtain the first search result.

[0020] In some possible implementations, the processing the first search result based on the third linear transformation matrix and the fourth linear transformation matrix to obtain the second intermediate image data includes:

[0021] The first transformation module is further used to obtain the linear function, and based on the linear function, obtain the product of the third linear transformation matrix and the first search result;

[0022] The second intermediate image data is obtained based on the product of the third linear transformation matrix and the first search result and the sum of the fourth linear transformation matrix.

[0023] In some possible implementations, the second lookup table includes multiple second arrays, each of the second arrays includes a second lookup value and a second mapping value corresponding to the second lookup value, and the difference between two adjacent second lookup values ​​is negatively correlated with the slope of the second nonlinear function; the second calculated value is used to find the second lookup value in each of the second arrays.

[0024] In some possible implementations, searching a second lookup table based on the second calculated value to obtain a second search result corresponding to the second intermediate image data includes:

[0025] The second transformation module is further used to search the second lookup table based on the second calculated value to obtain the second lookup value adjacent to the second calculated value;

[0026] Based on the second lookup table, the second mapping value corresponding to each second lookup value is obtained; and interpolation calculation is performed on each second mapping value to obtain the second lookup result.

[0027] In some possible implementations, the second search result is calculated based on the fifth linear transformation matrix and the sixth linear transformation matrix to obtain LAB image data, including:

[0028] The first transformation module is further used to obtain the linear function, and based on the linear function, obtain the product of the fifth linear transformation matrix and the second search result;

[0029] The LAB image data is obtained based on the product of the fifth linear transformation matrix and the second search result and the sum of the sixth linear transformation matrix.

[0030] In some possible implementations, the hardware accelerator is electrically connected to the OCM module;

[0031] The OCM module is used to store the first intermediate image data, the first calculated value, the first mapping value, the second intermediate image data, the second mapping value and the LAB image data.

[0032] In some possible implementations, the first transformation module is a CCM module, and the second transformation module is a DRC module.

[0033] According to a second aspect of an embodiment of the present application, a method for color space conversion is provided, comprising:

[0034] Acquire RGB image data; process the RGB image data based on the first linear transformation matrix and the second linear transformation matrix to obtain first intermediate image data;

[0035] Acquire the first intermediate image data; process the first intermediate image data based on a first nonlinear function to obtain a first calculated value, and search a first lookup table based on the first calculated value to obtain a first search result corresponding to the first intermediate image data;

[0036] Acquire the first search result, and process the first search result based on the third linear transformation matrix and the fourth linear transformation matrix to obtain second intermediate image data;

[0037] Acquire the second intermediate image data; process the second intermediate image data based on a second nonlinear function to obtain a second calculated value, and search a second lookup table based on the second calculated value to obtain a second search result corresponding to the second intermediate image data;

[0038] The second search result is processed based on the fifth linear transformation matrix and the sixth linear transformation matrix to obtain LAB image data.

[0039] In some possible implementations, the first lookup table includes multiple first arrays, each of the first arrays includes a first lookup value and a first mapping value corresponding to the first lookup value, and the difference between two adjacent first lookup values ​​is negatively correlated with the slope of the first nonlinear function; the first calculated value is used to find the first lookup value in each of the first arrays.

[0040] In some possible implementations, the processing the RGB image data based on the first linear transformation matrix and the second linear transformation matrix to obtain the first intermediate image data includes:

[0041] Obtain a linear function, and based on the linear function, obtain the product of the first linear transformation matrix and the RGB image data;

[0042] The first intermediate image data is obtained based on the product of the first linear transformation matrix and the RGB image data and the sum of the second linear transformation matrix.

[0043] In some possible implementations, searching a first lookup table based on the first calculated value to obtain a first search result corresponding to the first intermediate image data includes:

[0044] Searching the first lookup table based on the first calculated value to obtain the first lookup value adjacent to the first calculated value;

[0045] Based on the first lookup table, the first mapping value corresponding to each first lookup value is obtained; and interpolation calculation is performed on each first mapping value to obtain the first lookup result.

[0046] In some possible implementations, the processing the first search result based on the third linear transformation matrix and the fourth linear transformation matrix to obtain the second intermediate image data includes:

[0047] Obtain the linear function, and based on the linear function, obtain the product of the third linear transformation matrix and the first search result;

[0048] The second intermediate image data is obtained based on the product of the third linear transformation matrix and the first search result and the sum of the fourth linear transformation matrix.

[0049] In some possible implementations, the second lookup table includes multiple second arrays, each of the second arrays includes a second lookup value and a second mapping value corresponding to the second lookup value, and the difference between two adjacent second lookup values ​​is negatively correlated with the slope of the second nonlinear function; the second calculated value is used to find the second lookup value in each of the second arrays.

[0050] In some possible implementations, searching a second lookup table based on the second calculated value to obtain a second search result corresponding to the second intermediate image data includes:

[0051] Searching the second lookup table based on the second calculated value to obtain the second lookup value adjacent to the second calculated value;

[0052] Based on the second lookup table, the second mapping value corresponding to each second lookup value is obtained; and interpolation calculation is performed on each second mapping value to obtain the second lookup result.

[0053] In some possible implementations, the second search result is calculated based on the fifth linear transformation matrix and the sixth linear transformation matrix to obtain LAB image data, including:

[0054] Obtain the linear function, and based on the linear function, obtain the product of the fifth linear transformation matrix and the second search result;

[0055] The LAB image data is obtained based on the product of the fifth linear transformation matrix and the second search result and the sum of the sixth linear transformation matrix.

[0056] In some possible implementations, the method further includes:

[0057] The first intermediate image data, the first calculated value, the first mapped value, the second intermediate image data, the second mapped value and the LAB image data are stored in an OCM module.

[0058] According to a third aspect of an embodiment of the present application, a computer device is provided, comprising a processor and a memory, wherein the memory is used to store at least one program, and the at least one program is loaded by the processor and executes the method for color space conversion as described above.

[0059] According to a fourth aspect of an embodiment of the present application, a computer-readable storage medium is provided, in which at least one program is stored. The at least one program is loaded and executed by a processor to implement the above-mentioned method for color space conversion.

[0060] In an embodiment of the present application, an embodiment of the present application provides a hardware accelerator for color space conversion. The hardware accelerator converts RGB image data into LAB image data by combining multiple linear transformations and nonlinear transformations. There is no need for the CPU to process the RGB image, thereby solving the problem of the CPU consuming a long time to convert RGB image data into LAB image data, thereby improving the efficiency of converting RGB image data into LAB image data and realizing high frame rate image processing. BRIEF DESCRIPTION OF THE DRAWINGS

[0061] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0062] Figure 1 is a schematic diagram of an implementation environment provided according to an embodiment of the present application;

[0063] Figure 2 is a structural schematic diagram of a hardware accelerator for color space conversion provided according to an embodiment of the present application;

[0064] Figure 3 It is a flowchart of a method for a hardware accelerator for color space conversion provided according to an embodiment of the present application;

[0065] Figure 4 is a schematic diagram of the structure of a terminal provided according to an embodiment of the present application;

[0066] Figure 5 It is a structural diagram of a server provided according to an embodiment of the present application. DETAILED DESCRIPTION

[0067] In order to make the objectives, technical solutions and advantages of the present application clearer, the implementation methods of the present application will be further described in detail below with reference to the accompanying drawings.

[0068] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.

[0069] In this application, the terms "first", "second", etc. are used to distinguish between identical or similar items with substantially the same effects and functions. It should be understood that there is no logical or temporal dependency between "first", "second", and "nth", nor is there a limitation on the quantity and execution order. It should also be understood that although the following description uses the terms first, second, etc. to describe various elements, these elements should not be limited by the terms.

[0070] These terms are only used to distinguish one element from another element. For example, without departing from the scope of various examples, a first action can be referred to as a second action, and similarly, a second action can also be referred to as a first action. Both the first action and the second action can be actions, and in some cases, can be separate and different actions.

[0071] Here, at least one means one or more than one, for example, at least one action can be one action, two actions, three actions, or any other action that is an integer greater than or equal to one. And multiple means two or more than two, for example, multiple actions can be two actions, three actions, or any other action that is an integer greater than or equal to two.

[0072] Figure 1 It is a schematic diagram of an implementation environment provided according to an embodiment of the present application, and the implementation environment may include a terminal 101 and a server 102.

[0073] In the terminal 101, a hardware accelerator for color space conversion is provided.

[0074] The terminal 101 may be a smart phone with a hardware accelerator for color space conversion, a wearable device, a personal computer, a laptop, a tablet computer, a smart TV, a car terminal, etc.

[0075] The server 102 may be a single server, a server cluster consisting of multiple servers, or a cloud processing center.

[0076] The terminal 101 is connected to the server 102 via a wired or wireless network.

[0077] In some embodiments, the wireless network or wired network uses standard communication technology and / or protocol. The network is usually the Internet, but it can also be any network, including but not limited to any combination of local area network (LAN), metropolitan area network (MAN), wide area network (WAN), mobile, wired or wireless network, private network or virtual private network. In some embodiments, the data exchanged through the network is represented by technology and / or format including HyperText Mark-up Language (HTML), Extensible Markup Language (XML), etc. In addition, conventional encryption technologies such as Secure Socket Layer (SSL), Transport Layer Security (TLS), Virtual Private Network (VPN), Internet Protocol Security (IPsec) can also be used to encrypt all or some links. In other embodiments, customized and / or dedicated data communication technology can also be used to replace or supplement the above data communication technology.

[0078] Figure 2 is a structural diagram of a hardware accelerator 200 for color space conversion provided according to an embodiment of the present application, the device comprising:

[0079] The first transformation module 201 and the first transformation module 202 are electrically connected to each other.

[0080] It can be understood that the hardware accelerator is electrically connected to the CPU, and the CPU configures the first transformation module 201 and the first transformation module 202 in the hardware accelerator based on preset parameters.

[0081] For example, the preset parameters may include a first linear transformation matrix, a second linear transformation matrix, a third linear transformation matrix, a fourth linear transformation matrix, a fifth linear transformation matrix, a sixth linear transformation matrix, a linear function, a first nonlinear function, and a second nonlinear function, etc.

[0082] For example, the hardware accelerator may include at least one register, and the CPU configures each register based on preset parameters.

[0083] The first transformation module 201 can be used to respond to the instructions of the CPU, obtain the preset parameters in the corresponding register, and process the RGB image data based on the preset parameters. The second transformation module 202 can be used to respond to the instructions of the CPU, obtain the preset parameters in the corresponding register, and process the RGB image data based on the preset parameters.

[0084] In some embodiments, the first transformation module 201 is used to obtain RGB image data; process the RGB image data based on the first linear transformation matrix and the second linear transformation matrix to obtain first intermediate image data.

[0085] It can be understood that ISP (Image Signal Processing) obtains RGB image data from the image sensor and stores the RGB image data in the memory.

[0086] In some embodiments, the hardware accelerator is electrically connected to an OCM (On-Chip Memory) module.

[0087] The OCM module is used to store data generated by the hardware accelerator in the process of converting RGB image data into LAB image data.

[0088] For example, the OCM module may be used to store the first intermediate image data, the first calculated value, the first mapping value, the second intermediate image data, the second mapping value, and the LAB image data.

[0089] It can be understood that the OCM module is also electrically connected to the CPU. The OCM module obtains RGB image data from the memory in response to the instructions of the CPU. The first transformation module 201 obtains RGB image data from the OCM module in response to the instructions of the CPU.

[0090] In the embodiment of the present application, the data generated by the hardware accelerator in the process of converting RGB image data into LAB image data is stored in the OCM module, and the required data is obtained from the OCM module, which fully utilizes the advantage of the OCM module having a large data bandwidth without occupying memory resources, thereby reducing the delay of data transmission and improving the conversion efficiency.

[0091] In some embodiments, the RGB image data is processed based on the first linear transformation matrix and the second linear transformation matrix to obtain the first intermediate image data, including: the first transformation module 201 is used to obtain a linear function, and based on the linear function, obtain the product of the first linear transformation matrix and the RGB image data.

[0092] The first transformation module 201 is further used to obtain the first intermediate image data based on the product of the first linear transformation matrix and the RGB image data and the sum of the second linear transformation matrix.

[0093] Among them, the linear function may be Y=k×A+b, the first linear transformation matrix may be a 3×3 matrix, the second linear transformation matrix may be a 3×1 matrix, and the RGB image data may be 3-channel data.

[0094] k and b can be floating point numbers, and the value range of Y and A can be (0, 65535). That is, the first conversion module 201 can convert the floating point RGB image data into fixed point numbers, and the value range of the fixed point numbers is (0, 65535).

[0095] For example: RGB image data can be represented as:

[0096]

[0097] In the above formula, sR represents the red channel, sG represents the green channel, and sB represents the blue channel.

[0098] It can be understood that, for ease of description, the first linear transformation matrix can be represented by Q, and the product of the first linear transformation matrix and the RGB image data can be represented by: Q×RGB image data. The second linear transformation matrix can be represented by Z, and the first intermediate image data can be represented by Y, then Y=Q×RGB image data+Z.

[0099] For example, Q can be expressed as:

[0100]

[0101] It should be noted that Q can be obtained based on a preset.

[0102] Z can be 0, that is,

[0103] In some embodiments, the first transformation module 202 is used to obtain the first intermediate image data; process the first intermediate image data based on a first nonlinear function to obtain a first calculated value, and search a first lookup table based on the first calculated value to obtain a first search result corresponding to the first intermediate image data.

[0104] The first lookup table may be a LUT (Look-Up-Table, color lookup table).

[0105] For example, the first nonlinear function may be:

[0106]

[0107] In the above formula, T∈(0,65535); G(T)∈(0,65535); G(T) is The mapping of discrete sampling points in the value range of (0, 65535) can be understood as the second search value.

[0108] It can be obtained based on the following formula:

[0109]

[0110] It can be understood that by substituting Y into the first nonlinear function, the first calculated value can be expressed as

[0111]

[0112] In some embodiments, searching a first lookup table based on the first calculated value to obtain a first search result corresponding to the first intermediate image data includes:

[0113] The first transformation module 201 is used to search the first lookup table based on the first calculated value to obtain the first lookup value adjacent to the first calculated value.

[0114] The first transformation module 201 is further used to obtain the first mapping value corresponding to each first search value based on the first search table; and perform interpolation calculation on each first mapping value to obtain the first search result.

[0115] For example, the value range of the first search value is (0, 1).

[0116] Among them, it can be based on Search the first lookup table, if it finds a value equal to The value of Get the corresponding first mapping value.

[0117] In addition, based on Search the first lookup table. If there is no matching The same value as Two adjacent first lookup values.

[0118] Each of the above-mentioned first search values ​​is multiplied by 65535 to obtain the first mapping value corresponding to each first search value, and the weight corresponding to each first search value is calculated based on the interpolation algorithm. The weights and the first mapping value corresponding to each first search value are calculated based on the interpolation algorithm to obtain the first search result.

[0119] It should be noted that the interpolation algorithm can be obtained from related technologies and will not be described in detail in the embodiments of the present application.

[0120] In some embodiments, the first lookup table includes multiple first arrays, each of the first arrays includes a first lookup value and a first mapping value corresponding to the first lookup value, and the difference between two adjacent first lookup values ​​is negatively correlated with the slope of the first nonlinear function; the first calculated value is used to find the first lookup value in each of the first arrays.

[0121] It is understandable that, since G(T) is a nonlinear function, the corresponding slope may be different in different value ranges. Therefore, if the difference between two adjacent first search values ​​is the same in different value ranges, the accuracy of the first search result falling within the value range corresponding to the larger slope will be less than the accuracy of the first search result falling within the value range corresponding to the smaller slope. In order to solve the above technical problems, in an embodiment of the present application, the difference between two adjacent first search values ​​is negatively correlated with the slope of the first nonlinear function, thereby improving the accuracy of the first search result, and further improving the accuracy of the LAB image data.

[0122] Among them, when The slope in the value range of (0, 0.1) is 0.5, and the difference between two adjacent first search values ​​corresponding to the value range of (0, 0.1) may be 0.01.

[0123] For example, when The slope in the range of (0, 0.1) is 0.5. In the value range of (0.1, 0.2), three adjacent first arrays may be (0.11, first mapping value), (0.12, first mapping value) and (0.13, first mapping value).

[0124] In addition, when The slope in the value range of (0.1, 0.2) is 0.1, and the difference between two adjacent first search values ​​corresponding to the value range of (0.1, 0.2) may be 0.02.

[0125] For example, when The slope in the range of (0.1, 0.2) is 0.1. In the value range of (0.1, 0.2), three adjacent first arrays may be (0.22, first mapping value), (0.24, first mapping value) and (0.26, first mapping value).

[0126] It can be understood that, for the convenience of description, the first search result can be represented by P, and P can be represented as:

[0127]

[0128] In some embodiments, the first transformation module 201 is further used to obtain the first search result, process the first search result based on the third linear transformation matrix and the fourth linear transformation matrix, and obtain second intermediate image data.

[0129] It can be understood that for ease of description, the third linear transformation matrix can be represented by W, which can be expressed as:

[0130]

[0131] For example, W can be calculated by the following formula:

[0132] W = M × N;

[0133] In the above formula, M can be expressed as

[0134] In the above formula, N can be expressed as:

[0135] It should be noted that M and N can be obtained based on presets.

[0136] For example, the fourth linear transformation matrix may be zero.

[0137] In some embodiments, the first search result is processed based on the third linear transformation matrix and the fourth linear transformation matrix to obtain the second intermediate image data, including:

[0138] The first transformation module 201 is further used to obtain the linear function, and based on the linear function, obtain the product of the third linear transformation matrix and the first search result.

[0139] The second intermediate image data is obtained based on the product of the third linear transformation matrix and the first search result and the sum of the fourth linear transformation matrix.

[0140] It can be understood that, for the convenience of description, the second intermediate image data can be represented by C, and C can be expressed as: C=P×W.

[0141] For example, C can be expressed as:

[0142]

[0143] In some embodiments, the first transformation module 202 is also used to obtain the second intermediate image data; process the second intermediate image data based on a second nonlinear function to obtain a second calculated value, and search a second lookup table based on the second calculated value to obtain a second search result corresponding to the second intermediate image data.

[0144] The second lookup table may be a LUT (Look-Up-Table, color lookup table).

[0145] For example, the second nonlinear function may be:

[0146]

[0147] In the above formula, T∈(0,65535); F(T)∈(0,65535); F(T) is The mapping of discrete sampling points in the value range of (0, 65535) can be understood as the second search value.

[0148] For example, It can be obtained based on the following formula:

[0149]

[0150] It can be understood that by substituting C into the second nonlinear function, the second calculated value can be expressed as

[0151]

[0152] In some embodiments, the second lookup table includes multiple second arrays, each of the second arrays includes a second lookup value and a second mapping value corresponding to the second lookup value, and the difference between two adjacent second lookup values ​​is negatively correlated with the slope of the second nonlinear function; the second calculated value is used to find the second lookup value in each of the second arrays.

[0153] For example, the value range of the second search value is (0, 1).

[0154] Among them, it can be based on Search the second lookup table, if it finds a value equal to The value of The corresponding second mapping value is obtained.

[0155] In addition, based on Search the second lookup table. If there is no matching The same value as Two adjacent second lookup values.

[0156] In some embodiments, searching a second lookup table based on the second calculated value to obtain a second search result corresponding to the second intermediate image data includes:

[0157] The first transformation module 202 is further configured to search the second lookup table based on the second calculated value to obtain the second lookup value adjacent to the second calculated value.

[0158] Based on the second lookup table, the second mapping value corresponding to each second lookup value is obtained; and interpolation calculation is performed on each second mapping value to obtain the second lookup result.

[0159] It is understandable that, since F(T) is a nonlinear function, the corresponding slope may be different in different value ranges. Therefore, if the difference between two adjacent second search values ​​is the same in different value ranges, the accuracy of the second search result falling within the value range corresponding to the larger slope will be less than the accuracy of the second search result falling within the value range corresponding to the smaller slope. In order to solve the above technical problems, in an embodiment of the present application, the difference between two adjacent second search values ​​is negatively correlated with the slope of the second nonlinear function, thereby improving the accuracy of the second search result, and further improving the accuracy of the LAB image data.

[0160] Among them, when The slope in the value range of (0, 0.1) is 0.3, and the difference between two adjacent second search values ​​corresponding to the value range of (0, 0.1) may be 0.02.

[0161] In addition, when The slope in the value range of (0.1, 0.2) is 0.1, and the difference between two adjacent second search values ​​corresponding to the value range of (0.1, 0.2) may be 0.05.

[0162] It can be understood that for ease of description, the second search result can be represented by D, and D can be represented as:

[0163]

[0164] In some embodiments, the first transformation module 201 is further used to process the second search result based on the fifth linear transformation matrix and the sixth linear transformation matrix to obtain LAB image data.

[0165] In some embodiments, the second search result is calculated based on the fifth linear transformation matrix and the sixth linear transformation matrix to obtain LAB image data, including:

[0166] The first transformation module 201 is further used to obtain the linear function, and based on the linear function, obtain the product of the fifth linear transformation matrix and the second search result.

[0167] The LAB image data is obtained based on the product of the fifth linear transformation matrix and the second search result and the sum of the sixth linear transformation matrix.

[0168] It can be understood that, for the convenience of expression, the fifth linear transformation matrix can be represented by U, and the sixth linear transformation matrix can be represented by E, then the LAB image data can be represented as:

[0169] LAB image data=U×D+E.

[0170] For example, LAB image data can be represented as:

[0171]

[0172] In the above formula, L represents L channel, A represents A channel, and B represents B channel.

[0173] but,

[0174] In the above formula: E can be expressed as:

[0175]

[0176] U can be expressed as:

[0177] U = K / 65535;

[0178]

[0179] but

[0180] It should be noted that B, E and K can all be obtained based on presets.

[0181] In the related art, converting RGB image data into LAB image data based on a CPU may include the following steps:

[0182] Convert RGB image data to XYZ image data;

[0183] Convert XYZ image data to LAB image data.

[0184] In the related art, RGB image data is converted into XYZ image data based on the following formula:

[0185]

[0186] Convert XYZ image data to LAB image data based on the following formula:

[0187]

[0188] That is, in the related art,

[0189] By comparing the LAB image data obtained based on the above two methods, it can be seen that in the embodiment of the present application, the RGB image data is converted into LAB image data based on the hardware accelerator, and the obtained LAB image data is the same as the LAB image data in the related data, that is, the hardware accelerator based on the embodiment of the present application can not only convert RGB image data into LAB image data, but also improve the efficiency of converting RGB image data into LAB image data.

[0190] In some embodiments, the first transformation module 201 is a CCM (Color Correction Matrix) module, and the first transformation module 202 is a DRC (Dynamic Range Compression) module.

[0191] Among them, the DRC module can support a 16-bit LUT table, and the CCM module can support a 16-bit value range.

[0192] The embodiment of the present application is a hardware accelerator for color space conversion. The hardware accelerator converts RGB image data into LAB image data by combining multiple linear transformations and nonlinear transformations. There is no need for the CPU to process the RGB image, thereby solving the problem that the CPU consumes a lot of time to convert RGB image data into LAB image data, thereby improving the efficiency of converting RGB image data into LAB image data and realizing high frame rate image processing.

[0193] Figure 3 is a flow chart of a method for color space conversion provided according to an embodiment of the present application, such as Figure 3 As shown, in the embodiment of the present application, the application is described by taking the application on a terminal having a hardware accelerator for color space conversion as an example. The method comprises the following steps:

[0194] In step 301, the terminal obtains RGB image data; processes the RGB image data based on a first linear transformation matrix and a second linear transformation matrix to obtain first intermediate image data;

[0195] In step 302, the terminal obtains the first intermediate image data; processes the first intermediate image data based on a first nonlinear function to obtain a first calculated value, searches a first lookup table based on the first calculated value, and obtains a first search result corresponding to the first intermediate image data;

[0196] In step 303, the terminal obtains the first search result, processes the first search result based on the third linear transformation matrix and the fourth linear transformation matrix, and obtains second intermediate image data;

[0197] In step 304, the terminal obtains the second intermediate image data; processes the second intermediate image data based on a second nonlinear function to obtain a second calculated value, searches a second lookup table based on the second calculated value, and obtains a second search result corresponding to the second intermediate image data;

[0198] In step 305, the terminal processes the second search result based on the fifth linear transformation matrix and the sixth linear transformation matrix to obtain LAB image data.

[0199] In some embodiments, the first lookup table includes multiple first arrays, each of the first arrays includes a first lookup value and a first mapping value corresponding to the first lookup value, and the difference between two adjacent first lookup values ​​is negatively correlated with the slope of the first nonlinear function; the first calculated value is used to find the first lookup value in each of the first arrays.

[0200] In some embodiments, the step of processing the RGB image data based on the first linear transformation matrix and the second linear transformation matrix to obtain the first intermediate image data includes:

[0201] Obtain a linear function, and based on the linear function, obtain the product of the first linear transformation matrix and the RGB image data;

[0202] The first intermediate image data is obtained based on the product of the first linear transformation matrix and the RGB image data and the sum of the second linear transformation matrix.

[0203] In some embodiments, searching a first lookup table based on the first calculated value to obtain a first search result corresponding to the first intermediate image data includes:

[0204] Searching the first lookup table based on the first calculated value to obtain the first lookup value adjacent to the first calculated value;

[0205] Based on the first lookup table, the first mapping value corresponding to each first lookup value is obtained; and interpolation calculation is performed on each first mapping value to obtain the first lookup result.

[0206] In some embodiments, the first search result is processed based on the third linear transformation matrix and the fourth linear transformation matrix to obtain the second intermediate image data, including:

[0207] Obtain the linear function, and based on the linear function, obtain the product of the third linear transformation matrix and the first search result;

[0208] The second intermediate image data is obtained based on the product of the third linear transformation matrix and the first search result and the sum of the fourth linear transformation matrix.

[0209] In some embodiments, the second lookup table includes multiple second arrays, each of the second arrays includes a second lookup value and a second mapping value corresponding to the second lookup value, and the difference between two adjacent second lookup values ​​is negatively correlated with the slope of the second nonlinear function; the second calculated value is used to find the second lookup value in each of the second arrays.

[0210] In some embodiments, searching a second lookup table based on the second calculated value to obtain a second search result corresponding to the second intermediate image data includes:

[0211] Searching the second lookup table based on the second calculated value to obtain the second lookup value adjacent to the second calculated value;

[0212] Based on the second lookup table, the second mapping value corresponding to each second lookup value is obtained; and interpolation calculation is performed on each second mapping value to obtain the second lookup result.

[0213] In some embodiments, the second search result is calculated based on the fifth linear transformation matrix and the sixth linear transformation matrix to obtain LAB image data, including:

[0214] Obtain the linear function, and based on the linear function, obtain the product of the fifth linear transformation matrix and the second search result;

[0215] The LAB image data is obtained based on the product of the fifth linear transformation matrix and the second search result and the sum of the sixth linear transformation matrix.

[0216] In some embodiments, the method further comprises:

[0217] The first intermediate image data, the first calculated value, the first mapped value, the second intermediate image data, the second mapped value and the LAB image data are stored in an OCM module.

[0218] It should be noted that the hardware accelerator for color space conversion provided in the above embodiment and the method embodiment for color space conversion belong to the same concept, and the specific implementation process is detailed in the device embodiment, which will not be repeated here.

[0219] The embodiment of the present application is a hardware accelerator for color space conversion. The hardware accelerator converts RGB image data into LAB image data by combining multiple linear transformations and nonlinear transformations. There is no need for the CPU to process the RGB image, thereby solving the problem that the CPU consumes a lot of time to convert RGB image data into LAB image data, thereby improving the efficiency of converting RGB image data into LAB image data and realizing high frame rate image processing.

[0220] An embodiment of the present application further provides a computer device, including a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, and the processor implements the above method when executing the computer program.

[0221] Taking computer equipment as the terminal as an example, Figure 4 This is a schematic diagram of the structure of a terminal provided in an embodiment of the present application, see Figure 4 The terminal 400 may be a smart phone, a tablet computer, an MP3 player (Moving Picture Experts Group Audio Layer III), an MP4 player (Moving Picture Experts Group Audio Layer IV), a laptop computer or a desktop computer. The terminal 400 may also be called a user device, a portable terminal, a laptop terminal, a desktop terminal or other names.

[0222] Typically, the terminal 400 includes a processor 401 and a memory 402 .

[0223] The processor 401 may include one or more processing cores, such as a 4-core processor, a 4-core processor, etc. The processor 401 may be implemented in at least one hardware form of DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), and PLA (Programmable Logic Array). The processor 401 may also include a main processor and a coprocessor. The main processor is a processor for processing data in the awake state, also known as a CPU (Central Processing Unit); the coprocessor is a low-power processor for processing data in the standby state. In some embodiments, the processor 401 may be integrated with a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor 401 may also include an AI (Artificial Intelligence) processor, which is used to process computing operations related to machine learning.

[0224] The memory 402 may include one or more computer-readable storage media, which may be non-transitory. The memory 402 may also include a high-speed random access memory, and a non-volatile memory, such as one or more disk storage devices, flash memory storage devices. In some embodiments, the non-transitory computer-readable storage medium in the memory 402 is used to store at least one program code, which is used to be executed by the processor 401 to implement the process of terminal execution in the method for mixed-precision floating-point multiplication and accumulation operations provided in the method embodiment of the present application.

[0225] In some embodiments, the terminal 400 may further optionally include: a peripheral device interface 403 and at least one peripheral device. The processor 401, the memory 402 and the peripheral device interface 403 may be connected via a bus or a signal line. Each peripheral device may be connected to the peripheral device interface 403 via a bus, a signal line or a circuit board. Specifically, the peripheral device includes: at least one of a display screen 404, a camera assembly 405, an audio circuit 406 and a power supply 407.

[0226] The peripheral device interface 403 can be used to connect at least one peripheral device related to I / O (Input / Output) to the processor 401 and the memory 402. In some embodiments, the processor 401, the memory 402 and the peripheral device interface 403 are integrated on the same chip or circuit board; in some other embodiments, any one or two of the processor 401, the memory 402 and the peripheral device interface 403 can be implemented on a separate chip or circuit board, which is not limited in the embodiments of the present application.

[0227] The display screen 404 is used to display the UI (User Interface). The UI may include graphics, text, icons, videos, and any combination thereof. When the display screen 404 is a touch display screen, the display screen 404 also has the ability to collect touch signals on the surface or above the surface of the display screen 404. The touch signal can be input to the processor 401 as a control signal for processing. At this time, the display screen 404 can also be used to provide virtual buttons and / or virtual keyboards, also known as soft buttons and / or soft keyboards. In some embodiments, the display screen 404 can be one, set on the front panel of the terminal 400; in other embodiments, the display screen 404 can be at least two, respectively set on different surfaces of the terminal 400 or in a folding design; in other embodiments, the display screen 404 can be a flexible display screen, set on the curved surface or folding surface of the terminal 400. Even, the display screen 404 can also be set to a non-rectangular irregular shape, that is, a special-shaped screen. The display screen 404 can be made of materials such as LCD (Liquid Crystal Display), OLED (Organic Light-Emitting Diode, organic light-emitting diode).

[0228] The camera assembly 405 is used to capture images or videos. In some embodiments, the camera assembly 405 includes a front camera and a rear camera. Typically, the front camera is disposed on the front panel of the terminal, and the rear camera is disposed on the back of the terminal. In some embodiments, there are at least two rear cameras, which are any one of a main camera, a depth of field camera, a wide-angle camera, and a telephoto camera, so as to realize the fusion of the main camera and the depth of field camera to realize the background blur function, the fusion of the main camera and the wide-angle camera to realize the panoramic shooting and VR (Virtual Reality) shooting function or other fusion shooting functions. In some embodiments, the camera assembly 405 may also include a flash. The flash may be a monochrome temperature flash or a dual-color temperature flash. A dual-color temperature flash refers to a combination of a warm light flash and a cold light flash, which can be used for light compensation at different color temperatures.

[0229] The audio circuit 406 may include a microphone and a speaker. The microphone is used to collect sound waves from the user and the environment, and convert the sound waves into electrical signals and input them into the processor 401 for processing. For the purpose of stereo acquisition or noise reduction, there may be multiple microphones, which are respectively arranged at different parts of the terminal 400. The microphone may also be an array microphone or an omnidirectional acquisition microphone. The speaker is used to convert the electrical signal from the processor 401 into sound waves. The speaker may be a traditional film speaker or a piezoelectric ceramic speaker. When the speaker is a piezoelectric ceramic speaker, it can not only convert the electrical signal into sound waves audible to humans, but also convert the electrical signal into sound waves inaudible to humans for purposes such as ranging. In some embodiments, the audio circuit 406 may also include a headphone jack.

[0230] The power supply 407 is used to power various components in the terminal 400. The power supply 407 can be an alternating current, a direct current, a disposable battery, or a rechargeable battery. When the power supply 407 includes a rechargeable battery, the rechargeable battery can support wired charging or wireless charging. The rechargeable battery can also be used to support fast charging technology.

[0231] Those skilled in the art will understand that Figure 4 The structure shown in the figure does not constitute a limitation on the terminal 400, and the terminal 400 may include more or less components than those shown in the figure, or combine some components, or adopt a different component arrangement.

[0232] Take the computer device as a server as an example. Figure 5 : is a structural diagram of a server provided in an embodiment of the present application. The server 500 may have relatively large differences due to different configurations or performances, and may include one or more processors (Central Processing Units, CPU) 501 and one or more memories 502, wherein the one or more memories 502 store at least one computer program, and the at least one computer program is loaded and executed by the one or more processors 501 to implement the above-mentioned method for color space conversion. Of course, the server 500 may also have components such as a wired or wireless network interface, a keyboard, and an input and output interface for input and output. The server 500 may also include other components for implementing device functions, which will not be described in detail here.

[0233] The embodiment of the present application also provides a computer-readable storage medium, the computer-readable storage medium includes a stored computer program, wherein when the computer program is running, the device where the computer-readable storage medium is located is controlled to execute the above-mentioned method for generating an image processing model. Optionally, the computer-readable storage medium can be a read-only memory (ROM), a random access memory (RAM), a compact disc (CD-ROM), a magnetic tape, a floppy disk, an optical data storage device, etc.

[0234] A person skilled in the art will understand that all or part of the steps to implement the above embodiments may be accomplished by hardware or by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, and the above-mentioned storage medium may be a read-only memory, a disk or an optical disk, etc.

[0235] The above description is only an optional embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application shall be included in the protection scope of the present application.

Claims

1. A hardware accelerator for color space conversion, It is characterized in that include: A first conversion module and a second conversion module electrically connected to each other; The first transformation module is used to obtain RGB image data; Processing the RGB image data based on the first linear transformation matrix and the second linear transformation matrix to obtain first intermediate image data; The second transformation module is used to obtain the first intermediate image data; Processing the first intermediate image data based on a first nonlinear function to obtain a first calculated value, searching a first lookup table based on the first calculated value to obtain a first search result corresponding to the first intermediate image data; The first transformation module is further used to obtain the first search result, process the first search result based on the third linear transformation matrix and the fourth linear transformation matrix, and obtain second intermediate image data; The second transformation module is further used to obtain the second intermediate image data; Processing the second intermediate image data based on a second nonlinear function to obtain a second calculated value, searching a second lookup table based on the second calculated value to obtain a second search result corresponding to the second intermediate image data; The first transformation module is further used to process the second search result based on the fifth linear transformation matrix and the sixth linear transformation matrix to obtain LAB image data.

2. The hardware accelerator according to claim 1, It is characterized in that The first lookup table includes multiple first arrays, each of the first arrays includes a first lookup value and a first mapping value corresponding to the first lookup value, and the difference between two adjacent first lookup values ​​is negatively correlated with the slope of the first nonlinear function; the first calculated value is used to find the first lookup value in each of the first arrays.

3. The hardware accelerator according to claim 2, It is characterized in that The step of processing the RGB image data based on the first linear transformation matrix and the second linear transformation matrix to obtain first intermediate image data includes: The first transformation module is used to obtain a linear function, and based on the linear function, obtain the product of the first linear transformation matrix and the RGB image data; The first transformation module is further used to obtain the first intermediate image data based on the product of the first linear transformation matrix and the RGB image data and the sum of the second linear transformation matrix.

4. The hardware accelerator according to claim 3, It is characterized in that The step of searching a first lookup table based on the first calculated value to obtain a first search result corresponding to the first intermediate image data includes: The first transformation module is configured to search the first lookup table based on the first calculated value to obtain the first lookup value adjacent to the first calculated value; The first transformation module is further used to obtain the first mapping value corresponding to each first lookup value based on the first lookup table; and perform interpolation calculation on each first mapping value to obtain the first lookup result.

5. The hardware accelerator according to claim 3, It is characterized in that The step of processing the first search result based on the third linear transformation matrix and the fourth linear transformation matrix to obtain second intermediate image data includes: The first transformation module is further used to obtain the linear function, and based on the linear function, obtain the product of the third linear transformation matrix and the first search result; The second intermediate image data is obtained based on the product of the third linear transformation matrix and the first search result and the sum of the fourth linear transformation matrix.

6. The hardware accelerator according to claim 5, It is characterized in that The second lookup table includes a plurality of second arrays, each of the second arrays includes a second lookup value and a second mapping value corresponding to the second lookup value, and a difference between two adjacent second lookup values ​​is negatively correlated with a slope of the second nonlinear function; The second calculated value is used to look up the second lookup value in each of the second arrays.

7. The hardware accelerator according to claim 6, It is characterized in that The step of searching a second lookup table based on the second calculated value to obtain a second search result corresponding to the second intermediate image data includes: The second transformation module is further used to search the second lookup table based on the second calculated value to obtain the second lookup value adjacent to the second calculated value; Based on the second lookup table, the second mapping value corresponding to each second lookup value is obtained; and interpolation calculation is performed on each second mapping value to obtain the second lookup result.

8. The hardware accelerator according to claim 6, It is characterized in that The step of calculating the second search result based on the fifth linear transformation matrix and the sixth linear transformation matrix to obtain LAB image data includes: The first transformation module is further used to obtain the linear function, and based on the linear function, obtain the product of the fifth linear transformation matrix and the second search result; The LAB image data is obtained based on the product of the fifth linear transformation matrix and the second search result and the sum of the sixth linear transformation matrix.

9. The hardware accelerator according to claim 6, It is characterized in that The hardware accelerator is electrically connected to the OCM module; The OCM module is used to store the first intermediate image data, the first calculated value, the first mapping value, the second intermediate image data, the second mapping value and the LAB image data.

10. The hardware accelerator according to claim 1, It is characterized in that The first transformation module is a CCM module, and the second transformation module is a DRC module.

11. A method for color space conversion, It is characterized in that include: Get RGB image data; Processing the RGB image data based on the first linear transformation matrix and the second linear transformation matrix to obtain first intermediate image data; Acquire the first intermediate image data; Processing the first intermediate image data based on a first nonlinear function to obtain a first calculated value, searching a first lookup table based on the first calculated value to obtain a first search result corresponding to the first intermediate image data; Acquire the first search result, and process the first search result based on a third linear transformation matrix and a fourth linear transformation matrix to obtain second intermediate image data; acquiring the second intermediate image data; Processing the second intermediate image data based on a second nonlinear function to obtain a second calculated value, searching a second lookup table based on the second calculated value to obtain a second search result corresponding to the second intermediate image data; The second search result is processed based on the fifth linear transformation matrix and the sixth linear transformation matrix to obtain LAB image data.

12. A computer device, It is characterized in that The computer device comprises a processor and a memory, wherein the memory is used to store at least one program, and the at least one program is loaded by the processor and executes the method for color space conversion according to claim 11.

13. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores at least one program, and the at least one program is loaded and executed by a processor to implement the method for color space conversion according to claim 11.