Method and device for image processing through arithmetic operator class

By unifying the interface and mapping table mechanism in the image processing system, the problem of lack of flexibility and scalability in the design of arithmetic operator classes is solved, the speed and efficiency of image processing are improved, and the needs of different data types and formats are adapted to the needs.

CN118628333APending Publication Date: 2024-09-10SHANGHAI BIREN TECH CO LTD
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202410970206.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-18
Publication Date
2024-09-10

AI Technical Summary

Technical Problem

The existing arithmetic operator classes lack flexibility and scalability in design, resulting in the need to write and maintain different codes for different data types and image formats, increasing the development and maintenance workload, and limiting the speed and efficiency of image processing.

Method used

By introducing the input interface layer, processing layer and operator kernel function layer into the image processing system, the internal interface is unified to receive image data, and the calculation function pointer is searched in the pre-stored mapping table according to the data type and operation mode of the target operator, and passed The operator kernel function layer calls calculation functions to operate on image pixel data to achieve the versatility and efficiency of different operators.

Benefits of technology

It reduces the code maintenance workload, improves the speed and efficiency of image processing, has good flexibility and scalability, can adapt to different data types and image formats, and meets the growing needs of image processing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118628333A
    Figure CN118628333A
Patent Text Reader

Abstract

The invention provides a method and device for image processing through an arithmetic operator class, and the method comprises the steps: receiving image data needing arithmetic operation through a unified internal interface of an input interface layer, and determining a target operator in operators supported by the unified internal interface; a processing layer converts received image data into image pixel data according to a data type of a target operator, transmits the image pixel data to an operator kernel function layer, and searches in a pre-stored mapping table according to the received data type of the target operator and an operation mode; obtaining a pointer of a calculation function for processing the corresponding operation mode of each pixel point to be called by an operator kernel function; and calling an operator kernel function through the operator kernel function layer, obtaining image pixel data sent by the processing layer, calling a calculation function of a target operator through the operator kernel function according to a pointer, and executing operation on each pixel point of the image pixel data to obtain an arithmetic operation result of the image data so as to adapt to different data types and image formats.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of image processing technology, and in particular to a method and device for performing image processing through an arithmetic operator class. Background Art

[0002] With the rapid development of digital image processing technology, image arithmetic operations play an increasingly important role in many fields. Image arithmetic operations include but are not limited to basic arithmetic operations such as pixel-level addition, subtraction, multiplication and division, which are widely used in image enhancement, image fusion, motion detection and image denoising.

[0003] For different arithmetic operator classes, the supported sub-operators, image formats, data width types, and interface types are different from each other, and there is no unified format. For each arithmetic operator class, the corresponding supported application programming interface API must be set. For example, an arithmetic operator class contains 21 mathematical arithmetic operators, each sub-operator must support data width types of U8 / U16 / FP32, and the supported image formats are GRAY / RGB / BGR / RGBA / BGRA (i.e. 1channel / 3channel / 4channel three types of formats), and each interface is divided into synchronous interface and asynchronous interface. Correspondingly, the supported interface API is about 21*3*3*2≈378 APIs. Supporting so many APIs brings challenges to software development and maintenance.

[0004] Existing arithmetic operator classes are often designed for specific operations and data types, lacking sufficient flexibility and extensibility. For example, different operators may need to write and maintain different codes for different data types and image formats, which not only increases the workload of development and maintenance, but also limits the versatility of operators in different application scenarios and restricts the speed and efficiency of image processing. Summary of the invention

[0005] The present invention provides a method and device for image processing by using an arithmetic operator class, so as to solve the defects that the arithmetic operator class in the prior art is developed for specific operations and data types and lacks flexibility and extensibility.

[0006] The present invention provides a method for performing image processing by using an arithmetic operator class, which is used in an image processing system. The system includes an input interface layer, a processing layer and an operator kernel function layer. The method includes: Receiving image data that needs to be subjected to arithmetic operation through a unified internal interface of an input interface layer, and determining a target operator among operators supported by the unified internal interface, wherein API parameters of the target operator include a data type and an operation mode of the operator and the image data; The received image data is converted into image pixel data according to the data type of the target operator through the processing layer and transmitted to the operator kernel function layer, and a search is performed in a pre-stored mapping table according to the received data type and operation mode of the target operator to obtain a pointer to a calculation function of a corresponding operation mode for processing each pixel point for the operator kernel function to call; wherein the mapping table stores a pointer mapping of combinations of different operation modes and data types to corresponding calculation functions; The operator kernel function is called through the operator kernel function layer to obtain the image pixel data sent by the processing layer, and the calculation function of the target operator is called through the operator kernel function according to the pointer to perform operations on each pixel point of the image pixel data until the arithmetic operation result of the image data is obtained.

