Image processing methods, apparatus, devices and storage media
By dividing the row pixels of an image into multiple data blocks for parallel processing, the problem of low image processing efficiency is solved, and more efficient image processing is achieved.
Patent Information
- Application Number
- CN202611428528.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-15
- Publication Date
- 2026-11-17
AI Technical Summary
Image processing involves large amounts of data, which, due to limitations in hardware computing power, results in low processing efficiency.
The image to be processed is divided into at least two pixel data blocks by using a preset parallel processing amount. The pixels in the cached pixel data blocks are then processed in parallel according to the target processing algorithm. By using block caching combined with parallel processing, the device hardware resources are fully utilized.
Reduce waiting time for neighborhood data, improve image processing efficiency, adapt to the needs of different image processing algorithms, save cache resources, and improve processing efficiency and stability.
Smart Images

Figure CN123118342A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image processing technology, and in particular to an image processing method, apparatus, device, and storage medium. Background Technology
[0002] With the continuous development of science and technology, image processing technology has been widely used in many industries and fields, becoming an important technical means for machine perception and information analysis.
[0003] In practical engineering scenarios, different image processing algorithms (such as image denoising, gradient solving, target feature extraction, etc.) can be used to complete image processing tasks and obtain effective information from the image.
[0004] However, image processing involves large amounts of data, which is constrained by hardware computing power, resulting in low efficiency in related technologies. Summary of the Invention
[0005] Therefore, it is necessary to provide an image processing method, apparatus, device, and storage medium to address the aforementioned technical problems.
[0006] In a first aspect, this application provides an image processing method, comprising:
[0007] The row pixels of the image to be processed are divided into at least two pixel data blocks using a preset parallel processing amount; each pixel data block includes at most the preset parallel processing amount of pixels; the image to be processed includes at least one row of pixels;
[0008] The pixel data blocks are cached according to the target processing algorithm, and the pixels in the cached pixel data blocks with a preset parallel processing amount are processed in parallel according to the target processing algorithm to obtain the processed pixels of each pixel.
[0009] The processed image is determined based on the processed pixels of each pixel in the image to be processed.
[0010] In one embodiment, pixel data block caching is performed according to a target processing algorithm, including:
[0011] When the target processing algorithm includes a denoising filtering algorithm, cache the current data block and the previous data block that is temporally adjacent to the current data block;
[0012] When the target processing algorithm includes a gradient acquisition algorithm, a preset number of pixel data blocks of pixel rows are cached; different rows of pixel data blocks are cached in different areas.
[0013] In one embodiment, pixels in a cached pixel data block with a preset parallel processing capacity are processed in parallel according to a target processing algorithm to obtain processed pixels for each pixel, including:
[0014] The target processing algorithm determines the set of operation pixels for each pixel to be processed in parallel in the cached pixel data block; the set of operation pixels includes any pixel to be processed in parallel and the pixels adjacent to any pixel to be processed in parallel.
[0015] The target processing algorithm is performed in parallel on each set of pixels to obtain the processed pixels.
[0016] In one embodiment, the set of operation pixels for each pixel to be processed in parallel in the cached pixel data block is determined according to the target processing algorithm, including:
[0017] Obtain the pixel matrix information corresponding to the target processing algorithm;
[0018] For each pixel processed in parallel, pixels are retrieved from the cached pixel data block according to the pixel matrix information, and used as the set of pixels for operation.
[0019] In one embodiment, the target processing algorithm includes a gradient acquisition algorithm, and the processed image includes a gradient information image; the method further includes:
[0020] The gradient information image is binarized based on the comparison results between the gradient magnitude of each pixel in the gradient information image and the first preset threshold and the second preset threshold, to obtain a binarized image.
[0021] Output the position information of the boundary pixels of the marked points in the binarized image;
[0022] Marker points are extracted from the image to be processed based on the position information of the boundary pixels of the marker points.
[0023] In one embodiment, the second preset threshold is greater than the first preset threshold; the gradient information image is binarized based on the comparison between the gradient magnitude of each pixel in the gradient information image and the first and second preset thresholds, including:
[0024] Pixels in the gradient information image whose gradient magnitude is greater than the second preset threshold, or whose gradient magnitude is greater than the first preset threshold and which have adjacent pixels whose gradient magnitude is greater than the second preset threshold, are set to the first pixel value.
[0025] Pixels in the gradient information image whose gradient magnitude is less than or equal to a first preset threshold, or whose gradient magnitude is greater than the first preset threshold and which do not have adjacent pixels whose gradient magnitude is greater than the second preset threshold, are set to the second pixel value.
[0026] In one embodiment, the position information of the boundary pixels of the marker points in the binarized image is output based on the binarized image, including:
[0027] Based on the pixel values of each pixel in the pixel data block of the binarized image, the boundary pixels of the marker points in each pixel data block are determined sequentially, and the row and column of the boundary pixels of the marker points in the binarized image are obtained as the position information of the boundary pixels of the marker points.
[0028] When the number of boundary pixels of the marker points reaches the preset parallel processing level, the position information of the boundary pixels of the marker points with the preset parallel processing level is merged and output.
[0029] Secondly, this application also provides an image processing apparatus, comprising:
[0030] The pixel division module is used to divide the row pixels of the image to be processed into at least two pixel data blocks using a preset parallel processing amount; each pixel data block includes at most the preset parallel processing amount of pixels; the image to be processed includes at least one row of pixels;
[0031] The parallel processing module is used to cache pixel data blocks according to the target processing algorithm, and process the pixels in the cached pixel data blocks with a preset parallel processing amount in parallel according to the target processing algorithm to obtain the processed pixels of each pixel.
[0032] The processing result module is used to determine the processed image of the image based on the processed pixels of each pixel in the image to be processed.
[0033] Thirdly, this application also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above-described image processing method.
[0034] Fourthly, this application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps in the above-described image processing method.
[0035] The aforementioned image processing method, apparatus, device, and storage medium divide the row pixels of the image to be processed into at least two pixel data blocks using a preset parallel processing amount. Pixel data blocks are cached according to a target processing algorithm, and the pixels in the cached pixel data blocks, with a preset parallel processing amount, are processed in parallel according to the target processing algorithm to obtain the processed pixels of each pixel. The processed image of the image to be processed is then determined based on the processed pixels of each pixel in the image to be processed. Each pixel data block contains at most a preset parallel processing amount of pixels. The image to be processed contains at least one row of pixels. In the above method, the row pixels are divided into pixel data blocks according to the preset parallel processing amount, and the pixel data blocks are cached based on the target processing algorithm to process multiple pixels within the cached pixel data blocks in parallel. By relying on block caching combined with parallel processing, multiple pixels can be processed at once, thereby reducing the waiting time for neighboring data, fully utilizing the parallel resources of the device hardware, and improving image processing efficiency. Attached Figure Description
[0036] To more clearly illustrate the technical solutions in the embodiments of this application or related technologies, the drawings used in the description of the embodiments of this application or related technologies will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0037] Figure 1 This is an internal structural diagram of a computer device in one embodiment;
[0038] Figure 2 This is a flowchart illustrating an image processing method in one embodiment;
[0039] Figure 3 This is a schematic diagram of the pixel data block caching process in one embodiment;
[0040] Figure 4 This is a schematic diagram illustrating a pixel data block in a cache row pixel in one embodiment;
[0041] Figure 5 This is a schematic diagram illustrating the process of a target processing algorithm in one embodiment.
[0042] Figure 6 This is a schematic diagram illustrating the processing of pixels with a preset parallel data volume in one embodiment.
[0043] Figure 7 This is a flowchart illustrating the process of determining the set of pixels to be processed in one embodiment;
[0044] Figure 8 This is a flowchart illustrating the image processing method in another embodiment;
[0045] Figure 9 This is a schematic diagram of the binarization process in one embodiment;
[0046] Figure 10 This is a flowchart illustrating the output of the position information of the boundary pixels of the marker points in one embodiment;
[0047] Figure 11 This is a schematic diagram illustrating the merging of output location information in one embodiment;
[0048] Figure 12 This is a flowchart illustrating the image processing method in another embodiment;
[0049] Figure 13 This is a structural block diagram of an image processing device in one embodiment. Detailed Implementation
[0050] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0051] It should be noted that the terms "first," "second," etc., used in this application can be used to describe various elements, but these elements are not limited by these terms. These terms are only used to distinguish the first element from the second element. The terms "comprising" and "having," and any variations thereof, used in this application, are intended to cover non-exclusive inclusion. The term "multiple" used in this application refers to two or more. The term "and / or" used in this application refers to one of the embodiments, or any combination of multiple embodiments.
[0052] The image processing method provided in this application embodiment can be applied to, for example... Figure 1The computer device shown can be a terminal and may include a processor, memory, input / output interface, communication interface, display unit, and input device. The processor, memory, and input / output interface are connected via a system bus, and the communication interface, display unit, and input device are also connected to the system bus via the input / output interface. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The input / output interface is used for exchanging information between the processor and external devices. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, mobile cellular networks, Near Field Communication (NFC), or other technologies. When the computer program is executed by the processor, it implements an image processing method. The display unit of the computer device is used to form a visually visible image and may be a display screen, a projection device, or a virtual reality imaging device. The display screen can be an LCD screen or an e-ink screen. The input device of the computer device can be a touch layer covering the display screen, or buttons, trackballs, or touchpads set on the casing of the computer device, or external keyboards, touchpads, or mice, etc.
[0053] It should be noted that the aforementioned computer equipment may be an embedded system / device, and the provided image processing method may be applied to the central processing unit (CPU) or graphics processing unit (GPU) in the computer equipment.
[0054] Those skilled in the art will understand that Figure 1 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0055] In one exemplary embodiment, such as Figure 2 As shown, an image processing method is provided, which is applied to... Figure 1 Taking a computer device as an example, the explanation includes the following steps:
[0056] S210. The row pixels of the image to be processed are divided into at least two pixel data blocks using a preset parallel processing amount; each pixel data block includes at most pixels of the preset parallel processing amount; the image to be processed includes at least one row of pixels.
[0057] The image to be processed comprises at least rows of pixels, and each row of pixels includes a number of pixels. A pixel data block represents an ordered set of pixels obtained by dividing the row data. The preset parallel processing capacity represents the number of pixels that can be processed simultaneously in a single parallel operation. For example, the image to be processed can be a grayscale image or an RGB image.
[0058] Optionally, the computer device may, in response to an image processing instruction, acquire a pixel data stream of the image to be processed, and sequentially divide pixels of a preset parallel processing amount into a group as a pixel data block, so as to divide the row pixels of the image to be processed into at least two pixel data blocks. Except for the last pixel data block obtained by the division, each of the other pixel data blocks includes a preset parallel number of pixels, and the last pixel data block may include fewer pixels than the preset parallel number.
[0059] S220. Cache pixel data blocks according to the target processing algorithm, and process the pixels in the cached pixel data blocks with a preset parallel processing amount in parallel according to the target processing algorithm to obtain the processed pixels of each pixel.
[0060] Here, the target processing algorithm represents the processing algorithm to be performed on the pixels. For example, the target processing algorithm includes processing algorithms involving neighboring pixels. Examples include denoising filtering algorithms, gradient acquisition algorithms, image sharpening algorithms, or morphological operation algorithms, etc. Different target processing algorithms correspond to different caching strategies. The resulting pixel data blocks are cached in the on-chip cache of the computer device, such as Random Access Memory (RAM).
[0061] Optionally, the computer device can parse the image processing instructions, determine the image processing algorithm indicated by the image processing instructions as the target processing algorithm, cache the divided pixel data blocks according to the caching strategy corresponding to the target processing algorithm, and read the cache and call the target processing algorithm to process the pixels in the cached pixel data blocks with a preset parallel processing amount in parallel to obtain the processed pixels of each pixel.
[0062] S230. Determine the processed image of the image to be processed based on the processed pixels of each pixel in the image to be processed.
[0063] Optionally, the computer device can stitch together and reassemble the processed pixels corresponding to all the obtained pixels according to the original pixel arrangement order of the image to be processed to obtain the processed image corresponding to the entire image to be processed.
[0064] It should be noted that the data flow within the computer device for implementing the above image processing methods is as follows:
[0065] The Advanced RISC Machine (ARM) control unit of the computer device can trigger the camera to acquire images to be processed at high speed, and transmit the pixel data stream of the acquired images to the image receiving unit in the FPGA to execute the above image processing method.
[0066] In this embodiment, the row pixels of the image to be processed are divided into at least two pixel data blocks using a preset parallel processing amount. The pixel data blocks are cached according to the target processing algorithm, and the pixels in the cached pixel data blocks with the preset parallel processing amount are processed in parallel according to the target processing algorithm to obtain the processed pixels of each pixel. The processed image of the image to be processed is determined based on the processed pixels of each pixel in the image to be processed. Each pixel data block includes at most the preset parallel processing amount of pixels. The image to be processed includes at least one row of pixels. In the above method, the row pixels are divided into pixel data blocks according to the preset parallel processing amount, and the pixel data blocks are cached based on the target processing algorithm to process multiple pixels in the cached pixel data blocks in parallel. By relying on block caching combined with parallel processing, multiple pixels can be processed at a time, thereby reducing the waiting time of neighboring data, making full use of the parallel resources of the device hardware, and improving the image processing efficiency.
[0067] The target processing algorithm includes processing algorithms that involve neighboring pixels in the calculation. Based on this, in one embodiment, such as... Figure 3 As shown, the pixel data block caching in S220 above according to the target processing algorithm includes:
[0068] S310. If the target processing algorithm includes a denoising filtering algorithm, cache the current data block and the previous data block that is adjacent to the current data block in time sequence.
[0069] Here, the current data block and the previous data block represent two temporally adjacent pixel data blocks obtained from the partitioning, with the previous data block preceding the current data block in temporal order. The denoising filtering algorithm represents the processing algorithm that involves neighboring pixels in the row direction.
[0070] Optionally, if the target processing algorithm includes a processing algorithm in which neighboring pixels in the row direction are involved in the operation, the computer device may cache the current data block and the previous data block that is temporally adjacent to the current data block. For example, if the target processing algorithm includes a denoising filtering algorithm, the computer device may cache the current data block and the previous data block that is temporally adjacent to the current data block.
[0071] For example, each time a pixel data block is obtained, the computer device caches that pixel data block as the current data block. When a new current data block is obtained, the new current data block is cached, and the previous current data block is used as the previous data block of the new current data block. This ensures that both the current data block and the previous data block are cached, and the cache is updated in a First In First Out (FIFO) order, so that each current data block and its temporally adjacent previous data block are cached. For example, pixel data block 1 is obtained and cached; then pixel data block 2 is obtained and cached; then pixel data block 3 is obtained, pixel data block 1 is cleared, pixel data block 3 is cached; then pixel data block 4 is obtained, pixel data block 2 is cleared, pixel data block 4 is cached, and so on, until the last obtained pixel data block is cached.
[0072] S320. When the target processing algorithm includes a gradient acquisition algorithm, cache pixel data blocks of a preset number of pixel rows; the cache area is different for different rows of pixel data blocks.
[0073] The gradient acquisition algorithm refers to a processing algorithm that involves neighboring pixels in both the row and column directions. Different rows of pixel data blocks are cached in different buffers, while pixels in the same row are cached in the same buffer.
[0074] For example, such as Figure 4 As shown, taking a preset pixel row count of 3 as an example, buffers RAM0~2 are used to cache the data blocks obtained from each row of pixels. RAM0 is used to cache the pixel data blocks obtained from the first row of pixels, buffer RAM1 is used to cache the pixel data blocks obtained from the second row of pixels, and buffer RAM2 is used to cache the pixel data blocks obtained from the third row of pixels.
[0075] Optionally, if the computer device determines that the target processing algorithm includes a processing algorithm in which neighboring pixels in both the row and column directions participate in the operation, it may cache a preset number of pixel data blocks. For example, if the target processing algorithm includes a gradient acquisition algorithm, the computer device may cache a preset number of pixel data blocks corresponding to that gradient acquisition algorithm.
[0076] For example, each time a pixel data block is obtained, the computer device caches that pixel data block. As new pixel data blocks are obtained, the new pixel data blocks are cached until all pixel data blocks from the entire row of pixels are cached. Then, the pixel data blocks from the new row of pixels are cached sequentially in a new cache area, and the cache is updated in FIFO order, ensuring that the preset number of pixel data blocks for each row are cached. For example, continuing... Figure 4In the example, the pixel data block 1 obtained from the first row of pixels is cached sequentially in RAM0, the pixel data block obtained from the second row of pixels is cached sequentially in RAM1, the pixel data block obtained from the third row of pixels is cached sequentially in RAM2, then the data in RAM0 is cleared, the pixel data block obtained from the fourth row of pixels is cached sequentially in RAM0, then the data in RAM1 is cleared, the pixel data block obtained from the fifth row of pixels is cached sequentially in RAM1, and so on, until the pixel data block obtained from the last row of pixels is cached.
[0077] In this embodiment, when the target processing algorithm includes a denoising filtering algorithm, the current data block and the previous data block that is temporally adjacent to the current data block are cached. When the target processing algorithm includes a gradient acquisition algorithm, a preset number of pixel data blocks are cached. The cache areas for different rows of pixel data blocks are different. In the above method, a differentiated caching strategy is adopted for different target image processing algorithms. The denoising algorithm caches adjacent pixel data blocks, and the gradient acquisition algorithm caches pixel data blocks matching the number of rows. This achieves on-demand and accurate caching for different image processing algorithms, reduces redundant data storage, saves cache resources, and adapts to the computational data requirements of different neighborhood-type algorithms, thereby improving the efficiency and stability of image processing.
[0078] To obtain the processed pixels, in one embodiment, such as Figure 5 As shown, in S220 above, pixels in the cached pixel data block with a preset parallel processing amount are processed in parallel according to the target processing algorithm to obtain the processed pixels of each pixel, including:
[0079] S510. Determine the set of operation pixels for each pixel to be processed in parallel in the cached pixel data block according to the target processing algorithm; the set of operation pixels includes any pixel to be processed in parallel and the pixels adjacent to any pixel to be processed in parallel.
[0080] Here, the set of pixels for operation of a pixel represents the set of pixels required to perform the target processing algorithm on that pixel.
[0081] Optionally, the computer device may determine the pixels to be processed in parallel in the cached pixel data block in sequence and with a preset number of parallel operations, and for each pixel, determine the set of operation pixels that the pixel includes itself and the pixels adjacent to it according to the target processing algorithm.
[0082] For example, such as Figure 6As shown, taking a target processing algorithm including a denoising and filtering algorithm as an example, the current data block and the previous data block are cached. Based on the preset parallel data processing volume of 4, pixels 1-4 can be determined from the cached current data block and the previous data block as the pixels to be processed in parallel. For pixel 1, pixels 0-2 are determined as the set of operation pixels for pixel 1 according to the denoising and filtering algorithm; for pixel 2, pixels 1-3 are determined as the set of operation pixels for pixel 2 according to the denoising and filtering algorithm; for pixel 3, pixels 2-4 are determined as the set of operation pixels for pixel 3 according to the denoising and filtering algorithm; and for pixel 4, pixels 3-5 are determined as the set of operation pixels for pixel 4 according to the denoising and filtering algorithm.
[0083] S520. Perform the target processing algorithm on each set of pixels in parallel to obtain the processed pixels of each pixel.
[0084] Optionally, after obtaining the set of operation pixels for each pixel that needs to be processed in parallel in the cached pixel data block, the computer device can perform the corresponding target processing algorithm operation on each set of operation pixels in parallel to obtain the processed pixels of each pixel.
[0085] For example, continue Figure 6 In the example above, the computer device can perform the corresponding denoising filtering algorithm on the above four sets of operation pixels in parallel, and obtain the processed pixels 1-4 accordingly.
[0086] In this embodiment, the set of computational pixels for each pixel to be processed in parallel in the cached pixel data block is determined according to the target processing algorithm. The target processing algorithm is then performed on each set of computational pixels in parallel to obtain the processed pixels of each pixel. The set of computational pixels includes any pixel to be processed in parallel and the pixels adjacent to any pixel to be processed in parallel. In the above method, the set of computational pixels corresponding to each pixel to be processed in parallel is determined according to the target processing algorithm. The set of computational pixels includes any pixel to be processed in parallel and its adjacent pixels to adapt to the neighborhood data requirements of the target processing algorithm, thereby making full use of the cached pixel data and improving the overall computational efficiency and accuracy of image processing.
[0087] The neighborhood data requirement of the target processing algorithm can be represented using pixel matrix information. In one embodiment, such as... Figure 7 As shown, in S510 above, the set of operation pixels for each pixel to be processed in parallel in the cached pixel data block is determined according to the target processing algorithm, including:
[0088] S710. Obtain the pixel matrix information of the corresponding target processing algorithm.
[0089] The pixel matrix information represents the matrix information of the set of pixels being processed. For example, the pixel matrix information can be 1*3 or 3*3.
[0090] Optionally, the computer device determines the pixel matrix information of the corresponding target processing algorithm based on the preset correspondence between the processing algorithm and the pixel matrix information.
[0091] For example, the correspondence between the preset processing algorithms and pixel matrix information includes: pixel matrix information 1*3 corresponding to the noise reduction filtering algorithm, and pixel matrix information 3*3 corresponding to the gradient acquisition algorithm.
[0092] S720: For each pixel processed in parallel, obtain the pixel from the cached pixel data block according to the pixel matrix information, and use it as the set of pixels for operation.
[0093] Optionally, for each pixel processed in parallel, the computer device can use that pixel as the center of the matrix and retrieve pixels from the cached pixel block according to the corresponding pixel matrix information to form the set of operation pixels for that pixel.
[0094] For example, continue Figure 6 In the example, the target processing algorithm includes a noise reduction and filtering algorithm, corresponding to a 1*3 pixel matrix information. Figure 6 The pixels to be processed in parallel include pixels 1-4. For pixel 1, using pixel 1 as the matrix center, pixels 0-2 are obtained from the cached pixel data block (including the current data block and the previous data block) according to the pixel matrix information 1*3, forming the set of pixels for operation on pixel 1. Similarly, pixels 1-3 are obtained as the set of pixels for operation on pixel 2, pixels 2-4 are obtained as the set of pixels for operation on pixel 3, and pixels 3-5 are obtained as the set of pixels for operation on pixel 4.
[0095] The target processing algorithm includes a gradient acquisition algorithm, and the resulting processed image includes a gradient information image. Based on this, the above image processing algorithm can be applied to extract marker points from the image to be processed. In one embodiment, such as... Figure 8 As shown, the above method also includes:
[0096] S810. Based on the comparison results between the gradient magnitude of each pixel in the gradient information image and the first preset threshold and the second preset threshold, the gradient information image is binarized to obtain a binarized image.
[0097] The gradient information image includes the gradient magnitude of each pixel, which is used to characterize the degree of grayscale change of a pixel compared to its neighboring pixels.
[0098] Optionally, the computer device can compare the gradient magnitude of each pixel in the gradient information image with a first preset threshold and a second preset threshold respectively, so as to perform binarization processing on the image to be processed according to the comparison result, set the pixel value of at least some pixels in the gradient information image to the first pixel value (e.g., 1), and set the pixel value of the remaining pixels to the second pixel value (e.g., 0), so as to obtain a binarized image of the gradient information image.
[0099] S820: Output the position information of the boundary pixels of the marked points in the binarized image based on the binarized image.
[0100] Here, marker points represent connected regions in the image. For example, marker points can be regular geometric shapes, such as circles or directions, or they can be character shapes, such as letters or Chinese characters. Marker point boundary pixels represent the pixels that form the boundaries of the marker points.
[0101] Optionally, the computer device can determine the boundary pixels of the marker points based on the pixel values of each pixel in the binarized image, so as to locate the position of the boundary pixels of the marker points in the binarized image, obtain the position information of the boundary pixels of the marker points, and output it.
[0102] S830: Extract marker points from the image to be processed based on the position information of the boundary pixels of the marker points.
[0103] The image to be processed, the gradient information image, and the binarized image all have the same specifications.
[0104] Optionally, after obtaining the position information of the boundary pixels of the marker points in the binarized image, the computer device can sequentially connect the boundary pixels of each marker point according to the position information to form a connected component, and extract the connected component as the marker point.
[0105] For example, extracting a marker point includes marking the region where the marker point is located in the image to be processed, and may also include obtaining the geometric parameters of the marker point, such as center point coordinates, size, area, etc.
[0106] It should be noted that the FPGA can output the obtained binarized image to the ARM control terminal, which will further process it to obtain the position information of the boundary pixels of the marker points in the binarized image. The image is then output to the host computer through common industrial interfaces, including but not limited to Gigabit Ethernet and USB 3.0. The host computer extracts the marker points in the image to be processed based on the received position information of the boundary pixels of the marker points and transmits them to the off-chip DDR memory in a pipeline manner.
[0107] In this embodiment, the target processing algorithm includes a gradient acquisition algorithm, and the processed image includes a gradient information image. The method further includes binarizing the gradient information image based on the comparison results of the gradient magnitude of each pixel in the gradient information image with a first preset threshold and a second preset threshold to obtain a binarized image. The method then outputs the position information of the boundary pixels of the marker points in the binarized image and extracts the marker points in the image to be processed based on the position information of the boundary pixels of the marker points. In the above method, the pixel gradient magnitude is used in conjunction with the double threshold to complete the binarization process, which can effectively filter out interfering pixels and retain valid marker point boundary pixels, making the binarization result more accurate. This improves the recognition and positioning accuracy of the marker point boundary pixels and correspondingly improves the extraction accuracy of the marker points.
[0108] The second preset threshold is greater than the first preset threshold. In one embodiment, such as... Figure 9 As shown, in the above-mentioned S810, the gradient information image is binarized based on the comparison results between the gradient magnitude of each pixel in the gradient information image and the first preset threshold and the second preset threshold, including:
[0109] S910. Set the first pixel value to the pixel in the gradient information image whose gradient magnitude is greater than the second preset threshold, or whose gradient magnitude is greater than the first preset threshold and which has an adjacent pixel whose gradient magnitude is greater than the second preset threshold.
[0110] In this context, a pixel's gradient magnitude exceeding a second preset threshold indicates a drastic change in grayscale, suggesting that the pixel is a boundary pixel of a marker point and belongs to a strong boundary. A pixel's gradient magnitude exceeding a first preset threshold, along with adjacent pixels whose gradient magnitudes exceed the second preset threshold, indicates a relatively smooth grayscale change in the pixel, but with surrounding pixels exhibiting drastic grayscale changes. This also suggests that the pixel is a boundary pixel of a marker point and belongs to a weak boundary adjacent to a strong boundary. Pixels with a value equal to the first pixel value are considered boundary pixels of marker points.
[0111] Optionally, the computer device can compare the gradient magnitude of each pixel in the gradient information image with a first preset threshold and a second preset threshold respectively, so as to filter pixels in the gradient information image whose gradient magnitude is greater than the second preset threshold, or whose gradient magnitude is greater than the first preset threshold and which have adjacent pixels whose gradient magnitude is greater than the second preset threshold, and set their pixel value as the first pixel value.
[0112] S920. Set the pixel in the gradient information image whose gradient magnitude is less than or equal to the first preset threshold, or whose gradient magnitude is greater than the first preset threshold and which does not have a neighboring pixel whose gradient magnitude is greater than the second preset threshold, to the second pixel value.
[0113] In this context, a pixel's gradient magnitude being less than or equal to a first preset threshold indicates a smooth grayscale change, meaning the pixel is not a boundary pixel of a marker point. A pixel's gradient magnitude being greater than the first preset threshold and having no adjacent pixels with gradient magnitudes greater than a second preset threshold indicates a relatively smooth grayscale change, with no surrounding pixels exhibiting drastic grayscale changes, also suggesting the pixel is not a boundary pixel of a marker point. Pixels with a value equal to the second pixel value are considered non-marker point boundary pixels.
[0114] Optionally, the computer device can compare the gradient magnitude of each pixel in the gradient information image with a first preset threshold and a second preset threshold respectively, so as to filter pixels in the gradient information image whose gradient magnitude is less than or equal to the first preset threshold, or whose gradient magnitude is greater than the first preset threshold and there are no adjacent pixels whose gradient magnitude is greater than the second preset threshold, and set their pixel value as the second pixel value.
[0115] In this embodiment, the second preset threshold is greater than the first preset threshold. Pixels in the gradient information image whose gradient magnitude is greater than the second preset threshold, or whose gradient magnitude is greater than the first preset threshold and which have adjacent pixels with a gradient magnitude greater than the second preset threshold, are set as first pixels. Pixels in the image to be processed whose gradient magnitude is less than or equal to the first preset threshold, or whose gradient magnitude is greater than the first preset threshold and which do not have adjacent pixels with a gradient magnitude greater than the second preset threshold, are set as second pixel values. In the above method, binarization processing is completed by combining the dual thresholds and the pixel neighborhood association relationship. This not only relies on the high threshold to lock strong boundaries, but also uses neighborhood determination to retain weak boundaries adjacent to strong boundaries, improving the integrity and connectivity of the marked point boundary pixels, thereby improving the reliability of binarization processing.
[0116] The positional information of the boundary pixels of the marker points can be represented by the rows and columns of the pixels in the image. In one embodiment, such as Figure 10 As shown, the step S820 above, which outputs the position information of the boundary pixels of the marked points in the binarized image based on the binarized image, includes:
[0117] S1010. Based on the pixel values of each pixel in the pixel data block of the binarized image, determine the boundary pixels of the marker points in each pixel data block in sequence, and obtain the row and column of the boundary pixels of the marker points in the binarized image as the position information of the boundary pixels of the marker points.
[0118] Optionally, the computer device can use a preset parallel processing amount to divide the row pixels of the binarized image, sequentially determine the marker boundary pixels in each pixel data block obtained by the division, and obtain the row and column of the marker boundary pixels in the image to be processed as the position information of the marker boundary pixels.
[0119] For example, for the divided pixel data block, the computer device can extract the pixel with the first pixel value in the pixel data block, i.e., the marker point boundary pixel, and can simultaneously extract the position information of the marker point boundary pixel.
[0120] S1020. When the number of boundary pixels of the marker points reaches the preset parallel processing amount, the position information of the boundary pixels of the marker points with the preset parallel processing amount is merged and output.
[0121] Optionally, if the number of extracted marker boundary pixels reaches a preset parallel processing number, the position information of the extracted marker boundary pixels with the preset parallel processing amount is merged and output.
[0122] For example, such as Figure 11 As shown, the shaded area represents the pixel with the first pixel value, and the blank area represents the pixel with the second pixel value. For the first pixel data block, the position information of pixel 1 and pixel 3 is extracted; for the second pixel data block, the position information of pixel 5 is extracted and merged with the previously obtained pixel 1 and pixel 3, resulting in the position information of pixel 1, pixel 3, and pixel 5; for the third pixel data block, the position information of pixel 10 is extracted and merged with the previously obtained pixel 1, pixel 3, and pixel 5, resulting in the position information of pixel 1, pixel 3, pixel 5, and pixel 10. Since the number of boundary pixels of the marked point is 4, reaching the preset parallel processing volume of 4, the position information of pixel 1, pixel 3, pixel 5, and pixel 10 are merged and output at once.
[0123] In this embodiment, based on the pixel values of each pixel in the pixel data block of the binarized image, the boundary pixels of the marker points in each pixel data block are determined sequentially, and the row and column of the boundary pixels of the marker points in the binarized image are obtained as the position information of the boundary pixels of the marker points. When the number of boundary pixels of the marker points reaches a preset parallel processing level, the position information of the boundary pixels of the marker points with the preset parallel processing level is merged and output. In the above method, for the pixel data blocks obtained by dividing the binarized image, the boundary pixels of the marker points are determined according to the pixel values and their rows and columns are obtained as position information. When the number of boundary pixels of the marker points reaches a preset parallel processing level, they are merged and output, realizing batch packaging and output of position information, reducing data interaction overhead, and effectively improving the output of the position information of the boundary pixels of the marker points and the efficiency of subsequent processing.
[0124] To facilitate understanding by those skilled in the art, the image processing method provided in this application is described in detail below, such as... Figure 12 As shown, the method may include:
[0125] S1201. The row pixels of the image to be processed are divided into at least two pixel data blocks using a preset parallel processing amount; each pixel data block includes at most the preset parallel processing amount of pixels; the image to be processed includes at least one row of pixels;
[0126] S1202. When executing a denoising filtering algorithm, cache the current data block and the previous data block that is adjacent to the current data block in time sequence; when executing a gradient acquisition algorithm, cache pixel data blocks of a preset number of pixel rows; the cache area is different for different rows of pixel data blocks.
[0127] S1203. Obtain the pixel matrix information of the corresponding target processing algorithm;
[0128] S1204. For each pixel to be processed in parallel in the cached pixel data block, obtain the pixel from the cached pixel data block according to the pixel matrix information, and use it as the set of operation pixels for that pixel.
[0129] S1205. Perform the target processing algorithm on each set of pixels in parallel to obtain the processed pixels of each pixel.
[0130] S1206. The target processing algorithm includes a gradient acquisition algorithm, which obtains the gradient information image of the image to be processed based on the processed pixels of each pixel; and sets the pixels in the gradient information image whose gradient magnitude is greater than the second preset threshold, or whose gradient magnitude is greater than the first preset threshold and which have adjacent pixels whose gradient magnitude is greater than the second preset threshold, as the first pixel value.
[0131] S1207. Set the pixels in the gradient information image whose gradient magnitude is less than or equal to the first preset threshold, or whose gradient magnitude is greater than the first preset threshold and there are no adjacent pixels whose gradient magnitude is greater than the second preset threshold, to the second pixel value, and obtain the binarized image of the gradient information image.
[0132] S1208. Based on the pixel values of each pixel in the pixel data block of the binarized image, determine the boundary pixels of the marker points in each pixel data block in sequence, and obtain the row and column of the boundary pixels of the marker points in the binarized image as the position information of the boundary pixels of the marker points.
[0133] S1209. When the number of boundary pixels of the marker points reaches the preset parallel processing amount, the position information of the boundary pixels of the marker points with the preset parallel processing amount is merged and output.
[0134] S1210. Extract marker points from the image to be processed based on the position information of the boundary pixels of the marker points.
[0135] It should be noted that the descriptions in S1201-S1210 above can be found in the relevant descriptions in the above embodiments, and their effects are similar, so they will not be repeated here.
[0136] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages in other steps. It is understood that the steps in different embodiments can be freely combined as needed, and all non-contradictory solutions formed by such combinations are within the scope of protection of this application.
[0137] Based on the same inventive concept, this application also provides a connected component information extraction device for implementing the connected component information extraction method described above. The solution provided by this device is similar to the solution described in the above method; therefore, the specific limitations in one or more connected component information extraction device embodiments provided below can be found in the limitations of the connected component information extraction method described above, and will not be repeated here.
[0138] In one exemplary embodiment, such as Figure 13 As shown, an image processing apparatus is provided, including: a pixel division module 1301, a parallel processing module 1302, and a processing result module 1303, wherein:
[0139] The pixel division module 1301 is used to divide the row pixels of the image to be processed into at least two pixel data blocks using a preset parallel processing amount; each pixel data block includes at most the preset parallel processing amount of pixels; the image to be processed includes at least one row of pixels;
[0140] The parallel processing module 1302 is used to cache pixel data blocks according to the target processing algorithm, and to process the pixels in the cached pixel data blocks with a preset amount of parallel processing according to the target processing algorithm, so as to obtain the processed pixels of each pixel.
[0141] The processing result module 1303 is used to determine the processed image of the image to be processed based on the processed pixels of each pixel in the image to be processed.
[0142] Each module in the aforementioned image processing device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device as software, so that the processor can call and execute the operations corresponding to each module.
[0143] In one embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in any of the above-described image processing methods.
[0144] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the steps of any of the above image processing methods.
[0145] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps in any of the above-described image processing methods.
[0146] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, artificial intelligence (AI) processors, etc., and are not limited to these.
[0147] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.
[0148] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.
Claims
1. An image processing method, characterized in that, The method includes: The row pixels of the image to be processed are divided into at least two pixel data blocks using a preset parallel processing amount; each pixel data block includes at most the preset parallel processing amount of pixels; the image to be processed includes at least one row of pixels; The pixel data blocks are cached according to the target processing algorithm, and the pixels in the cached pixel data blocks with a preset parallel processing amount are processed in parallel according to the target processing algorithm to obtain the processed pixels of each pixel. The processed image is determined based on the processed pixels of each pixel in the image to be processed.
2. The method according to claim 1, characterized in that, The step of caching pixel data blocks according to the target processing algorithm includes: When the target processing algorithm includes a denoising filtering algorithm, the current data block and the previous data block that is temporally adjacent to the current data block are cached; When the target processing algorithm includes a gradient acquisition algorithm, a preset number of pixel data blocks with different pixel rows are cached; the cache areas for different rows of pixel data blocks are different.
3. The method according to claim 1 or 2, characterized in that, The step of processing pixels in the cached pixel data block in parallel according to the target processing algorithm with a preset parallel processing amount to obtain the processed pixels of each pixel includes: The target processing algorithm determines the set of operation pixels for each pixel to be processed in parallel in the cached pixel data block; the set of operation pixels includes any pixel to be processed in parallel and the pixels adjacent to any pixel to be processed in parallel. The target processing algorithm is performed in parallel on each of the aforementioned sets of pixels to obtain the processed pixels for each pixel.
4. The method according to claim 3, characterized in that, The step of determining the set of operation pixels for each pixel to be processed in parallel in the cached pixel data block according to the target processing algorithm includes: Obtain the pixel matrix information corresponding to the target processing algorithm; For each pixel in the parallel processing, pixels are obtained from the cached pixel data block according to the pixel matrix information, and used as the set of pixels for operation.
5. The method according to claim 1 or 2, characterized in that, The target processing algorithm includes a gradient acquisition algorithm, and the processed image includes a gradient information image; the method further includes: The gradient information image is binarized based on the comparison results between the gradient magnitude of each pixel in the gradient information image and the first preset threshold and the second preset threshold to obtain a binarized image. Output the position information of the boundary pixels of the marked points in the binarized image; Marker points are extracted from the image to be processed based on the position information of the boundary pixels of the marker points.
6. The method according to claim 5, characterized in that, The second preset threshold is greater than the first preset threshold; the step of binarizing the gradient information image based on the comparison result between the gradient magnitude of each pixel in the gradient information image and the first and second preset thresholds includes: Pixels in the gradient information image whose gradient magnitude is greater than the second preset threshold, or whose gradient magnitude is greater than the first preset threshold and which have adjacent pixels whose gradient magnitude is greater than the second preset threshold, are set to the first pixel value. Pixels in the gradient information image whose gradient magnitude is less than or equal to the first preset threshold, or whose gradient magnitude is greater than the first preset threshold and which do not have adjacent pixels whose gradient magnitude is greater than the second preset threshold, are set to the second pixel value.
7. The method according to claim 5, characterized in that, The step of outputting the position information of the marker point boundary pixels in the binarized image based on the binarized image includes: Based on the pixel values of each pixel in the pixel data block of the binarized image, the boundary pixels of the marker points in each pixel data block are determined sequentially, and the row and column of the boundary pixels of the marker points in the binarized image are obtained as the position information of the boundary pixels of the marker points. When the number of boundary pixels of the marked points reaches the preset parallel processing amount, the position information of the boundary pixels of the marked points of the preset parallel processing amount is merged and output.
8. An image processing apparatus, characterized in that, The device includes: A pixel partitioning module is used to divide the row pixels of the image to be processed into at least two pixel data blocks using a preset parallel processing amount; each pixel data block includes at most the preset parallel processing amount of pixels; the image to be processed includes at least one row of pixels; The parallel processing module is used to cache pixel data blocks according to the target processing algorithm, and process the pixels in the cached pixel data blocks with a preset amount of parallel processing according to the target processing algorithm to obtain the processed pixels of each pixel. The processing result module is used to determine the processed image of the image to be processed based on the processed pixels of each pixel in the image to be processed.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 7.
