Image processing method, device, computing equipment and medium based on OpenCL
By using OpenCL-based GPU computing devices in image processing for parallel processing, the problem of high-resolution image processing is solved, fast image denoising and edge enhancement is achieved, and processing efficiency and frame rate are improved.
Patent Information
- Application Number
- CN202210449332.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-24
- Publication Date
- 2024-12-03
- Estimated Expiration
- 2042-04-24
AI Technical Summary
At this stage, when facing high-resolution images, especially when complexity is high, it is difficult to complete tasks efficiently by relying solely on the CPU, resulting in slow computing speed and low processing efficiency, especially in handheld infrared thermal imagers. The frame rate of the picture is low and the resource consumption is too much.
The GPU computing device based on OpenCL is used for parallel processing, and the pre-processed stretched images are denoised and edge-enhanced on the parallel processing platform. The parallel computing power of OpenCL is used to accelerate image processing, reduce CPU computing volume, and save CPU resources.
It realizes the fast computing speed and better effect of image processing, improves the efficiency of image processing, reduces CPU resource usage, and improves the frame rate of the picture.
Smart Images

Figure CN114820277B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image data processing, and in particular to an OpenCL-based image parallel processing method, device, computing equipment and medium. Background Art
[0002] Image enhancement is an important technical field in digital image processing. Since the image acquisition process is easily affected by the external environment, such as night, fog, or rainy days, the image quality is greatly reduced.
[0003] In the process of implementing the technical solutions in the embodiments of the present application, the inventors of the present application found that the above technology has at least the following technical problems:
[0004] At present, the main problems of image enhancement include local contrast enhancement, adaptive brightness adjustment, effective elimination of halo phenomenon and denoising edge processing. With the continuous development of technology, the resolution of collected images is constantly improving. Image enhancement often faces massive amounts of data. Especially when the image enhancement processing complexity is high, it is extremely difficult to rely solely on the CPU to achieve high-quality completion of the task.
[0005] It should be noted that the information disclosed in the above background technology section is only used to enhance the understanding of the background of the present disclosure, and therefore may include information that does not constitute the prior art known to ordinary technicians in the field. Summary of the invention
[0006] In view of at least one of the above technical problems, the present application provides an OpenCL-based image parallel processing method, apparatus, computing device and medium. The OpenCL-based GPU computing device performs denoising and edge enhancement on the image, and the parallel processing platform can perform parallel calculations, with a fast computing speed and better image processing effect.
[0007] According to an embodiment of the first aspect of the present application, there is provided an OpenCL-based image processing method, including:
[0008] Output the pre-processed stretched image to the parallel processing platform;
[0009] receiving an enhanced image processed by the parallel processing platform;
[0010] The parallel processing platform is a GPU computing device based on OpenCL, and the enhanced image is generated after the parallel processing platform performs denoising and edge enhancement on the stretched image.
[0011] In some implementations, before the preprocessing, the method further includes:
[0012] Acquire a target image, wherein the target image includes a gray component, a red component, and a blue component, wherein the ratio of the gray component, the blue component, and the red component is 2:1:1;
[0013] An extraction conversion operation is performed on the target image to generate a grayscale image, wherein the extraction conversion operation includes extracting the grayscale component.
[0014] In some implementations, the preprocessing includes: a first processing rule, the first processing rule including:
[0015] Dividing the grayscale image into a plurality of first pre-processed image blocks, wherein the first pre-processed image blocks have n*n pixel blocks;
[0016] Obtaining pixel values on each of the pixel blocks;
[0017] When the pixel value on the pixel block exceeds the set pixel threshold, the excess portion of the pixel value on the pixel block is distributed to another pixel block below the set pixel threshold;
[0018] When the pixel value on the pixel block does not exceed the set pixel threshold, a first preprocessing result image block is generated.
[0019] In some implementations, the preprocessing further includes: a second processing rule, wherein the second processing rule includes:
[0020] Obtaining corner pixel information of the first preprocessing result image block, including first pixel information, second pixel information, third pixel information and fourth pixel information, wherein the first pixel information includes a first pixel value and a first pixel coordinate value, the second pixel information includes a second pixel value and a second pixel coordinate value, the third pixel information includes a third pixel value and a third pixel coordinate value, and the fourth pixel information includes a fourth pixel value and a fourth pixel coordinate value, wherein the horizontal axis coordinate of the first pixel coordinate value is the same as the horizontal axis coordinate of the second pixel coordinate value, the vertical axis coordinate of the first pixel coordinate value is the same as the vertical axis coordinate of the third pixel coordinate value, and the horizontal axis coordinate of the third pixel coordinate value is the same as the horizontal axis coordinate of the fourth pixel coordinate value;
[0021] Get the reference point coordinate value of the reference point;
[0022] Determine a first interpolation pixel value of a first interpolation point according to the first pixel value, the second pixel value, the first pixel point coordinate value, the second pixel point coordinate value, and the reference point coordinate value;
[0023] Determine a second interpolation pixel value of the second interpolation point according to the third pixel value, the fourth pixel value, the third pixel point coordinate value, the fourth pixel point coordinate value, and the reference point coordinate value;
[0024] Determine a reference point pixel value of the reference point according to the first interpolated pixel value and the second interpolated pixel value;
[0025] Generating a second preprocessing result image block according to the reference point pixel value;
[0026] The stretched image is generated according to a plurality of the second preprocessing result image blocks.
[0027] In some implementations, the parallel processing platform is configured to receive the stretched image and the grayscale image, perform guided filtering on the stretched image and the grayscale image, and then output the enhanced image.
[0028] According to an embodiment of the second aspect of the present application, there is provided an OpenCL-based image processing device, including:
[0029] An output module, used for outputting the pre-processed stretched image to a parallel processing platform;
[0030] A receiving module, used for receiving the enhanced image processed by the parallel processing platform;
[0031] The parallel processing platform is a GPU computing device based on OpenCL, and the enhanced image is generated after the parallel processing platform performs denoising and edge enhancement on the stretched image.
[0032] In some implementations, the acquisition module is used to acquire a target image, wherein the target image includes a gray component, a red component, and a blue component, wherein the ratio of the gray component, the blue component, and the red component is 2:1:1;
[0033] The conversion module is used to perform an extraction conversion operation on the target image and generate a grayscale image, wherein the extraction conversion operation includes extracting the grayscale component.
[0034] In some implementations, the first processing module is configured to execute a first processing rule;
[0035] The second processing module is used to execute the second processing rule.
[0036] According to an embodiment of the third aspect of the present application, there is provided a computing device, including a memory and a processor;
[0037] The storage device is used to store computer programs;
[0038] The processor is used to implement the image processing method based on OpenCL in the embodiment of the first aspect of the present application when executing the computer program.
[0039] According to an embodiment of the fourth aspect of the present application, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the image processing method based on OpenCL in the embodiment of the first aspect of the present application is implemented.
[0040] The present application has the following technical effects: an OpenCL-based GPU computing device performs denoising and edge enhancement on an image, and the parallel processing platform can perform parallel computing, with a fast computing speed and better image processing effect.
[0041] The present invention is further described below in conjunction with the accompanying drawings and embodiments. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only 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.
[0043] Figure 1 This is a first flow chart of the OpenCL-based image processing method according to an embodiment of the present application;
[0044] Figure 2 A second flow chart of the OpenCL-based image processing method according to an embodiment of the present application;
[0045] Figure 3 A third flow chart of the OpenCL-based image processing method according to an embodiment of the present application;
[0046] Figure 4 A flowchart of executing the first processing rule according to an embodiment of the present application;
[0047] Figure 5 This is an example diagram of the first processing rule of an embodiment of the present application;
[0048] Figure 6 A flowchart of executing the second processing rule according to an embodiment of the present application;
[0049] Figure 7 is a schematic diagram of the structure of an OpenCL-based image processing device in an embodiment of the present application;
[0050] Figure 8 A schematic diagram of the structure of a computing device according to an embodiment of the present application; DETAILED DESCRIPTION
[0051] In order to make the above-mentioned purposes, features and advantages of the present application more obvious and easy to understand, the specific implementation methods of the present application are described in detail below in conjunction with the accompanying drawings. In the following description, many specific details are set forth to facilitate a full understanding of the present application. However, the present application can be implemented in many other ways different from those described herein, and those skilled in the art can make similar improvements without violating the connotation of the present application, so the present application is not limited by the specific embodiments disclosed below.
[0052] The image processing method provided in the present application can be applied to electronic devices including a central processing unit (CPU) and an embedded neural network processing unit (NPU), and the electronic devices include but are not limited to cameras, video cameras, smart cameras, smart camcorders, smart mobile terminals (such as mobile phones, tablet computers, etc.), smart televisions and other portable terminals.
[0053] The image processing method provided in the present application can also be applied to a video playback device in a video surveillance system, or implemented by a cloud server in a video surveillance system. Exemplary embodiments of portable terminals include, but are not limited to, portable terminals equipped with iOS, Android, Microsoft or other operating systems. The portable terminal may also be a laptop computer (Laptop) such as one with a touch-sensitive surface (e.g., a touch panel). It should also be understood that in some other embodiments, the terminal may also be a desktop computer with a touch-sensitive surface (e.g., a touch panel).
[0054] Specifically, the image processing method provided in the present application is mainly used in handheld infrared thermal imagers.
[0055] Existing handheld infrared thermal imagers generally only use the CPU to process the image enhancement algorithm. Due to the limited computing and processing speed of the CPU, the computing control of other modules of the handheld infrared thermal imager must be taken into account. There are the following shortcomings: first, the running time is too long, resulting in a low frame rate; second, the algorithm occupies a lot of CPU resources, resulting in insufficient resources allocated to the software. In short, using a single CPU to process images has a slow computing speed, low processing efficiency, and the frame rate of the picture will also be affected to a certain extent.
[0056] Figure 1 FIG. 1 is a first flow chart of an OpenCL-based image processing method according to an embodiment of the present application, including steps 500 to 600. Figure 1 As shown, according to an embodiment of the first aspect of the present application, an OpenCL-based image processing method is provided, comprising:
[0057] In step 500, the stretched image after preprocessing is output to the parallel processing platform. In the embodiment of the present application, the CPU outputs the stretched image after preprocessing to the parallel processing platform, so that the parallel processing platform performs guided filtering on the stretched image, reducing the amount of CPU calculation and processing, and saving CPU calculation resources.
[0058] Specifically, the steps for building a parallel processing platform are as follows: first, use the clGetPlatformIDs function to obtain platform information, which includes the number of OpenCL platforms supported and the type of platform, generally the CPU model or GPU model; second, select a platform that supports OpenCL, use the clGetPlatformInfo function to query the number of OpenCL devices supported by the current GPU platform, as well as the device support interface version information, and select a device; third, use the OpenCL interface function clCreateContext to create a context on the selected device, and use the clCreateCommandQueue function to create a queue for interaction between the host side (memory and CPU) and the GPU device side; third, load the self-written running kernel and compile it into the program to be run, which contains the guided filtering algorithm, and the compiled running kernel is in the above-created context. The parallel processing platform and the CPU are jointly set inside the handheld infrared thermal imager. When the image needs to be denoised and edge filtered, the image is output from the CPU to the parallel processing platform for guided filtering. After the processing is completed, the parallel processing platform outputs the processed image to the CPU.
[0059] When the stretched image is written to the OpenCL image buffer, parameters are assigned to the running kernel in the context, the kernel is run in the queue, and the stretched image is filtered. The guided filtering algorithm running in the queue will perform operations according to the configuration parameters, greatly accelerating the running efficiency of the algorithm, and only the guided filtering algorithm is run in the parallel computing platform, that is, only denoising and edge enhancement operations are performed on the stretched image, further accelerating the processing efficiency of the stretched image. After filtering, an enhanced image is generated.
[0060] The parallel processing platform can configure the GPU device for parallel computing through parameters. Compared with the serial computing of a single CPU in the prior art, the parallel processing platform has a faster computing speed. In addition, the parallel computing within the work group of OpenCL in the parallel processing platform can further accelerate the guided filtering processing.
[0061] Furthermore, the specific steps of guided filtering processing are:
[0062] A grayscale image I and a stretched image P are received.
[0063] Use the integral image to calculate the first mean parameter mean of the grayscale image I I and the first variance parameter Var I , the second mean parameter mean of the stretched image P P , the product parameter IP of the grayscale image I and the stretched image P.
[0064] According to the product parameter IP, the first mean parameter mean I , the second mean parameter mean P , the first variance parameter Var I and adjusting parameter ε, generating a linear correlation factor a through the first mapping relationship;
[0065] The adjustment parameter ε is a fixed parameter, which is used to adjust the blur degree and edge detection accuracy of the image.
[0066] The first mapping relationship is: a=(IP-mean I *mean P ) / (Var I +ε)
[0067] According to the first mean parameter mean I , the second mean parameter mean P and linear correlation factor a, generating a linear correlation factor b through a second mapping relationship;
[0068] The second mapping relationship is: b = mean P -a*mean I
[0069] Generate the third mean parameter mean based on the linear correlation factor a and the linear correlation factor b a And the fourth mean parameter mean b .
[0070] According to the third mean parameter mean a 、The fourth mean parameter mean b and the grayscale image I, generating an enhanced image Q through a third mapping relationship;
[0071] The third mapping relationship is: Q = mean a *I+mean b
[0072] In step 600, an enhanced image processed by the parallel processing platform is received;
[0073] The parallel processing platform is a GPU computing device based on OpenCL, and the enhanced image is generated after the parallel processing platform performs denoising and edge enhancement on the stretched image.
[0074] The GPU computing device based on OpenCL performs denoising and edge enhancement on the image, and the parallel processing platform can perform parallel computing, with fast computing speed and better image processing effect.
[0075] In addition, the method further includes step 700, in which the enhanced image is dyed. In this embodiment, the enhanced image is a single-channel grayscale image, and the three RGB channels corresponding to the grayscale values are dyed respectively by looking up a predefined pseudo color table.
[0076] In other embodiments, Figure 2 This is a second flow chart of the OpenCL-based image processing method according to an embodiment of the present application. Figure 2 As shown, before the preprocessing, the process further includes steps 100 to 200.
[0077] In step 100, a target image is obtained, wherein the target image includes a gray component, a red component, and a blue component, wherein the ratio of the gray component, the blue component, and the red component is 2:1:1;
[0078] In step 200, an extraction conversion operation is performed on the target image to generate a grayscale image, wherein the extraction conversion operation includes extracting the grayscale component.
[0079] In this embodiment, an infrared detection module is internally disposed in the handheld infrared thermal imager, and the chip array size in the infrared detection module is 384*288, that is, the pixels that can acquire the target image.
[0080] In other embodiments, Figure 3 This is a third flow chart of the OpenCL-based image processing method according to an embodiment of the present application. Figure 4 This is a flowchart of executing the first processing rule in the embodiment of the present application; Figure 3 and Figure 4 As shown, step 300 is included.
[0081] The pre-processing includes: a first processing rule, the step 300 is to execute the first processing rule, and the first processing rule includes: steps 310-340.
[0082] In step 310, the grayscale image is divided into a plurality of first pre-processed image blocks, wherein the first pre-processed image blocks have n*n pixel blocks;
[0083] In step 320, the pixel value of each pixel block is obtained;
[0084] In step 330, when the pixel value on the pixel block exceeds the set pixel threshold, the excess portion of the pixel value on the pixel block is distributed to another pixel block below the set pixel threshold;
[0085] In step 340, when the pixel value on the pixel block does not exceed the set pixel threshold, a first preprocessing result image block is generated.
[0086] For example, Figure 5 This is an example diagram of the first processing rule of the embodiment of the present application, such as Figure 5 As shown in the figure, it is assumed that the pixel distribution of the first pre-processed image block is 7*7. Assuming that the threshold is set to 5, when the number of pixels of a certain pixel value on the block is 7, the excess part of the number of pixels on the block (i.e. 2) will be distributed to the remaining pixel blocks below the set threshold. In this way, after the first pre-processed image block executes the first processing rule, its grayscale distribution can be more uniform.
[0087] In other embodiments, Figure 6 A flowchart of executing the second processing rule for the embodiment of the present application is shown in FIG. Figure 3 and Figure 6 As shown, the pre-processing further includes: a second processing rule, step 400 is to execute the second processing rule;
[0088] The second processing rule includes: steps 410 to 460.
[0089] In the step 410, the corner pixel information of the first preprocessing result image block is obtained, including first pixel information, second pixel information, third pixel information and fourth pixel information, the first pixel information includes a first pixel value and a first pixel coordinate value, the second pixel information includes a second pixel value and a second pixel coordinate value, the third pixel information includes a third pixel value and a third pixel coordinate value, the fourth pixel information includes a fourth pixel value and a fourth pixel coordinate value, wherein the horizontal axis coordinate of the first pixel coordinate value is the same as the horizontal axis coordinate of the second pixel coordinate value, the vertical axis coordinate of the first pixel coordinate value is the same as the vertical axis coordinate of the third pixel coordinate value, and the horizontal axis coordinate of the third pixel coordinate value is the same as the horizontal axis coordinate of the fourth pixel coordinate value;
[0090] In this embodiment, the first pixel value is f(Q11), and the coordinate value of the first pixel point is (x1, y1); the second pixel value is f(Q21), and the coordinate value of the second pixel point is (x2, y1); the third pixel value is f(Q12), and the coordinate value of the third pixel point is (x1, y2); the fourth pixel value is f(Q22), and the coordinate value of the fourth pixel point is (x2, y2).
[0091] In the step 420, the reference point coordinate value of the reference point is obtained;
[0092] In step 420, the reference point is any point in the first preprocessing result image block. The reference point coordinate value is (x, y)
[0093] In the step 430, a first interpolation pixel value of a first interpolation point is determined according to the first pixel value, the second pixel value, the first pixel point coordinate value, the second pixel point coordinate value, and the reference point coordinate value;
[0094] In this embodiment, according to the formula:
[0095]
[0096] The first interpolated pixel value is f(x, y1).
[0097] In step 440, a second interpolation pixel value of the second interpolation point is determined according to the third pixel value, the fourth pixel value, the third pixel point coordinate value, the fourth pixel point coordinate value, and the reference point coordinate value;
[0098] In this embodiment, according to the formula:
[0099]
[0100] The second interpolated pixel value is f(x, y2).
[0101] In the step 450, a reference point pixel value of the reference point is determined according to the first interpolated pixel value and the second interpolated pixel value;
[0102] In this embodiment, according to the formula:
[0103]
[0104] The reference point pixel value is f(x, y).
[0105] In the step 460, a second preprocessing result image block is generated according to the reference point pixel value;
[0106] In this embodiment, the second preprocessing result image block is generated according to the reference point pixel value. Such processing can reduce certain visual distortions caused by resizing the image to a non-integer scaling factor and reduce the sense of pixel fragmentation generated when executing the first processing rule.
[0107] In step 470, the stretched image is generated according to the plurality of second preprocessing result image blocks.
[0108] In other embodiments, the parallel processing platform is configured to receive the stretched image and the grayscale image, perform guided filtering on the stretched image and the grayscale image, and then output the enhanced image.
[0109] Figure 7 is a schematic diagram of the structure of an OpenCL-based image processing device in an embodiment of the present application, such as Figure 7 As shown, according to an embodiment of the second aspect of the present application, an OpenCL-based image processing device is provided, including:
[0110] The output module S5 is used to output the pre-processed stretched image to the parallel processing platform;
[0111] A receiving module S6, used for receiving the enhanced image processed by the parallel processing platform;
[0112] The parallel processing platform is a GPU computing device based on OpenCL, and the enhanced image is generated after the parallel processing platform performs denoising and edge enhancement on the stretched image.
[0113] The specific limitations of the above-mentioned image processing device can be found in the limitations of the image processing method in the implementation of the first aspect of the present application, and will not be repeated here. Each module in the image processing device can be implemented in whole or in part by software, hardware, and a combination thereof. The above-mentioned devices, modules, or units can be embedded in or independent of the processor in the computing device in the form of hardware, or can be stored in the memory of the computing device in the form of software, so that the processor can call and execute the operations corresponding to the above-mentioned devices or modules.
[0114] In some other embodiments, the acquisition module S1 is used to acquire a target image, wherein the target image includes a gray component, a red component, and a blue component, wherein the ratio of the gray component, the blue component, and the red component is 2:1:1;
[0115] The conversion module S2 is used to perform an extraction conversion operation on the target image and generate a grayscale image, wherein the extraction conversion operation includes extracting the grayscale component.
[0116] In some other embodiments, the first processing module S3 is used to execute the first processing rule;
[0117] The second processing module S4 is used to execute the second processing rule.
[0118] Figure 8 is a schematic diagram of the structure of a computing device according to an embodiment of the present application, such as Figure 8 As shown, according to an embodiment of the third aspect of the present application, a computing device is provided, including a memory and a processor;
[0119] The storage device is used to store computer programs;
[0120] The processor is used to implement the image processing method based on OpenCL in the embodiment of the first aspect of the present application when executing the computer program.
[0121] The computing device 12 may be implemented in the form of a general-purpose computing device. The components of the computing device 12 may include, but are not limited to: one or more processors or processing units 16, a system memory 28, and a bus 18 that connects various system components (including the system memory 28 and the processing unit 16).
[0122] The bus 18 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, a graphics acceleration port, a processor, or a local bus using any of a variety of bus structures. For example, these architectures include but are not limited to Industry Standard Architecture (ISA) bus, Micro Channel Architecture (MAC) bus, Enhanced ISA bus, Video Electronics Standards Association (VESA) local bus, and Peripheral Component Interconnection (PCI) bus.
[0123] Computing device 12 typically includes a variety of computer system readable media. These media can be any available media that can be accessed by computing device 12, including volatile and nonvolatile media, removable and non-removable media.
[0124] The memory 28 may include a computer system readable medium in the form of a volatile memory, such as a random access memory (Random Access Memory; hereinafter referred to as: RAM) 30 and / or a cache memory 32. The computing device 12 may further include other removable / non-removable, volatile / non-volatile computer readable storage media. By way of example only, the storage system 34 may be used to read and write non-removable, non-volatile magnetic media (not shown in the figure, usually referred to as a "hard drive"). Although not shown in the figure, a disk drive for reading and writing a removable non-volatile disk (such as a "floppy disk"), and an optical disk drive for reading and writing a removable non-volatile optical disk (such as a compact disc read-only memory (hereinafter referred to as: CD-ROM), a digital versatile disc read-only disk (hereinafter referred to as: DVD-ROM) or other optical media) may be provided. In these cases, each drive may be connected to the bus 18 via one or more data medium interfaces. The memory 28 may include at least one program product having a set (eg, at least one) of program modules configured to perform the functions of various embodiments of the present disclosure.
[0125] A program / utility 40 having a set (at least one) of program modules 42 may be stored, for example, in the memory 28, such program modules 42 including but not limited to an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment. The program modules 42 generally perform the functions and / or methods of the embodiments described in the present disclosure.
[0126] The computing device 12 may also communicate with one or more external devices 14 (e.g., keyboards, pointing devices, displays 24, etc.), one or more devices that enable a user to interact with the computer system / server 12, and / or any device that enables the computer system / server 12 to communicate with one or more other computing devices (e.g., network cards, modems, etc.). Such communication may be performed via an input / output (I / O) interface 22. In addition, the computing device 12 may also communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) via a network adapter 20. As shown, the network adapter 20 communicates with other modules of the computing device 12 via a bus 18. It should be noted that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the computing device 12, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0127] The processing unit 16 executes various functional applications and data processing by running programs stored in the system memory 28, such as implementing the methods mentioned in the above embodiments.
[0128] The computing device of the present application may be a server or a terminal device with limited computing power.
[0129] According to an embodiment of the fourth aspect of the present application, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the image processing method based on OpenCL in the embodiment of the first aspect of the present application is implemented.
[0130] Generally speaking, the computer instructions for implementing the method of the present application can be carried by any combination of one or more computer-readable storage media. Non-transitory computer-readable storage media can include any computer-readable media except the signal itself that is temporarily propagating.
[0131] Computer-readable storage media can be, for example, but not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or components, or any combination thereof. More specific examples of computer-readable storage media (a non-exhaustive list) include: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM14), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In this document, a computer-readable storage medium can be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, device, or device.
[0132] The computer program code for performing the operation of the present application can be written in one or more programming languages or a combination thereof, including object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" language or similar programming languages, in particular, Python language suitable for neural network computing and platform frameworks based on TensorFlow, PyTorch, etc. can be used. The program code can be executed entirely on the user's computer, partially on the user's computer, as an independent software package, partially on the user's computer and partially on a remote computer, or completely on a remote computer or server. In the case of a remote computer, the remote computer can be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computer (for example, using an Internet service provider to connect through the Internet).
[0133] The above is only a preferred embodiment of the present application and does not constitute any formal limitation to the present application. Any technician familiar with the art can make many possible changes and modifications to the technical solution of the present application by using the above disclosed methods and technical contents without departing from the scope of the technical solution of the present application, or modify it into an equivalent embodiment of equivalent changes. Therefore, all equivalent changes made according to the shape, structure and principle of the present application without departing from the content of the technical solution of the present application should be included in the protection scope of the present application.
Claims
1. An image processing method based on OpenCL, It is characterized in that include: Output the pre-processed stretched image to the parallel processing platform; receiving an enhanced image processed by the parallel processing platform; The parallel processing platform is a GPU computing device based on OpenCL. The steps to build the parallel processing platform are: first, use the clGetPlatformIDs function to obtain platform information; second, select a platform that supports OpenCL, use the clGetPlatformInfo function to query the number of OpenCL devices supported by the current GPU platform, as well as the device support interface version information, and select a device; third, use the OpenCL interface function clCreateContext to create a context on the selected device, and use the clCreateCommandQueue function to create a queue for interaction between the host and GPU device ends; Second, load the running kernel written by yourself and compile it into the program to be run, which includes the guided filtering algorithm. In the context created above, when the image needs to be denoised and edge filtered, the compiled running kernel outputs the image from the CPU to the parallel processing platform for guided filtering. After the processing is completed, the parallel processing platform outputs the processed image to the CPU; when the stretched image is written into the OpenCL image buffer, allocate parameters for the running kernel in the context, run the kernel in the queue, and filter the stretched image. The guided filtering algorithm running in the queue will perform operations according to the configuration parameters, and only the guided filtering algorithm will be run in the parallel computing platform, that is, only the denoising and edge enhancement operations will be performed on the stretched image; The enhanced image is generated after the parallel processing platform performs guided filtering on the stretched image, and the guided filtering step is: receiving a grayscale image I and a stretched image P; Use the integral image to calculate the first mean parameter mean of the grayscale image I I and the first variance parameter Var I , the second mean parameter mean of the stretched image P P , the product parameter IP of the grayscale image I and the stretched image P; According to the product parameter IP, the first mean parameter mean I , the second mean parameter mean P , the first variance parameter Var I and adjusting parameter ε, generating a linear correlation factor a through the first mapping relationship; The adjustment parameter ε is a fixed parameter, which is a parameter for adjusting the blur degree and edge detection accuracy of the image. The first mapping relationship is: ; According to the first mean parameter mean I , the second mean parameter mean P and linear correlation factor a, and generate linear correlation factor b through the second mapping relationship, the second mapping relationship is: ; Generate the third mean parameter mean based on the linear correlation factor a and the linear correlation factor b a And the fourth mean parameter mean b ; According to the third mean parameter mean a 、The fourth mean parameter mean b And the grayscale image I, the enhanced image Q is generated through the third mapping relationship, the third mapping relationship is: .
2. The image processing method based on OpenCL according to claim 1, It is characterized in that Before the preprocessing, it also includes: Acquire a target image, wherein the target image includes a gray component, a red component, and a blue component, wherein the ratio of the gray component, the blue component, and the red component is 2:1:1; An extraction conversion operation is performed on the target image to generate a grayscale image, wherein the extraction conversion operation includes extracting the grayscale component.
3. The image processing method based on OpenCL according to claim 2, It is characterized in that The preprocessing includes: a first processing rule, the first processing rule includes: Dividing the grayscale image into a plurality of first pre-processed image blocks, wherein the first pre-processed image blocks have n*n pixel blocks; Obtaining pixel values on each of the pixel blocks; When the number of pixels of the pixel value on the pixel block exceeds the set threshold, the excess portion of the pixel value is evenly distributed to other pixel blocks whose pixel values are lower than the set threshold; When the number of pixels on the pixel block does not exceed the set threshold, a first preprocessing result image block is generated.
4. The OpenCL-based image processing method according to claim 3, It is characterized in that The pre-processing further includes: a second processing rule, wherein the second processing rule includes: Obtaining corner pixel information of the first preprocessing result image block, including first pixel information, second pixel information, third pixel information and fourth pixel information, wherein the first pixel information includes a first pixel value and a first pixel coordinate value, the second pixel information includes a second pixel value and a second pixel coordinate value, the third pixel information includes a third pixel value and a third pixel coordinate value, and the fourth pixel information includes a fourth pixel value and a fourth pixel coordinate value, wherein the horizontal axis coordinate of the first pixel coordinate value is the same as the horizontal axis coordinate of the second pixel coordinate value, the vertical axis coordinate of the first pixel coordinate value is the same as the vertical axis coordinate of the third pixel coordinate value, and the horizontal axis coordinate of the third pixel coordinate value is the same as the horizontal axis coordinate of the fourth pixel coordinate value; Get the reference point coordinate value of the reference point; Determine a first interpolation pixel value of a first interpolation point according to the first pixel value, the second pixel value, the first pixel point coordinate value, the second pixel point coordinate value, and the reference point coordinate value; Determine a second interpolation pixel value of the second interpolation point according to the third pixel value, the fourth pixel value, the third pixel point coordinate value, the fourth pixel point coordinate value, and the reference point coordinate value; Determine a reference point pixel value of the reference point according to the first interpolated pixel value and the second interpolated pixel value; Generating a second preprocessing result image block according to the reference point pixel value; The stretched image is generated according to a plurality of the second preprocessing result image blocks.
5. The OpenCL-based image processing method according to claim 2, It is characterized in that The parallel processing platform is configured to receive the stretched image and the grayscale image, perform guided filtering on the stretched image and the grayscale image, and then output the enhanced image.
6. An image processing device based on OpenCL, It is characterized in that include: An output module, used for outputting the pre-processed stretched image to a parallel processing platform; A receiving module, used for receiving the enhanced image processed by the parallel processing platform; The parallel processing platform is a GPU computing device based on OpenCL. The steps to build the parallel processing platform are: first, use the clGetPlatformIDs function to obtain platform information; second, select a platform that supports OpenCL, use the clGetPlatformInfo function to query the number of OpenCL devices supported by the current GPU platform, as well as the device support interface version information, and select a device; third, use the OpenCL interface function clCreateContext to create a context on the selected device, and use the clCreateCommandQueue function to create a queue for interaction between the host and GPU device ends; Second, load the running kernel written by yourself and compile it into the program to be run, which includes the guided filtering algorithm. In the context created above, when the image needs to be denoised and edge filtered, the compiled running kernel outputs the image from the CPU to the parallel processing platform for guided filtering. After the processing is completed, the parallel processing platform outputs the processed image to the CPU; when the stretched image is written into the OpenCL image buffer, allocate parameters for the running kernel in the context, run the kernel in the queue, and filter the stretched image. The guided filtering algorithm running in the queue will perform operations according to the configuration parameters, and only the guided filtering algorithm will be run in the parallel computing platform, that is, only the denoising and edge enhancement operations will be performed on the stretched image; The enhanced image is generated after the parallel processing platform performs guided filtering on the stretched image, and the guided filtering step is: receiving a grayscale image I and a stretched image P; Use the integral image to calculate the first mean parameter mean of the grayscale image I I and the first variance parameter Var I , the second mean parameter mean of the stretched image P P , the product parameter IP of the grayscale image I and the stretched image P; According to the product parameter IP, the first mean parameter mean I , the second mean parameter mean P , the first variance parameter Var I and adjusting parameter ε, generating a linear correlation factor a through the first mapping relationship; The adjustment parameter ε is a fixed parameter, which is a parameter for adjusting the blur degree and edge detection accuracy of the image. The first mapping relationship is: ; According to the first mean parameter mean I , the second mean parameter mean P and linear correlation factor a, and generate linear correlation factor b through the second mapping relationship, the second mapping relationship is: ; Generate the third mean parameter mean based on the linear correlation factor a and the linear correlation factor b a And the fourth mean parameter mean b ; According to the third mean parameter mean a 、The fourth mean parameter mean b And the grayscale image I, the enhanced image Q is generated through the third mapping relationship, the third mapping relationship is: .
7. The OpenCL-based image processing device according to claim 6, It is characterized in that An acquisition module is used to acquire a target image, wherein the target image includes a gray component, a red component and a blue component, wherein the ratio of the gray component, the blue component and the red component is 2:1:1; The conversion module is used to perform an extraction conversion operation on the target image and generate a grayscale image, wherein the extraction conversion operation includes extracting the grayscale component.
8. The OpenCL-based image processing device according to claim 6, It is characterized in that A first processing module, used for executing a first processing rule; The second processing module is used to execute the second processing rule.
9. A computing device, It is characterized in that including memory and processor; The memory is used to store computer programs; The processor is configured to implement the OpenCL-based image processing method according to any one of claims 1 to 5 when executing the computer program.
10. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the OpenCL-based image processing method according to any one of claims 1 to 5 is implemented.