[0007] According to a method for image processing through an arithmetic operator class provided by the present invention, the unified internal interface of the input interface layer is implemented by the following method: determining multiple arithmetic operator classes supported by the input interface layer, as well as API parameters of each operator of each arithmetic operator class and enumeration values ​​of each operator, wherein the API parameters include an image type; and forming a unified internal interface based on the image type and enumeration value of each operator as template parameters.

[0008] According to a method for performing image processing by an arithmetic operator class provided by the present invention, a pointer to a calculation function of a corresponding operation mode for processing each pixel point is obtained by searching in a pre-stored mapping table according to the data type and operation mode of the received target operator, specifically comprising: According to the data type and operation mode of the received target operator, a search is performed in a pre-stored mapping table to obtain a corresponding call function pointer; wherein the key of the mapping table is a combination of the operation mode and the data type, and the value is a call function pointer pointing to the calculation function that actually performs the operation.

[0009] According to a method for performing image processing through an arithmetic operator class provided by the present invention, a calculation function of the target operator is called according to the pointer through an operator kernel function, and operations are performed on each pixel point of the image pixel data until an arithmetic operation result of the image data is obtained, including: The operator kernel function is called through the operator kernel function to obtain the image pixel data sent by the processing layer, and the image pixel data is cut into blocks according to the resources of the graphics card and the size of the image pixel data; The calculation function of the target operator is called according to the pointer through the operator kernel function, and the operation is performed in parallel on each pixel point of each cut block until the calculation of all the cut blocks is completed, thereby obtaining the result of the arithmetic operation of the entire image.

[0010] According to a method for image processing by an arithmetic operator class provided by the present invention, the input interface layer stores a unified internal interface function, and the processing layer stores an operator dispatching function; The received image data is converted into image pixel data according to the data type of the target operator through the processing layer and transmitted to the operator kernel function layer, specifically including: The operator dispatching function is called through the internal interface function, and the received image data is converted into image pixel data according to the data type of the target operator through the called operator dispatching function and transmitted to the operator kernel function layer.

[0011] According to a method for image processing by an arithmetic operator class provided by the present invention, the mapping table is generated in the following manner: The operator dispatch function receives the data type and operation mode of each operator as input, and determines the function pointer corresponding to each operator to associate the corresponding arithmetic operation; The data type and operation mode of each operator are mapped to the function pointer corresponding to each operator through the operator dispatching function to obtain the mapping table.

[0012] The present invention also provides a device for performing image processing by using an arithmetic operator class, which is used in an image processing system. The system includes an input interface layer, a processing layer and an operator kernel function layer. The device includes: The interface layer processing module is used to receive the image data that needs to be subjected to arithmetic operation through the unified internal interface of the input interface layer, and determine the target operator among the operators supported by the unified internal interface, wherein the API parameters of the target operator include the data type and operation mode of the operator and the image data; The processing layer processing module is used to convert the received image data into image pixel data according to the data type of the target operator through the processing layer and transmit it to the operator kernel function layer, and search in the pre-stored mapping table according to the received data type and operation mode of the target operator to obtain the pointer of the calculation function of the corresponding operation mode for processing each pixel point for the operator kernel function to call; wherein the mapping table stores the pointer mapping of the combination of different operation modes and data types to the corresponding calculation function; The kernel function layer processing module is used to call the operator kernel function through the operator kernel function layer, obtain the image pixel data sent by the processing layer, call the calculation function of the target operator according to the pointer through the operator kernel function, and perform operations on each pixel point of the image pixel data until the arithmetic operation result of the image data is obtained.

[0013] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the method for performing image processing by using an arithmetic operator class as described above is implemented.

[0014] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements any of the above-described methods for performing image processing by using an arithmetic operator class.

[0015] The present invention also provides a computer program product, comprising a computer program, which, when executed by a processor, implements any of the above methods for performing image processing by using arithmetic operator classes.

[0016] The method and device for image processing through an arithmetic operator class provided by the present invention define a unified internal interface through an input interface layer to realize receiving image data that needs to be arithmetic operated, and determine a target operator among operators supported by the unified internal interface; the received image data is converted into image pixel data according to the data type of the target operator through the processing layer, and transmitted to the operator kernel function layer, and a search is performed in a pre-stored mapping table according to the received data type and operation mode of the target operator to obtain a pointer to a calculation function of a corresponding operation mode for processing each pixel point, which is provided for the operator kernel function to call, thereby unifying the behavior of the processing layer; then, the operator kernel function is called through the operator kernel function to obtain the image pixel data sent by the processing layer, and the calculation function of the target operator is called through the operator kernel function according to the pointer, and the operation is performed on each pixel point of the image pixel data until the arithmetic operation result of the image data is obtained, thereby unifying the behavior of the operator kernel function; thereby realizing the operation of various different operators through a unified external API internal interface, a unified processing layer behavior, and a unified operator kernel function behavior, reducing the workload of code maintenance and increasing the flexibility of the software. This method can not only improve the speed and efficiency of image processing, but also has good flexibility and scalability, and can adapt to different data types and image formats to meet the growing needs of image processing. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0018] Figure 1 This is one of the flowchart diagrams of the method for performing image processing through an arithmetic operator class provided by the present invention.

[0019] Figure 2 This is the second flowchart of the method for performing image processing through arithmetic operator classes provided by the present invention.

[0020] Figure 3 This is the third flowchart of the method for performing image processing through arithmetic operator classes provided by the present invention.

[0021] Figure 4 This is the fourth flowchart of the method for performing image processing through arithmetic operator classes provided by the present invention.

[0022] Figure 5 It is a structural schematic diagram of the device for performing image processing through arithmetic operator classes provided by the present invention.

[0023] Figure 6 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION

[0024] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0025] In view of the technical defects existing in the prior art, the present invention aims to provide a design method for image arithmetic operators implemented on CPU and GPU, which can not only improve the speed and efficiency of image processing, but also has good flexibility and scalability, can adapt to different data types and image formats, and meet the growing image processing needs.

[0026] Combine the following Figure 1-Figure 5 The present invention describes a method and apparatus for image processing using arithmetic operator classes.

[0027] Figure 1 It is one of the flow diagrams of the method for performing image processing by arithmetic operator class provided by the present invention, which is used in an image processing system. The image processing system of this embodiment includes an input interface layer, a processing layer and an operator kernel function layer. Among them, the processing layer can be set in the CPU, and the operator kernel function layer can be set in the GPU.

[0028] like Figure 1 As shown, the method includes the following: Step 101: receiving image data that needs to be subjected to arithmetic operation through a unified internal interface of an input interface layer, and determining a target operator among operators supported by the unified internal interface, wherein API parameters of the target operator include a data type, an operation mode, and image data of the operator.

[0029] Among them, the image data is directly transmitted to the input interface layer as API parameters.

[0030] The common points among multiple operator interface APIs of many arithmetic operator classes are analyzed and abstracted into a unified internal interface. The APIs of each operator of the arithmetic operator class call the unified internal interface.

[0031] For the internal interface, its template parameter is the union of the API parameters of each operator of all arithmetic operator classes, and the parameter type is a generic type adapted to different operator APIs, thereby achieving the unification of the internal interface.

[0032] Among them, see Figure 2 , the unified internal interface of the input interface layer is implemented by the following methods: 201. Determine multiple arithmetic operator classes supported by the input interface layer, as well as API parameters of each operator of each arithmetic operator class and enumeration values ​​of each operator, wherein the API parameters include an image type.

[0033] 202. A unified internal interface is formed based on the image type and enumeration value of each operator as template parameters.

[0034] When designing an internal template function, its parameters usually include the union of input, configuration, and output parameters that may be required by all related APIs. For an arithmetic operator API, its parameters may include but are not limited to the following categories: Input data: References or pointers to input images or datasets. For image processing, this may include pointers to source and destination images.

[0035] Output data: A reference or pointer to an image or data structure used to store the results.

[0036] Data width: The bit width of each element in an image or data, such as an 8-bit unsigned integer (uint8_t), a 16-bit unsigned integer (uint16_t), a 32-bit floating point number (float), etc.

[0037] Operation type: Specifies the arithmetic operation to be performed, such as addition, subtraction, multiplication, division, etc.

[0038] Operation mode (opMode): Some operations may have different execution modes. For example, addition can be a simple addition of pixel values ​​or a weighted addition.

[0039] In this embodiment, the data type and operation mode in the API parameter are used as an example for explanation. The arithmetic operation rules of each operator are different, and the data type DataType and operation mode opmode of each API are different. Among them, the data type is used as a template parameter, and the operation mode is used as a function parameter.

[0040] It needs to be explained that when using a programming language that supports templates like C++, "template parameters" and "function parameters" are two different concepts, and they play different roles in the program.

[0041] Template parameters: Template parameters are parameters used when defining a template. They are used to create generic or common code structures. Template parameters can be types (such as typename T or class T) or constant expressions (such as int N). Template parameters allow programmers to define a skeleton for a function or class that can be instantiated at compile time based on specific types or values ​​provided. For example, in template<typename T> In the template, T is a template parameter, which represents a type and will be replaced by a specific type when creating a template instance.

[0042] Function parameters: Function parameters are variables specified in the function definition, which are used to pass data to the function when the function is called. Function parameters have specific types and names, and they need to match the actual parameters passed when the function is called. Function parameters can be value parameters, reference parameters, or pointer parameters, which define how the function receives and uses external data. For example, in void myFunction(int x, double y), int x and double y are function parameters, representing an integer and a double-precision floating-point number respectively.

[0043] For example: template<typename T>

[0044] void myTemplateFunction(T param) {

[0045] / / Use template parameter T and function parameter param

[0046] }

[0047] In this example, T is the template parameter, which allows the function to accept any type of argument; and param is the function parameter, which is the specific data passed to the function.

[0048] Through step 101, a unified internal interface of the input interface layer is implemented, and the API of each operator is uniformly called without the need for separate development for each operator.

[0049] Step 102: The received image data is converted into image pixel data according to the data type of the target operator through the processing layer and transmitted to the operator kernel function layer, and a search is performed in a pre-stored mapping table according to the received data type and operation mode of the target operator to obtain a pointer to a calculation function of the corresponding operation mode for processing each pixel point for the operator kernel function to call; wherein the mapping table stores pointer mappings of combinations of different operation modes and data types to corresponding calculation functions.

[0050] Specifically, the input interface layer stores a unified internal interface function, and the processing layer also stores an operator dispatch function. The mapping table is generated in the following manner: the operator dispatch function receives the data type datatype and operation mode opmode of each operator input, and determines the function pointer corresponding to each operator to associate the corresponding arithmetic operation; the operator dispatch function maps the data type datatype and operation mode opmode of each operator with the function pointer corresponding to each operator to obtain the mapping table.

[0051] For the processing layer set up in the CPU, two parts of work need to be completed: one is to process the received image data to obtain image pixel data that is suitable for transmission to the GPU; the other is to look up the mapping table according to the received data type and operation model, and obtain the corresponding calculation function opCalculator through a table lookup, so that the operator kernel function in the subsequent steps can call it and execute the corresponding operator operation.

[0052] Different operators have different arithmetic operation rules. For example, the MulCScale operator multiplies each pixel by a constant and then scales it to the pixel data width. Another example is the DivRound operator, which divides the pixels of two images, rounds the result according to the specified rounding mode, and scales the result.

[0053] Different operators are used as General Launcher template parameters, and the instantiation of template parameters is stored in a launch map table. At runtime, the instantiation call function pointer of General Launch is obtained by looking up the table, so that the operator kernel function can call the calculation function of the corresponding operation mode OPMode for processing each pixel point according to the call function pointer, thereby taking into account the unification of the process and method as well as the unification of the source code form. The compilation and runtime of different operation modes opMode actually call different calculation rule functions to realize the operation of each operator.

[0054] It should be noted that the calculation function and the API parameter are different. Take the example of the API parameter being the value of the image pixel and the calculation function being addition. If the addition is the addition of each pixel of two images, the API function parameter is the value of each pixel.

[0055] Through step 102, the behaviors of the processing layers can be unified through the mapping table in the processing layer to obtain the processed image pixel data and the calculation function opCalculator for the operator kernel function to call.

[0056] Furthermore, compared with the two table lookups in the related art, this embodiment can obtain the calculation function corresponding to the data type datatype and the operation mode opmode of the target operator through one table lookup.

[0057] In a related technique, two table lookups are performed: First table lookup: arithmetic<srcDataType, dstDataType> Here srcDataType and dstDataType represent the source data type and the target data type respectively. In this lookup table, the corresponding arithmetic operation function is determined according to the input and output data types.

[0058] Second table lookup: ArithmeticLauncher <ArithOp<srcDataType, dstDataType,opMode> >In this search, in addition to the data type, the operation mode opMode is also considered. ArithOp may be a template structure that combines the data type and the operation mode to further determine the specific arithmetic operation.

[0059] In this embodiment, these two lookups are combined into one lookup table, the purpose of which is to reduce the call level and reduce the complexity of the overall design. The key to simplification is to create a unified lookup table that can index the correct arithmetic operation function based on both the data type and the operation mode.

[0060] Simplifying the table lookup process can reduce the number of lookups at runtime, thereby improving efficiency. In addition, reducing the lookup level also means reducing the possibility of errors, because each lookup may fail because the key does not exist or the type does not match. At the same time, simplifying the design also makes the code easier to understand and maintain.

[0061] Step 103, call the operator kernel function through the operator kernel function layer to obtain the image pixel data sent by the processing layer, call the calculation function of the target operator according to the pointer through the operator kernel function, and perform operations on each pixel point of the image pixel data until the arithmetic operation result of the image data is obtained.

[0062] The calculation function stores the operation rules corresponding to each operator. The operator kernel function is called to use the opCalculator object to perform corresponding arithmetic operations on each pixel, and finally the arithmetic operation results corresponding to the entire image are obtained.

[0063] The method for image processing through an arithmetic operator class provided by the present invention defines a unified internal interface through an input interface layer to realize receiving image data that needs to be subjected to arithmetic operations, and determines a target operator among operators supported by the unified internal interface; the received image data is converted into image pixel data according to the data type of the target operator through a processing layer, and transmitted to an operator kernel function layer, and a search is performed in a pre-stored mapping table according to the received data type and operation mode of the target operator, so as to obtain a pointer to a calculation function of a corresponding operation mode for processing each pixel point, for the operator kernel function to call, thereby unifying the behavior of the processing layer; then, the operator kernel function is called through the operator kernel function to obtain the image pixel data sent by the processing layer, and the calculation function of the target operator is called through the operator kernel function according to the pointer, and operations are performed on each pixel point of the image pixel data until the arithmetic operation result of the image data is obtained, thereby unifying the behavior of the operator kernel function; thereby realizing the operation of various different operators through a unified internal interface of an external API, a unified behavior of a processing layer, and a unified behavior of an operator kernel function, reducing the workload of code maintenance and increasing the flexibility of the software. This method can not only improve the speed and efficiency of image processing, but also has good flexibility and scalability, and can adapt to different data types and image formats to meet the growing needs of image processing.

[0064] More specifically, step 102 specifically includes: searching in a pre-stored mapping table according to the data type datatype and operation mode opmode of the target operator received to obtain a corresponding call function pointer; wherein the key of the mapping table is a combination of the operation mode and the data type, and the value is a call function pointer pointing to the calculation function that actually performs the operation.

[0065] It should be noted that what is found in the mapping table is not the operator itself, but a call function pointer. The retrieved function pointer is used to call the GeneralLauncher::call function, which generates the opCalculator object of the corresponding pixel arithmetic operation rule according to the data type DataType and the operation mode OPMode.

[0066] More specifically, when operating an image through an operator kernel function, it is necessary to segment the image and then process the pixels of each segment in parallel. Figure 3 , step 103 comprises: 301. Call the operator kernel function through the operator kernel function to obtain the image pixel data sent by the processing layer, and cut the image pixel data into blocks according to the resources of the graphics card and the size of the image pixel data.

[0067] This does not physically slice the image data in memory, but logically divides the image into multiple parts that can be processed in parallel. Each thread block consists of multiple threads that can execute simultaneously, and each thread is responsible for processing a small block or pixel of the image.

[0068] 302. Call the calculation function of the target operator according to the pointer through the operator kernel function, and perform operations on each pixel point of each block in parallel until the calculation of all blocks is completed, so as to obtain the result of the arithmetic operation of the whole image.

[0069] Within each tile, the threads move pointers to access the correct pixel data based on their index within the tile and the layout of the tile. This is to ensure that each thread has access to the portion of the image data that it is supposed to process.

[0070] Threads in the kernel layer directly access image data in GPU memory. In GPU programming, shared memory or texture memory is usually used to improve data access efficiency.

[0071] Through steps 301 to 302, arithmetic operations on the GPU card can be implemented efficiently and in parallel.

[0072] More specifically, the input interface layer stores a unified internal interface function bppiArithmeticCompInternal, and the processing layer also stores an operator dispatch function ArithmeticCompDispatcher. The internal interface function executes step 101, and the operator dispatch function executes step 102.

[0073] Their responsibilities when processing image arithmetic operation requests are as follows: bppiArithmeticCompInternal function: This is an internally used function that serves as a bridge between the API input interface layer and subsequent processing layers. It receives parameters from the input interface layer and further calls appropriate internal functions or processing logic based on these parameters. This function may use template parameters (such as DataType) to support multiple data types, ensuring that arithmetic operations can adapt to different image formats.

[0074] ArithmeticCompDispatcher operator dispatch function: The operator dispatch function (dispatcher) is usually used to select and call the correct function or method based on runtime parameters. In this scenario, ArithmeticCompDispatcher determines which specific arithmetic operation function should be executed based on the provided data type DataType (such as the width and type of image data) and operator type (such as addition, subtraction, etc.).

[0075] It is responsible for constructing or accessing a mapping table, which is a lookup table that maps data types DataType and sub-operator types to specific function implementations. This mapping table may use a data structure such as std::unordered_map to store the mapping of different DataType and sub-operator types to function pointers. Each entry in the table is associated with a specific arithmetic operation implementation, which is a function specialization based on different data types and operations.

[0076] Runtime dispatch: When ArithmeticCompDispatcher receives an arithmetic operation request, it queries the mapping table to find the corresponding function pointer. Then, the operator dispatch function dispatcher calls this function pointer, triggering the actual arithmetic operation.

[0077] Flexibility and scalability: By using the operator dispatch function dispatcher and function table, the system can easily add new DataType or sub-operator type without modifying the existing function call logic. This design improves the flexibility and scalability of the system and makes maintenance and updates easier.

[0078] Performance optimization: Dispatcher can quickly find and call the appropriate function at runtime, reducing conditional statements and branch logic, which helps improve performance. In this way, bppiArithmeticCompInternal and ArithmeticCompDispatcher work together to provide a flexible, efficient, and easily extensible mechanism to handle various image arithmetic operation requests.

[0079] See also Figure 4 , Figure 4 A schematic diagram of an image processing method of this embodiment is shown, which specifically includes: 401. Receive image data that requires arithmetic operation through a unified internal interface of an input interface layer, and determine a target operator among operators supported by the unified internal interface.

[0080] There are many operators, for example, including: Bppimulcscale_8u_C3R_ctx operator, Bppiabsdiffc_32f_C1R_ctx operator, Bppimulcscale_16u_C1R operator and Bppidiv_round_8u_C1Rsfs_ctx operator.

[0081] The API parameters of the target operator include the operator's data type datatype, operation mode opmode, and the image data.

[0082] 402. The received image data is converted into image pixel data according to the data type datatype of the target operator through the processing layer, and transmitted to the operator kernel function layer.

[0083] 403. The processing layer searches a pre-stored mapping table according to the data type datatype and the operation mode opmode of the target operator, and obtains a corresponding call function pointer for the operator kernel function to call.

[0084] There are many types of call function pointers, such as: Generallauncher <mulcscale>::call function pointer, Generallauncher <divround>::call function pointer, Generallauncher <addproduct>::call function pointer and Generallauncher <absdiff>::call function pointer, etc.

[0085] 404. Call the operator kernel function through the operator kernel function to obtain the image pixel data sent by the processing layer.

[0086] 405. Cut the image pixel data into blocks according to the resources of the graphics card and the size of the image pixel data.

[0087] 406. Call the calculation function of the target operator according to the pointer through the operator kernel function, and perform operations on each pixel point of each block in parallel until the calculation of all blocks is completed, so as to obtain the result of the arithmetic operation of the whole image.

[0088] The application of this method unifies the internal interfaces of many operator APIs, unifies the behavior of the processing layer, and unifies the behavior of the operator kernel function to realize the calculation of various Arithmetic operators, reduces the workload of code maintenance, and increases the flexibility of the software. When adding new operators, the modification amount is small, which increases the maintainability, extensibility, and robustness of the code.

[0089] The following is a description of the apparatus for performing image processing through an arithmetic operator class provided by the present invention. The apparatus for performing image processing through an arithmetic operator class described below and the method for performing image processing through an arithmetic operator class described above can be referred to each other in correspondence.

[0090] The present invention provides a device for image processing by using an arithmetic operator class, which is used in an image processing system. The system includes an input interface layer, a processing layer and an operator kernel function layer. Figure 5 , the device comprises: The interface layer processing module 501 is used to receive the image data that needs to be subjected to arithmetic operation through the unified internal interface of the input interface layer, and determine the target operator among the operators supported by the unified internal interface, wherein the API parameters of the target operator include the data type and operation mode of the operator and the image data; The processing layer processing module 502 is used to convert the received image data into image pixel data according to the data type of the target operator through the processing layer and transmit it to the operator kernel function layer, and search in a pre-stored mapping table according to the received data type and operation mode of the target operator to obtain a pointer to a calculation function of a corresponding operation mode for processing each pixel point for the operator kernel function to call; wherein the mapping table stores a pointer mapping of combinations of different operation modes and data types to corresponding calculation functions; The kernel function layer processing module 503 is used to call the operator kernel function through the operator kernel function layer, obtain the image pixel data sent by the processing layer, call the calculation function of the target operator according to the pointer through the operator kernel function, and perform operations on each pixel point of the image pixel data until the arithmetic operation result of the image data is obtained.

[0091] Optionally, the device further comprises an internal interface generating module, configured to: Determine multiple arithmetic operator classes supported by the input interface layer, as well as API parameters of each operator of each arithmetic operator class and enumeration values ​​of each operator, wherein the API parameters include image types; and form a unified internal interface based on the image types and enumeration values ​​of each operator as template parameters.

[0092] Optionally, the processing layer processing module 502 is specifically configured to: According to the data type and operation mode of the received target operator, a search is performed in a pre-stored mapping table to obtain a corresponding call function pointer; wherein the key of the mapping table is a combination of the operation mode and the data type, and the value is a call function pointer pointing to the calculation function that actually performs the operation.

[0093] Optionally, the kernel function layer processing module 503 is specifically used to: The operator kernel function is called through the operator kernel function to obtain the image pixel data sent by the processing layer, and the image pixel data is cut into blocks according to the resources of the graphics card and the size of the image pixel data; The calculation function of the target operator is called according to the pointer through the operator kernel function, and the operation is performed in parallel on each pixel point of each cut block until the calculation of all the cut blocks is completed, thereby obtaining the result of the arithmetic operation of the entire image.

[0094] Optionally, the input interface layer stores a unified internal interface function, and the processing layer also stores an operator dispatch function; The processing layer processing module 502 is specifically used to: call the operator dispatching function through the internal interface function, and convert the received image data into image pixel data according to the data type of the target operator through the called operator dispatching function and transmit it to the operator kernel function layer.

[0095] Optionally, the device further includes a mapping table generating module, configured to: The operator dispatch function receives the data type and operation mode of each operator as input, and determines the function pointer corresponding to each operator to associate the corresponding arithmetic operation; The data type and operation mode of each operator are mapped to the function pointer corresponding to each operator through the operator dispatching function to obtain the mapping table.

[0096] Figure 6 An example of a physical structure diagram of an electronic device is shown in FIG. Figure 6 As shown, the electronic device may include: a processor (processor) 610 , a communication interface (Communications Interface) 620 , a memory (memory) 630 and a communication bus 640 , wherein the processor 610 , the communication interface 620 , and the memory 630 communicate with each other through the communication bus 640 . The processor 610 can call the logic instructions in the memory 630 to execute a method for image processing through an arithmetic operator class, the method comprising: receiving image data that requires arithmetic operation through a unified internal interface of the input interface layer, and determining a target operator among the operators supported by the unified internal interface, wherein the API parameters of the target operator include the data type, operation mode and image data of the operator; converting the received image data into image pixel data according to the data type of the target operator through the processing layer and transmitting the data to the operator kernel function layer, and searching in a pre-stored mapping table according to the received data type and operation mode of the target operator to obtain a pointer to a calculation function of a corresponding operation mode for processing each pixel point for the operator kernel function to call; wherein the mapping table stores a mapping of pointers of combinations of different operation modes and data types to corresponding calculation functions; calling the operator kernel function through the operator kernel function layer to obtain the image pixel data sent by the processing layer, calling the calculation function of the target operator according to the pointer through the operator kernel function, and performing operations on each pixel point of the image pixel data until the arithmetic operation result of the image data is obtained.

[0097] In addition, the logic instructions in the above-mentioned memory 630 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.

[0098] On the other hand, the present invention also provides a computer program product, which includes a computer program, which can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the method for performing image processing through an arithmetic operator class provided by the above methods, the method including: receiving image data that needs to be arithmetic operated through a unified internal interface of an input interface layer, and determining a target operator among operators supported by the unified internal interface, wherein the API parameters of the target operator include a data type, an operation mode, and image data of the operator; converting the received image data into image pixel data according to the data type of the target operator through a processing layer and transmitting the data to an operator kernel function layer, and searching in a pre-stored mapping table according to the received data type and operation mode of the target operator to obtain a pointer to a calculation function of a corresponding operation mode for processing each pixel point for calling by the operator kernel function; wherein the mapping table stores a pointer mapping of combinations of different operation modes and data types to corresponding calculation functions; calling the operator kernel function through the operator kernel function layer to obtain the image pixel data sent by the processing layer, calling the calculation function of the target operator according to the pointer through the operator kernel function, and performing operations on each pixel point of the image pixel data until an arithmetic operation result of the image data is obtained.

[0099] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to execute the method for performing image processing through an arithmetic operator class provided by the above-mentioned methods, the method comprising: receiving image data that requires arithmetic operation through a unified internal interface of an input interface layer, and determining a target operator among operators supported by the unified internal interface, wherein the API parameters of the target operator include a data type, an operation mode, and image data of the operator; converting the received image data into image pixel data according to the data type of the target operator through a processing layer, and transmitting the data to an operator kernel function layer, and searching in a pre-stored mapping table according to the received data type and operation mode of the target operator, to obtain a pointer to a calculation function of a corresponding operation mode for processing each pixel point, for the operator kernel function to call; wherein the mapping table stores a mapping of pointers from combinations of different operation modes and data types to corresponding calculation functions; calling the operator kernel function through the operator kernel function layer to obtain the image pixel data sent by the processing layer, calling the calculation function of the target operator according to the pointer through the operator kernel function, and performing operations on each pixel point of the image pixel data until an arithmetic operation result of the image data is obtained.

[0100] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.

[0101] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.

[0102] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.< / absdiff> < / addproduct> < / divround> < / mulcscale>

Claims

1. A method for image processing by arithmetic operator classes, characterized in that: Used in an image processing system, the system comprises an input interface layer, a processing layer and an operator kernel function layer, and the method comprises: Receiving image data that needs to be subjected to arithmetic operation through a unified internal interface of an input interface layer, and determining a target operator among operators supported by the unified internal interface, wherein API parameters of the target operator include a data type and an operation mode of the operator and the image data; The received image data is converted into image pixel data according to the data type of the target operator through the processing layer and transmitted to the operator kernel function layer, and a search is performed in a pre-stored mapping table according to the received data type and operation mode of the target operator to obtain a pointer to a calculation function of a corresponding operation mode for processing each pixel point for the operator kernel function to call; wherein the mapping table stores a pointer mapping of combinations of different operation modes and data types to corresponding calculation functions; The operator kernel function is called through the operator kernel function layer to obtain the image pixel data sent by the processing layer, and the calculation function of the target operator is called through the operator kernel function according to the pointer to perform operations on each pixel point of the image pixel data until the arithmetic operation result of the image data is obtained.

2. The method for image processing by arithmetic operator class according to claim 1, characterized in that: The unified internal interface of the input interface layer is implemented by the following method: Determine a plurality of arithmetic operator classes supported by the input interface layer, and API parameters of each operator of each arithmetic operator class and enumeration values ​​of each operator, wherein the API parameters include an image type; A unified internal interface is formed based on the image type and enumeration value of each operator as template parameters.

3. The method for image processing by arithmetic operator class according to claim 1, characterized in that: According to the received data type and operation mode of the target operator, a search is performed in a pre-stored mapping table to obtain a pointer to a calculation function corresponding to the operation mode for processing each pixel point, specifically including: According to the data type and operation mode of the received target operator, a search is performed in a pre-stored mapping table to obtain a corresponding call function pointer; wherein the key of the mapping table is a combination of the operation mode and the data type, and the value is a call function pointer pointing to the calculation function that actually performs the operation.

4. The method for image processing by arithmetic operator class according to claim 1, characterized in that: The calculation function of the target operator is called according to the pointer by the operator kernel function to perform operations on each pixel point of the image pixel data until an arithmetic operation result of the image data is obtained, including: The operator kernel function is called through the operator kernel function to obtain the image pixel data sent by the processing layer, and the image pixel data is cut into blocks according to the resources of the graphics card and the size of the image pixel data; The calculation function of the target operator is called according to the pointer through the operator kernel function, and the operation is performed in parallel on each pixel point of each cut block until the calculation of all the cut blocks is completed, thereby obtaining the result of the arithmetic operation of the entire image.

5. The method for image processing by arithmetic operator class according to claim 1, characterized in that: The input interface layer stores a unified internal interface function, and the processing layer also stores an operator dispatch function; The received image data is converted into image pixel data according to the data type of the target operator through the processing layer and transmitted to the operator kernel function layer, specifically including: The operator dispatching function is called through the internal interface function, and the received image data is converted into image pixel data according to the data type of the target operator through the called operator dispatching function and transmitted to the operator kernel function layer.

6. The method for image processing by arithmetic operator class according to claim 5, characterized in that: The mapping table is generated in the following way: The operator dispatch function receives the data type and operation mode of each operator as input, and determines the function pointer corresponding to each operator to associate the corresponding arithmetic operation; The data type and operation mode of each operator are mapped to the function pointer corresponding to each operator through the operator dispatching function to obtain the mapping table.

7. A device for image processing by arithmetic operator class, characterized in that Used in an image processing system, the system comprises an input interface layer, a processing layer and an operator kernel function layer, and the device comprises: The interface layer processing module is used to receive the image data that needs to be subjected to arithmetic operation through the unified internal interface of the input interface layer, and determine the target operator among the operators supported by the unified internal interface, wherein the API parameters of the target operator include the data type and operation mode of the operator and the image data; The processing layer processing module is used to convert the received image data into image pixel data according to the data type of the target operator through the processing layer and transmit it to the operator kernel function layer, and search in the pre-stored mapping table according to the received data type and operation mode of the target operator to obtain the pointer of the calculation function of the corresponding operation mode for processing each pixel point for the operator kernel function to call; wherein the mapping table stores the pointer mapping of the combination of different operation modes and data types to the corresponding calculation function; The kernel function layer processing module is used to call the operator kernel function through the operator kernel function layer, obtain the image pixel data sent by the processing layer, call the calculation function of the target operator according to the pointer through the operator kernel function, and perform operations on each pixel point of the image pixel data until the arithmetic operation result of the image data is obtained.

8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the method for performing image processing by using an arithmetic operator class as described in any one of claims 1 to 6 is implemented.

9. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method for performing image processing by using an arithmetic operator class as claimed in any one of claims 1 to 6 is implemented.

10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the method for performing image processing by using an arithmetic operator class as claimed in any one of claims 1 to 6 is implemented.

Citation Information

Cited By

  • Image filtering method and device based on kernel function selection, medium and product

    CN121213361A

  • An image filtering method, device, medium and product based on kernel function selection

    CN121213361B