Image pixel processing method and chip based on unidirectional search
By adopting a sliding window method of one-way search in image processing, the problem of large amount of image filtering processing in the prior art is solved, and more efficient image traversal and processing is achieved.
Patent Information
- Application Number
- CN202111167546.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-07
- Publication Date
- 2025-06-06
- Estimated Expiration
- 2041-10-07
AI Technical Summary
The prior art requires frequent cross-row operations and multi-directional search in image filtering processing, resulting in large calculations and increasing the burden on embedded devices.
Using an image pixel processing method based on one-way search, when the sliding window slides in the image to be processed, it only searches for pixel points along a single preset search direction, and calculates the grayscale value similarity in that direction, simplifies the calculation process and reduces the number of operations.
By reducing the number of pixels calculated by searching, the image traversal speed is improved, the probability of image data being invalidated in the cache space is reduced, and the cache space hit rate of the CPU accessed pixels is improved.
Smart Images

Figure CN113900806B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image processing, and in particular to an image pixel processing method and a chip based on unidirectional search. Background Art
[0002] In the process of filtering an image, in order to calculate the result corresponding to a pixel and its eight adjacent pixels, the prior art involves cross-row operations and searches along multiple directions. For example, when calculating the difference between the grayscale value of a pixel currently traversed and the grayscale value of a pixel in the same column of the previous row, a cross-row read operation is required. In particular, when performing operations pixel by pixel (involving exponential operations, square operations, and division operations), it is necessary to frequently cross rows to read image data at multiple search directions, which increases the number of calculations and increases the burden on embedded devices with limited cache space. Summary of the invention
[0003] In order to overcome the above technical defects, the present invention discloses an image pixel processing method and chip based on unidirectional search. For a single sliding of the window, the pixel points in a circle around it are not considered, but the pixel points in a single search direction are selected for calculation operations, which can effectively solve the problem of excessive calculation in devices with limited cache. The specific technical solution is as follows:
[0004] A method for processing image pixels based on unidirectional search, the method comprising: searching for pixels along a preset search direction in an image area currently framed by the sliding window each time the sliding window slides once according to a preset step length, and calculating the gray value similarity corresponding to each pair of specific pixel points searched in the corresponding preset search direction; wherein the pixel point covered by the center position of the sliding window in the currently framed image area is the central pixel point; the central pixel point can always be found by searching for pixels along the preset search direction.
[0005] After the sliding window slides once according to the preset step length, the technical solution only needs to search for pixels along a single preset search direction and calculate the gray value similarity between a pair of specific pixels searched in the preset search direction. Compared with the complete multi-directional neighborhood operation of the prior art, the operation process is simplified and the number of operations is reduced, so that the calculation amount of the pixels in the technical solution increases linearly with the length and width of the sliding window instead of quadratically. Especially for images with millions of pixels, the degree of improvement in processing efficiency is adapted to the access speed and memory capacity of the cache space of the embedded device, so that after the memory stores limited pixels into the cache space, the CPU can quickly read the correct data and use it for calculation.
[0006] Furthermore, the image pixel processing method also includes: whenever the sliding window slides through all pixel points in the image to be processed, it is determined that the sliding window has completed a round of full coverage operation on the image to be processed; when the sliding window performs a preset number of rounds of full coverage operation on the image to be processed, the grayscale value similarity corresponding to each pair of specific pixel points in all preset search directions is obtained, wherein the preset search directions along which the image to be processed are taken in different rounds of full coverage operations are different, and the preset search directions along which the image to be processed are taken in the same round of full coverage operations remain the same; the preset search directions along which any two rounds of full coverage operations are taken are not opposite, and the number of preset search directions is set to a preset number.
[0007] In this technical solution, according to the traversal method of the neighborhood pixel points in a specific direction and the acquisition method of their grayscale value similarity, it is determined that the sliding window has performed a sliding operation in the image to be processed, and then according to the full coverage sliding method of the sliding window on the image to be processed, a round of full coverage operation on the image to be processed is determined, forming a full coverage operation mechanism for pixel points in multiple different preset search directions within the sliding window, thereby considering the comprehensive coverage effect of the traversed image area.
[0008] Furthermore, before the sliding window starts sliding for the first time in the image to be processed or each time the sliding window slides a preset step length in the image to be processed, the sliding window searches for pixels along a preset search direction in the image area currently framed by the sliding window, and calculates the grayscale value similarity corresponding to each pair of specific pixel points searched in the corresponding preset search direction, to determine that the sliding window has performed a sliding operation in the image to be processed; whenever all image areas framed by the sliding window have slid through all pixel points in the image to be processed, and the grayscale value similarity corresponding to each pair of specific pixel points in all preset search directions in the image area framed by the sliding window is obtained, it is determined that the sliding window has completed a round of full coverage operation on the image to be processed; in the same round of full coverage operation, the pixel points covered by the center position of the sliding window in the current sliding operation are different from the pixel points covered by the center position of the sliding window in a previously performed sliding operation; wherein the grayscale value similarity is used to indicate the degree of difference between the grayscale values of two pixel points.
[0009] Compared with the prior art, each time it is necessary to calculate the image information similarity (the difference in spatial distance and the difference in pixel value) between pixel pairs, the pixel pairs in the same search direction are used to obtain representative image information similarity, thereby forming a traversal operation on relatively fixed pixel positions, reducing the number of pixels required for the sliding window to perform image information similarity calculation under one sliding condition, and reducing the number of pixel pairs involved in the calculation; on this basis, the technical solution performs multiple full coverage operations along various preset search directions within the same image to be processed, so that a fixed number of image rows in the same direction can be read in each sliding operation in the same round of full coverage operations, and pixels are searched along different preset search directions when switching a round of full coverage operations, thereby reducing the number of times image data enters and exits the cache space in each round of full coverage operations, thereby improving the image traversal speed by reducing the number of pixels for search calculation.
[0010] Furthermore, the grayscale value similarity corresponding to each pair of specific pixel points searched in the corresponding preset search direction is calculated as follows: whenever a pair of specific pixel points is searched along the corresponding preset search direction, the grayscale value similarity between a pixel point searched in the corresponding preset search direction and the same preset boundary point of the image area currently framed by the sliding window is calculated; wherein, a pixel point searched in the corresponding preset search direction and the same preset boundary point of the image area currently framed by the sliding window constitute a pair of specific pixel points.
[0011] This technical solution selects the boundary point of the image area framed by the sliding window as the search starting point, and also as the reference center point for subsequent calculation of grayscale value similarity, so that the number of pixel points searched along the same preset search direction in a single sliding operation of the sliding window is greater than the number of pixel points searched in the neighborhood starting from the center position of the sliding window along the same preset search direction.
[0012] Furthermore, the grayscale value similarity between each pair of specific pixel points searched in the corresponding preset search direction is calculated as follows: whenever a pair of specific pixel points is searched along the corresponding preset search direction, the grayscale value similarity between two pixel points symmetrical about the center pixel point searched in the corresponding preset search direction is calculated; wherein, the two pixel points symmetrical about the center pixel point constitute a pair of specific pixel points, and the pixel point covered by the center position of the sliding window within the currently framed image area is the center pixel point.
[0013] Under the condition of a single sliding of the sliding window, this technical solution chooses to calculate the grayscale value similarity between two pixel points symmetrical about the central pixel point as the processing result of a pair of specific pixel points, and skips calculating the grayscale value similarity between the pixel point currently covered by the center position of the sliding window and its neighboring pixel points, thereby avoiding repeated calculation of the grayscale value similarity between the previously determined central pixel point and the currently determined central pixel point after the center position of the sliding window is translated.
[0014] Furthermore, the grayscale value similarity between each pair of specific pixel points searched in the corresponding preset search direction is calculated as follows: whenever a pair of specific pixel points is searched along the corresponding preset search direction, the grayscale value similarity between the neighborhood pixel points searched in the corresponding preset search direction and the center pixel point is calculated non-repeatedly; wherein, any neighborhood pixel point searched in the corresponding preset search direction and the center pixel point form a pair of specific pixel points, the pixel point covered by the center position of the sliding window within the currently framed image area is the center pixel point, and the pixel points in the neighborhood of the center pixel point are the neighborhood pixel points.
[0015] This technical solution uses the gray value similarity between the pixel points searched in sequence in the corresponding preset search direction and the central pixel point as the processing result of a pair of specific pixel points under the condition of each sliding of the sliding window, so that the obtained gray value similarity focuses on the change of the pixel value near the neighborhood space of the central pixel point along a specific direction, and will not affect the pixel value on the edge too much, thereby ensuring the preservation of the pixel value near the edge of the image to be processed. It is suitable for bilateral filtering of the image to be processed.
[0016] Furthermore, during the same round of full coverage operation, each time the sliding window slides a preset step length within the image to be processed, the preset search direction along which the pixel points are searched within the image area currently framed by the sliding window is the same as the preset search direction along which the pixel points are searched within the image area last framed by the sliding window; during each sliding operation, the number of pixel points searched along the corresponding preset search direction within the image area framed by the sliding window is equal.
[0017] The pixels with parallel orientations searched by the sliding window before and after sliding a preset step length are all located in the same row of the image to be processed, wherein the pixels with parallel orientations refer to the neighboring pixels located in the same preset search direction and at an equal distance from the corresponding central pixel. In addition, since the image to be processed is stored in the memory space by row, this embodiment supports the CPU to keep reading the pixels of the image to be processed from the memory row by row, or the CPU stores the pixels of the image to be processed into the cache space row by row, thereby reducing the number of cross-row readings, reducing the probability of image data failure in the cache space, and improving the hit rate of the pixels accessed by the CPU in the cache space.
[0018] Further, the preset number is 4; the preset number of rounds of full coverage operations are respectively a first full coverage operation, a second full coverage operation, a third full coverage operation and a fourth full coverage operation; in the first full coverage operation, the preset search direction is from the lower right corner point of the image area currently framed by the sliding window to its upper left corner point, or from the upper left corner point of the image area currently framed by the sliding window to its lower right corner point; in the second full coverage operation, the preset search direction is from the upper right corner point of the image area currently framed by the sliding window to its lower left corner point, or from the lower left corner point of the image area currently framed by the sliding window to its upper right corner point; in the third full coverage operation, the preset search direction is a horizontal left direction, or a horizontal right direction; in the fourth full coverage operation, the preset search direction is a vertical downward direction, or a vertical upward direction.
[0019] This technical solution realizes four full coverage operations on the image to be processed along the boundary direction and diagonal direction of the sliding window, and traverses and calculates (including sequential processing or simultaneous processing) pixel pairs in the horizontal left and right directions, pixel pairs in the upper left and lower right diagonal directions, pixel pairs in the vertical up and down directions, and pixel pairs in the lower left and upper right diagonal directions, thereby reducing the amount of pixel calculation under a single sliding operation and improving the image processing speed.
[0020] Furthermore, the sliding window is represented by a square window, and the side length of the square window is 2×W+1, where W is a positive integer. When the center position of the sliding window slides in the image to be processed, the pixel point covered becomes the central pixel point, and after the sliding window slides a preset step length, at most 2W neighboring pixel points can be framed in the preset search direction, and the positions of the framed pixel points can be symmetrical about the center position of the sliding window.
[0021] Further, when the preset search direction is from the upper left corner point of the image area currently framed by the sliding window to its lower right corner point, the preset boundary point is the upper left corner point of the image area currently framed by the sliding window; when the preset search direction is from the lower right corner point of the image area currently framed by the sliding window to its upper left corner point, the preset boundary point is the lower right corner point of the image area currently framed by the sliding window; when the preset search direction is from the upper right corner point of the image area currently framed by the sliding window to its lower left corner point, the preset boundary point is the upper right corner point of the image area currently framed by the sliding window; when the preset search direction is from the image area currently framed by the sliding window to its lower left corner point When the lower left corner point of a image region currently framed by the sliding window points to its upper right corner point, the preset boundary point is the lower left corner point of the image region currently framed by the sliding window; when the preset search direction is horizontally to the left, the preset boundary point is the midpoint of the right boundary of the image region currently framed by the sliding window; when the preset search direction is horizontally to the right, the preset boundary point is the midpoint of the left boundary of the image region currently framed by the sliding window; when the preset search direction is vertically upward, the preset boundary point is the midpoint of the upper boundary of the image region currently framed by the sliding window; when the preset search direction is vertically downward, the preset boundary point is the midpoint of the lower boundary of the image region currently framed by the sliding window.
[0022] In this technical solution, all preset boundary points serving as the search starting points of the image area framed by the sliding window are symmetrical about the center of the sliding window, and these preset boundary points symmetrical about the center traverse the pixel points along the corresponding preset search directions respectively, so that in four rounds of full coverage operations in which the preset search directions are changed successively, the search range covers the local area of the image to be processed in the corresponding preset search directions to the greatest extent.
[0023] Furthermore, in the current sliding operation, if the pixel points searched along the preset search direction are the pixel points searched in the previous sliding operation, then the pair of specific pixel points searched in the current sliding operation is different from any pair of specific pixel points searched in the previous sliding operation, so that the pixel positions of the same pair of specific pixel points are not repeatedly traversed. Thus, there will be no phenomenon of repeatedly calculating the gray value similarity between the pair of specific pixel points; wherein, the pixel points covered by the center position of the sliding window in the current sliding operation are different from the pixel points covered by the center position of the sliding window in the previous sliding operation. Thus, after each sliding operation, the sliding window keeps the "latest" data searched out, regardless of which round of full coverage operation it is in, and each round of full coverage operation has a corresponding preset search direction.
[0024] Furthermore, the method for non-repetitively calculating the grayscale value similarity between the neighborhood pixel points searched in the corresponding preset search direction and the central pixel point includes: if the pixel point covered by the center position of the sliding window in the current sliding operation is a pixel point searched along the preset search direction in a previously executed sliding operation, then the pixel point covered by the center position of the sliding window in the current sliding operation is set as the first reference center pixel point, and at the same time, it is determined that the pixel point covered by the center position of the sliding window in the previously executed sliding operation is a pixel point that can be searched along the preset search direction in the image area currently framed by the sliding window, then the pixel point covered by the center position of the sliding window in the previously executed sliding operation is set as the second reference center pixel point. point; wherein, in the previously executed sliding operation, the first reference center pixel point and the second reference center pixel point are the pair of specific pixel points; wherein, in the current sliding operation, the grayscale value similarity between the first reference center pixel point and the second reference center pixel point is calculated in the previously executed sliding operation; then, if a pixel point searched along the preset search direction in the image area currently framed by the sliding window is the center pixel point covered by the center position of the sliding window in the previously executed sliding operation, the grayscale value similarity between the first reference center pixel point and the second reference center pixel point is directly updated to the grayscale value similarity between the currently searched pixel point and the pixel point covered by the center position of the sliding window in the current sliding operation.
[0025] Compared with the prior art, this technical solution controls the same pair of pixels not to be traversed repeatedly during the sliding window sliding in the image to be processed, thereby controlling the gray value similarity between each pair of pixels in relative position relationship to be calculated only once, and can configure the gray value similarity calculated when the pair of pixels is first traversed as the gray value similarity required for subsequent repeated traversals to the pair of pixels, thereby significantly reducing the number of calculations compared to the repeated calculation phenomenon in the prior art, and increasing the calculation speed of all pixels of the image to be processed. It is suitable for processing images with chips with small cache space.
[0026] Furthermore, the image pixel processing method also includes: in each round of full coverage operation, when the sliding window has not started to slide in the image to be processed, in the initial image area framed by the sliding window in the image to be processed, the pixel points are searched sequentially along the corresponding preset search direction in the initial image area, and the spatial proximity corresponding to each pair of specific pixel points searched is calculated, and the calculated spatial proximity corresponding to each pair of specific pixel points with different relative position relationships is stored in a preset memory space, so that when the sliding window performs a sliding operation in the image to be processed later, the spatial proximity corresponding to the corresponding relative position relationship is directly called; wherein, before the sliding window starts to slide in the image to be processed and in each sliding operation performed according to the preset step size, in the image area framed by the sliding window, the spatial proximity corresponding to each pair of specific pixel points with the same relative position relationship is equal; wherein the spatial proximity is used to indicate the degree of difference in the spatial position between two pixel points.
[0027] This technical solution saves the general spatial proximity result calculated in the initial image area before each round of full coverage operation starts to perform the sliding operation, so as to use it in the subsequent shifted framed image, so as to more quickly call the spatial proximity of the corresponding position relationship calculated in advance and avoid repeated calculation of the spatial proximity.
[0028] Furthermore, for a sliding operation performed by the sliding window, the image pixel processing method also includes: multiplying the grayscale similarity and spatial proximity between a pair of specific pixel points currently searched, and then configuring the product as the weight of the first pixel point in the pair of specific pixel points relative to the second pixel point, as the weight of the grayscale value at the pixel position where the first pixel point is located; wherein the pair of specific pixel points includes the first pixel point and the second pixel point; controlling the product of the grayscale similarity and spatial proximity between the pair of specific pixel points currently searched to participate in the accumulation, and then configuring the result of the accumulation under the current sliding operation as a total weight; then accumulating the product of the grayscale value of each first pixel point searched at the pixel position and the configured weight, and then configuring the result of the accumulation under the current sliding operation as the weighted sum of the grayscale values of the pixel points in the neighborhood space; then, setting the ratio of the aforementioned grayscale value weighted sum to the total weight as the weighted average of the grayscale values of the pixel points in the neighborhood space of the second pixel point, used to represent the processing result of the local image under a sliding operation.
[0029] This technical solution uses the product of grayscale value similarity and spatial proximity as the weight of the grayscale value at the corresponding pixel position of the image to be processed, and then uses the weight to perform weighted averaging on the grayscale values of the corresponding pixel points, so that the result of the weighted averaging is the result of a denoising process on the image to be processed.
[0030] Furthermore, in the process of executing the image pixel processing method, for the N pairs of specific pixel points traversed by the sliding window, the CPU is controlled to call N calculation registers to parallelly calculate the image information similarity between the N pairs of specific pixel points traversed; wherein each calculation register is used to calculate the image information similarity between a pair of specific pixel points, and the image information similarity includes gray value similarity and spatial proximity; wherein N is a positive integer greater than or equal to 1. This technical solution uses parallel computing to improve the calculation speed of the image information similarity corresponding to multiple pairs of pixel points, thereby accelerating the image processing speed.
[0031] Furthermore, the N pairs of specific pixel points traversed in one sliding operation performed by the sliding window are pixel points or neighboring pixel points searched in sequence along a preset search direction in an image area framed by the sliding window. The operation speed of a single sliding operation is accelerated, thereby increasing the speed of a full coverage operation on the image to be processed.
[0032] A chip is used to store program codes corresponding to the image pixel processing method. When executing the image pixel processing method, the chip is used to reduce the number of times the pixels of the image to be processed enter and exit the cache space, thereby increasing the speed at which the chip assists the CPU in processing the image, wherein the cache space is set between the CPU and a memory for storing the image to be processed. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] Figure 1 A flowchart of an image pixel processing method based on unidirectional search is disclosed for an embodiment of the present invention.
[0034] Figure 2 A flowchart of an image pixel processing method based on unidirectional search is disclosed as another embodiment of the present invention.
[0035] Figure 3 It is a schematic diagram of the sliding operation of the sliding window commonly used in the aforementioned embodiments within the image to be processed. DETAILED DESCRIPTION
[0036] The technical scheme in the embodiment of the present invention will be described in detail below in conjunction with the accompanying drawings in the embodiment of the present invention. It should be understood that the specific embodiments described below are only used to explain the present invention and are not used to limit the present invention. In the following description, specific details are given to provide a thorough understanding of the embodiments. However, it will be understood by those of ordinary skill in the art that the embodiments can be implemented without these specific details. For example, the circuit can be shown in a block diagram to avoid obscuring the embodiments in unnecessary details. In other cases, in order not to confuse the embodiments, known circuits, structures and techniques may not be shown in detail.
[0037] The terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In the description of the present invention, the meaning of "plurality" is at least two, such as two, three, etc., unless otherwise clearly and specifically defined.
[0038] It is understood by those skilled in the art that the temporary memory, namely the cache space Cache, disposed between the CPU and the image memory has a smaller capacity than the image memory. The data in the Cache comes from a small portion of the image memory, which is the data that the CPU is about to access and use for calculation in a short period of time. The CPU can bypass the image memory and directly call data from the Cache. Such a reading mechanism makes the CPU's hit rate of reading the Cache very high, that is, 90% of the data that the CPU wants to read next time is in the Cache, and only about 10% needs to be read from the image memory.
[0039] The cache of embedded mobile terminal devices is still too small for a frame of image with millions of pixels. It is not enough to hold a complete image. Therefore, when a data block in the image memory enters the cache at one time, the number of buffered rows is not large. Specifically, the memory addresses indexed twice adjacently need to span multiple rows of memory segments. At this time, the amount of addresses occupied by an index step has exceeded the carrying capacity of the cache space of general embedded and mobile devices. Although the row image data of conventional memory needs to enter and exit the cache frequently, the hit rate of data in the cache (the probability that the data that the CPU needs to access is in the cache) is not high, and CPU read / cache failures often occur, resulting in very slow CPU access to data, affecting the execution speed of the image processing algorithm.
[0040] It should be noted that algorithm complexity and execution speed do not completely correspond. If the algorithm is not convenient for cache optimization, even if the algorithm complexity is low, the execution speed may not be fast. The speed of image processing is affected by the cache hit rate and memory speed. The cache has a great impact on the performance of the CPU, mainly caused by the data exchange order of the CPU and the bandwidth between the CPU and the cache.
[0041] In order to overcome the above technical defects, the present invention starts from the number of pixels involved in the calculation, discloses an embodiment to disclose an image pixel processing method based on unidirectional search, such as Figure 1 As shown, the image pixel processing method includes:
[0042] Step S101, the sliding window starts to slide in the image to be processed to start covering the image, and determines that the image to be processed starts to be traversed, and the traversal is performed in a sliding manner with the sliding window as the convolution kernel, and then enters step S102. This embodiment frames an image area of a fixed size and symmetrical about the center by executing step S101, so as to search for pixels that meet the expected processing goals in the currently framed image area. Among them, the sliding window is an index closed interval that slides on the image along a specific moving direction, and is a specific term in the field of image processing. This embodiment saves the image to be processed in an image memory in advance, such as a DDR memory that is electrically connected to the CPU.
[0043] Step S102, whenever the sliding window slides once in the image to be processed according to the preset step length, the pixel points are searched along a preset search direction in the image area currently framed by the sliding window, and the gray value similarity corresponding to each specific pair of pixel points searched in the corresponding preset search direction is calculated, wherein this step is to search along a preset search direction for a pair of specific pixel points participating in the gray value similarity calculation, that is, a pair of pixel points at a specific position, and a pair of specific pixel points has only two pixel points participating in the gray value similarity calculation. Specifically, after the sliding window slides once in the image to be processed, in the image area currently framed by the sliding window, the specific pixel points are searched pair by pair only along a preset search direction, and the gray value similarity between the two pixel points in the pair of specific pixel points currently searched is calculated, and then the calculated gray value similarity is stored. Each specific pair of pixel points in the aforementioned preset search direction can be traversed simultaneously or one after another, or one pixel point in a specific pair of pixel points can be read in advance, and on this basis, the other pixel point can be traversed along the same preset search direction. In this way, when traversing a single central pixel point, there is no need to consider the surrounding pixel points, but rather two relatively fixed pixel points can be selected along a single search direction for calculation operations.
[0044] For step S102, it should be supplemented that when the sliding window has not started to slide within the image to be processed, that is, when the image processing is in the initial state, pixel points are searched along a preset search direction within the image area currently framed by the sliding window, and the grayscale value similarity between the corresponding two specific pixel points is calculated pair by pair; at this time, the calculated grayscale value similarity is the grayscale value similarity between the pixel points at every two specific positions in the pixel points currently searched along the preset search direction; wherein the preset search direction currently being searched is a search direction that needs to be set in order to search for the pair of specific pixel points every time the sliding window slides once according to a preset step size in the image to be processed.
[0045] It should be noted that the preset search direction is configured to always search for a center pixel point in the process of searching for pixels along the preset search direction starting from a search starting point, or it can be understood that the preset search direction is configured to point to the center pixel point from a specific search starting point, so that in the image area currently framed by the sliding window, the pixels searched (traversed) along the preset search direction are symmetrical about the currently configured center pixel point, wherein the currently configured center pixel point is the pixel point covered by the center position of the sliding window in the currently framed image area, if the sliding window slides in the image to be processed, the pixel points covered by the center position of the sliding window in the framed image area will change, that is, the center pixel point will shift, at this time, the preset search direction corresponding to the configuration before the sliding window slides in the image to be processed according to the preset step size is the same as the preset search direction corresponding to the configuration after the same sliding window slides in the same image to be processed according to the preset step size.
[0046] In addition, the neighborhood pixel points are the pixel points located in the neighborhood of the central pixel point, including but not limited to eight neighborhoods and 24 neighborhoods, which are specifically related to the size of the sliding window; wherein the gray value similarity corresponds to the intensity difference in the pixel domain of the image to be processed, and the spatial domain proximity corresponds to the geometric difference in the spatial domain of the image to be processed. The storage order of each pixel point in the image to be processed in the memory is stored in rows.
[0047] In summary, after the sliding window slides once according to the preset step length, it is only necessary to search for pixels along a single preset search direction, and calculate the gray value similarity between a pair of specific pixels searched in the preset search direction, which is equivalent to taking out two relatively fixed pixel position areas in the direction of interest from the image to be processed in one sliding operation of the search window (the number of searches is definitely less than the search amount in the complete neighborhood of a pixel). Therefore, compared with the complete multi-directional neighborhood operation in the prior art, the number of operations is reduced, the operation process is simplified, and the calculation amount of the pixel in this embodiment increases linearly with the length and width of the sliding window instead of quadratically. In particular, relative to images with millions of pixels, the cache miss (cache failure problem) caused by the CPU frequently accessing the image across rows is reduced, and the probability of the accessed image data in the cache space (Cache) is increased, thereby improving the execution speed of image processing, and the degree of improvement in processing efficiency is adapted to the access speed and memory amount of the cache space of the embedded device, so that after the memory stores limited pixels into the cache space, the CPU can quickly read the correct data and use it for calculation.
[0048] It should be noted that, in the corresponding preset search direction, the next row of pixels or the previous row of pixels adjacent to the row of pixels currently read by the CPU can be pre-stored in the cache space. In this way, when the CPU needs to calculate the similarity of the grayscale values between the currently read row of pixels and the corresponding pixels in the adjacent next row, the adjacent next row of pixels or the previous row of pixels are known and can be directly obtained from the cache space. Based on the fact that image data is always transmitted row by row in the image memory, the CPU does not need to perform cross-row reading operations, but instead performs a fixed two-row reading operation each time.
[0049] As an example, Figure 2 As shown, the image pixel processing method includes:
[0050] Step S201, whenever the sliding window slides a preset step length in the image to be processed, search for pixels along a preset search direction in the image area currently framed by the sliding window. Specifically, for one sliding / translation operation of the sliding window, search for pixels in the image area currently framed by the sliding window along the preset search direction, and record the pixels in the sliding window that appear in the preset search direction, including their pixel position information and the number of occurrences of the same pixel; and calculate the grayscale value similarity between each pair of specific pixel points searched in the corresponding preset search direction, including calculating the grayscale information similarity between a pair of specific pixel points that have not been traversed before, or directly reading the grayscale information similarity between a pair of specific pixel points that have been traversed before from the storage space (such as image memory, cache space or other memory space); then enter step S202; wherein, the pixel point currently covered by the center position of the sliding window is the most recently set center pixel point.
[0051] It should be supplemented that, before the sliding window starts sliding for the first time in the image to be processed, the pixel points are searched along a preset search direction in the image area currently framed by the sliding window, and the gray value similarity corresponding to each pair of specific pixel points searched in the corresponding preset search direction is calculated. At this time, it is determined that the sliding window has performed a sliding operation in the image to be processed, which can be expressed as starting from a starting pixel point of the sliding window in the image area currently framed by the sliding window, searching for pixel points along a preset search direction, recorded as the neighborhood pixel points (at least 2) of the starting pixel point, and sequentially obtaining the gray value similarity between two neighborhood pixel points that can constitute a pair of specific pixel points searched in the corresponding preset search direction. Of course, there are more than one pair of pixel points (at least two pixel points) searched in the corresponding preset search direction. At this time, it is determined that the sliding window has completed a sliding operation. This is a sliding operation of the sliding window based on the extraction of pixel points in a single fixed search direction. Since the number of pixel points processed in a single-direction sliding operation is reduced, the hit rate of data in the cache is improved. It should be noted that the preset search direction before the first sliding in the image to be processed is the same as the preset search direction after sliding a preset step length in the image to be processed.
[0052] Step S202, repeating step S201 until the sliding window covers all pixel points in the image to be processed and obtains the gray value similarity corresponding to each pair of specific pixel points in all preset search directions, then determining that the sliding window completes a round of full coverage operation on the image to be processed; wherein, the preset search direction along which the image to be processed is kept the same in the same round of full coverage operation; then entering step S203; in this embodiment, in the same round of full coverage operation, the sliding window undergoes multiple sliding operations and keeps the preset search direction the same in each sliding operation, until all image areas framed by the sliding window have covered all pixel points in the image to be processed, and obtain the gray value similarity corresponding to all pairs of specific pixel points in the corresponding preset search direction, then entering step S203 to prepare to start executing the next round of full coverage operation.
[0053] It should be noted that, in the same round of full coverage operation, since the sliding window slides multiple times in the image to be processed, the pixel points covered by the center position of the sliding window in the current sliding operation are different from the pixel points covered by the center position of the sliding window in a previously performed sliding operation; wherein, the gray value similarity is used to indicate the degree of difference between the gray values of two pixels.
[0054] Step S203, adjust the preset search direction of the image to be processed along the current round of full coverage operation, obtain a new preset search direction of the image to be processed along the next round of full coverage operation, so that the preset search direction along the current round of full coverage operation is different from the preset search direction along the next round of full coverage operation, that is, any preset search direction along the current round of full coverage operation is different from any preset search direction along the next round of full coverage operation; then enter step S204; then enter step S204. Among them, the image area framed by the sliding window in the execution of the previous round of full coverage operation overlaps with the image area framed by the execution of the current round of full coverage operation, but the preset search directions along are different; and the preset search directions along any two rounds of full coverage operations are not opposite, so that in some embodiments, a pair of specific pixel points searched in the corresponding two rounds of full coverage operations are not exactly the same.
[0055] Step S204, repeating steps S201 to S203 until the sliding window performs the preset number of rounds of full coverage operation on the image to be processed, and then obtaining the gray value similarity corresponding to each pair of specific pixel points in all preset search directions, wherein all preset search directions are composed of a preset number of batches of preset search directions, each batch of preset search directions corresponds to a round of full coverage operation, and a batch of preset search directions corresponding to a round of full coverage operation are the same, wherein any preset search direction corresponding to a round of full coverage operation is different from any preset search direction corresponding to another round of full coverage operation. In this embodiment, in performing the preset number of rounds of full coverage operation on the image to be processed, the preset search directions along different rounds of full coverage operation are different, and the preset search directions along the same round of full coverage operation for the image to be processed are a search direction facing the same direction. Among them, this embodiment sets a plurality of preset search directions with regional representativeness, and matches them to the corresponding rounds of full coverage operation, so as to take into account the comprehensive coverage effect of the pixels in the traversal image area.
[0056] In summary, the aforementioned steps S201 to S204, according to the traversal method of the neighborhood pixel points in a specific direction and the acquisition method of their grayscale value similarity, determine that the sliding window has performed a sliding operation in the image to be processed, and then determine a round of full coverage operation on the image to be processed according to the full coverage sliding method of the sliding window on the image to be processed, thereby forming a full coverage operation mechanism for the neighborhood pixel points in different multiple preset search directions within the sliding window.
[0057] In view of the prior art, the sliding window fully and completely traverses all neighboring pixels in each convolution sliding process, and it is necessary to perform calculation operations on each central pixel and its 8 adjacent neighboring pixels, which involves frequent cross-row operations in multiple symmetrical directions. Each cross-row operation may be across three rows and multiple cross-row reading operations. Therefore, the image pixel processing method described in the above steps S201 to S204, by performing a preset number of full coverage operations on a pair of neighboring pixels in a preset search direction in the same image to be processed, can make each sliding operation in each round of full coverage operation read a fixed number of image rows in a fixed direction, reduce the number of times image data enters and exits the cache space, and improve the image traversal speed by reducing the number of pixels searched and calculated.
[0058] As an embodiment 1, the gray value similarity corresponding to each pair of specific pixel points searched in the preset search direction is calculated as follows:
[0059] Whenever a pair of specific pixel points are searched along the corresponding preset search direction, the gray value similarity between the pixel point searched along the corresponding preset search direction and the same preset boundary point of the image area currently framed by the sliding window is calculated; wherein, the pixel point searched along the corresponding preset search direction and the same preset boundary point of the image area currently framed by the sliding window form a pair of specific pixel points, that is, a pair of computational pixel point pairs, then for each sliding operation, each time the sliding window slides a preset step length in the image to be processed, each pixel point searched along the same preset search direction is formed into a corresponding pair of specific pixel points with the same preset boundary point of the image area currently framed by the sliding window, then the number of pixel points searched in the same preset search direction is the number of computational pixel point pairs (in pairs). Therefore, in this embodiment, the boundary point of the image area framed by the sliding window is selected as the search starting point, and also as the reference center point for the subsequent calculation of the gray value similarity, so that the number of pixel points searched along the same preset search direction under a single sliding operation of the sliding window is greater than the number of pixel points searched in the neighborhood along the same preset search direction starting from the center position of the sliding window.
[0060] Specifically, when the preset search direction is from the upper left corner point of the image area currently framed by the sliding window to the lower right corner point thereof, the preset boundary point is the upper left corner point of the image area currently framed by the sliding window. Figure 3 As shown in the dotted box of the upper left corner of the framed image in the upper left corner, in the current sliding operation, point A is located at the upper left corner of the image area currently framed by the sliding window, point C is located at the lower right corner of the image area currently framed by the sliding window, and point B is located at the pixel position currently covered by the center position of the sliding window. If the preset search direction is from the upper left corner point A of the image area currently framed by the sliding window to its lower right corner point C, point B will be searched along the preset search direction, and the preset boundary point is point A. Starting from point A, point B and point C are searched in sequence along the corresponding preset search direction, then point B and point A form a pair of specific pixel points, and the grayscale value similarity between point B and point A is calculated at the same time; point C and point A form another pair of specific pixel points, and the grayscale value similarity between point C and point A is calculated at the same time; so far, in the current sliding operation, the grayscale value similarity between two pairs of specific pixel points is obtained.
[0061] Another example Figure 3As shown in the dotted box on the upper left that does not touch the image boundary, in the same round of full coverage operation, relative to the current sliding operation, in a subsequent sliding operation, point B is located at the upper left corner point of the image area currently framed by the sliding window, point D is located at the lower right corner point of the image area currently framed by the sliding window, and point C is located at the pixel position currently covered by the center position of the sliding window. If the preset search direction is from the upper left corner point B of the image area currently framed by the sliding window to its lower right corner point D, point C will be searched along the preset search direction, and the preset boundary point is point B. Starting from point B, point C and point D are searched in sequence along the corresponding preset search direction, then point C and point B form a pair of specific pixel points, and the grayscale value similarity between point C and point B is calculated at the same time; point D and point B form another pair of specific pixel points, and the grayscale value similarity between point D and point B is calculated at the same time; so far, in a subsequent sliding operation, the grayscale value similarity between two pairs of specific pixel points is obtained.
[0062] When the preset search direction is from the lower right corner point of the image area currently framed by the sliding window to the upper left corner point thereof, the preset boundary point is the lower right corner point of the image area currently framed by the sliding window. Figure 3 As shown, if in the current sliding operation, point B is located at the upper left corner point of the image area currently framed by the sliding window, point D is located at the lower right corner point of the image area currently framed by the sliding window, and point C is located at the pixel position currently covered by the center position of the sliding window, if the preset search direction is from the lower right corner point D of the image area currently framed by the sliding window to its upper left corner point B, point C will be searched along the preset search direction, the preset boundary point is point D, starting from point D, point C and point B are searched in sequence along the corresponding preset search direction, then point C and point D form a pair of specific pixel points, and the grayscale value similarity between point C and point D is calculated at the same time; point B and point D form another pair of specific pixel points, and the grayscale value similarity between point B and point D is calculated at the same time; so far, in the currently executed sliding operation, the grayscale value similarity between two new pairs of specific pixel points is obtained.
[0063] By the same token, it can be deduced that: when the preset search direction is from the upper right corner point of the image area currently framed by the sliding window to its lower left corner point, and the preset boundary point is the upper right corner point of the image area currently framed by the sliding window, then starting from the upper right corner point of the image area currently framed by the sliding window, pixel points are searched sequentially along the diagonal line of the image area currently framed by the sliding window, and each pixel point in the lower left corner except the upper right corner point of the image area is searched in the image area currently framed by the sliding window, and the grayscale value similarity between each searched pixel point and the upper right corner point of the currently framed image area is calculated, that is, the grayscale value similarity required for a sliding operation is obtained. Alternatively, when the preset search direction is from the lower left corner point of the image area currently framed by the sliding window to its upper right corner point, and the preset boundary point is the lower left corner point of the image area currently framed by the sliding window, then starting from the lower left corner point of the image area currently framed by the sliding window, pixel points are searched sequentially along the diagonal line of the image area currently framed by the sliding window, and each pixel point in the upper right corner except the lower left corner point of the image area is searched in the image area currently framed by the sliding window, and the grayscale value similarity between each searched pixel point and the lower left corner point of the currently framed image area is calculated, so as to obtain the grayscale value similarity required for a sliding operation.
[0064] When the preset search direction is horizontal to the left, the preset boundary point is the midpoint of the right boundary of the image area currently framed by the sliding window; or, when the preset search direction is horizontal to the right, the preset boundary point is the midpoint of the left boundary of the image area currently framed by the sliding window; the specific search and calculation method concept is consistent with the above-mentioned embodiment, specifically referring to the embodiment in which the preset boundary point is each corner point of the image area currently framed by the sliding window, including the embodiment corresponding to the lower left corner point, the upper left corner point, the lower right corner point or the upper right corner point. Among them, the midpoint of the right boundary and the midpoint of the left boundary are symmetrical about the center in the same framed image area.
[0065] When the preset search direction is a vertical upward direction, the preset boundary point is the midpoint of the upper boundary of the image area currently framed by the sliding window; when the preset search direction is a vertical downward direction, the preset boundary point is the midpoint of the lower boundary of the image area currently framed by the sliding window. The specific search and calculation method concept is consistent with the aforementioned embodiment, specifically referring to the embodiment in which the preset boundary point is each corner point of the image area currently framed by the sliding window, including the embodiment corresponding to the lower left corner point, the upper left corner point, the lower right corner point or the upper right corner point. Among them, the midpoint of the upper boundary and the midpoint of the lower boundary are symmetrical about the center in the same framed image area.
[0066] In the aforementioned embodiment, all preset boundary points serving as the search starting points of the image area framed by the sliding window are symmetrical about the center of the sliding window, and these preset boundary points symmetrical about the center traverse the pixel points along the corresponding preset search directions respectively, so that in multiple rounds of full coverage operations in which the preset search directions are changed from round to round, the search range covers the local area of the image to be processed in the corresponding preset search directions to the greatest extent.
[0067] As a second embodiment, the gray value similarity between each pair of specific pixel points searched in the corresponding preset search direction is calculated as follows:
[0068] Whenever a pair of specific pixel points is searched along the corresponding preset search direction, the grayscale value similarity between the two pixel points symmetrical about the center pixel point searched in the corresponding preset search direction is calculated; for each sliding operation in each round of full coverage operation, the two pixel points symmetrical about the center pixel point form a pair of specific pixel points, that is, a pair of operational pixel point pairs, and the two pixel points symmetrical about the center pixel point searched in a preset search direction form a pair of operational pixel point pairs, wherein half of the number of pixel points searched in the same preset search direction is the number of operational pixel point pairs (in pairs); the pixel point covered by the center position of the sliding window in the currently framed image area is the center pixel point; then for each sliding operation, when the sliding window slides a preset step size in the image to be processed, two pixel points symmetrical about the center pixel point are obtained along the same preset search direction, and the grayscale value similarity between the two pixel points symmetrical about the center pixel point is calculated. Therefore, under the condition of a single sliding of the sliding window, this embodiment chooses to calculate the grayscale value similarity between two pixel points symmetrical about the central pixel point as the processing result of a pair of specific pixel points, and skips calculating the grayscale value similarity between the pixel point currently covered by the center position of the sliding window and its neighboring pixel points, so as to avoid repeated calculation of the grayscale value similarity between the previously determined center pixel point and the currently determined center pixel point after the center position of the sliding window is translated.
[0069] In some embodiments, Figure 3As shown in the dotted box of the upper left corner of the framed image in the upper left corner, in the current sliding operation, point A is located at the upper left corner of the image area currently framed by the sliding window, point C is located at the lower right corner of the image area currently framed by the sliding window, and point B is located at the pixel position currently covered by the center position of the sliding window. If the preset search direction is from the upper left corner point A of the image area currently framed by the sliding window to its lower right corner point C, then in the current sliding operation, point A and point C are searched in sequence along the corresponding preset search direction. Although point B will be traversed along the corresponding preset search direction, point B is skipped during the search process. Then point C and point A are symmetrical about the central pixel point B, then point C and point A form a pair of specific pixel points, and the grayscale value similarity between point C and point A is calculated at the same time. So far, in the current sliding operation, the grayscale value similarity between a pair of specific pixel points is obtained.
[0070] In some embodiments, Figure 3 As shown in the dotted box on the upper left that does not touch the image boundary, in the same round of full coverage operation, relative to the current sliding operation, in a subsequent sliding operation, point B is located at the upper left corner point of the image area currently framed by the sliding window, point D is located at the lower right corner point of the image area currently framed by the sliding window, and point C is located at the pixel position currently covered by the center position of the sliding window. If the preset search direction is from the upper left corner point B of the image area currently framed by the sliding window to its lower right corner point D, then in the subsequent sliding operation, point B and point D are searched in sequence along the corresponding preset search direction. Although point C will be traversed along the corresponding preset search direction, point C is skipped during the search process. Then point B and point D form a pair of specific pixel points, and the grayscale value similarity between point B and point D is calculated at the same time. At this point, in a subsequent sliding operation, the grayscale value similarity between a new pair of specific pixel points is obtained.
[0071] In summary, in the current sliding operation, whenever a pair of specific pixel points is searched along the corresponding preset search direction, whether it is calculating the grayscale value similarity between two pixel points symmetrical about the central pixel point searched in the corresponding preset search direction, or calculating the grayscale value similarity between a pixel point searched in the corresponding preset search direction and the same preset boundary point of the image area currently framed by the sliding window, if the pixel point searched along the preset search direction is a pixel point searched in a previously executed sliding operation, then the pair of specific pixel points searched in the current sliding operation is different from any pair of specific pixel points searched in the previously executed sliding operation, so that the pixel positions of the same pair of specific pixel points are not repeatedly traversed, and thus there will be no phenomenon of repeatedly calculating the grayscale value similarity between the pair of specific pixel points; wherein, the pixel points covered by the center position of the sliding window in the current sliding operation are different from the pixel points covered by the center position of the sliding window in a previously executed sliding operation. Therefore, after each sliding operation, the sliding window keeps searching for the "latest" data, regardless of which round of full coverage operation it is in. Each round of full coverage operation has a corresponding preset search direction.
[0072] As a third embodiment, the gray value similarity between each pair of specific pixel points searched in the corresponding preset search direction is calculated as follows:
[0073] Whenever a pair of specific pixel points are searched along the corresponding preset search direction, the grayscale value similarity between the neighborhood pixel points searched in the corresponding preset search direction and the center pixel point is calculated non-repeatedly; wherein, any neighborhood pixel point searched in the corresponding preset search direction and the center pixel point form a pair of specific pixel points, the pixel point covered by the center position of the sliding window in the currently framed image area is the center pixel point, and the pixel point in the neighborhood of the center pixel point is the neighborhood pixel point. Therefore, in this embodiment, under the condition of each sliding of the sliding window, the grayscale value similarity between the pixel points searched in sequence in the corresponding preset search direction and the center pixel point is used as the processing result of a pair of specific pixel points, so that the obtained grayscale value similarity focuses on the change of the pixel value near the neighborhood space of the center pixel point along a specific direction, and will not affect the pixel value on the edge too much, thereby ensuring the preservation of the pixel value near the edge of the image to be processed. It is suitable for bilateral filtering of the image to be processed.
[0074] It is worth noting that the preset search direction is configured so that by searching for pixels along the preset search direction, the center pixel point can always be searched. The center pixel point is the pixel point covered by the center position of the sliding window within the currently framed image area. This is applicable to any embodiment.
[0075] Specifically, the method for non-repetitively calculating the grayscale value similarity between the neighborhood pixel points searched in the corresponding preset search direction and the central pixel point includes: if the pixel point covered by the center position of the sliding window in the current sliding operation is a pixel point searched along the preset search direction in a previously executed sliding operation, then the pixel point covered by the center position of the sliding window in the current sliding operation is set as the first reference center pixel point, and at the same time, it is determined that the pixel point covered by the center position of the sliding window in the previously executed sliding operation is a pixel point that can be searched along the preset search direction in the image area currently framed by the sliding window, which is determined by the The coverage range of the image area framed by the sliding window is determined, and the pixel point covered by the center position of the sliding window in the previously executed sliding operation is set as the second reference center pixel point; wherein, in the previously executed sliding operation, the first reference center pixel point and the second reference center pixel point are the pair of specific pixel points and will be repeatedly traversed; wherein, in the current sliding operation, the grayscale value similarity between the first reference center pixel point and the second reference center pixel point is calculated in the previously executed sliding operation, is a pre-known value, and is the grayscale value similarity between a pair of specific pixel points at the corresponding positions obtained for the first time.
[0076] Then, if a pixel point searched along the preset search direction in the image area currently framed by the sliding window is the central pixel point covered by the center position of the sliding window in the previously executed sliding operation, it is determined that the position of the second reference central pixel point is searched, and the grayscale value similarity between the aforementioned first reference central pixel point and the second reference central pixel point is directly updated to the grayscale value similarity between the currently searched pixel point and the pixel point covered by the center position of the sliding window in the current sliding operation, without performing the calculation of the grayscale value similarity again, thereby avoiding repeated calculation of the grayscale value similarity between the aforementioned first reference central pixel point and the second reference central pixel point; wherein, since in the same round of full coverage operation, the pixel point covered by the center position of the sliding window in the current sliding operation is different from the pixel point covered by the center position of the sliding window in the previously executed sliding operation, the sliding window is configured not to allow repeated framing of the same specific image area during the sliding process in the image to be processed, and the size of the specific image area is equal to the size of the sliding window. Preferably, the sliding direction of the sliding window in the image to be processed is configured not to allow repeated framing of the same specific image area, and the size of the specific image area is equal to the size of the sliding window. Compared with the prior art, in the process of sliding the sliding window in the image to be processed, this embodiment controls the same pair of pixels not to be repeatedly traversed, thereby controlling the gray value similarity between each pair of pixels in a relative position relationship to be calculated only once, and the gray value similarity calculated when the pair of pixels is first traversed can be configured as the gray value similarity required to be obtained when the pair of pixels is repeatedly traversed subsequently, thereby significantly reducing the number of calculations compared to the repeated calculation phenomenon in the prior art, and increasing the calculation speed of all pixels of the image to be processed. It is suitable for processing images with chips with small cache space.
[0077] In some embodiments, Figure 3As shown, a 3x3 sliding window (a window whose side length is 3 pixels) is used to slide the image to be processed. At the beginning, pixel A and pixel B are separated into two adjacent columns in the sliding window. If pixel A is located in the first column and the first row of the image to be processed and pixel B is located in the second column and the second row of the image to be processed, that is, pixel A is located in the upper left corner of the 3x3 sliding window, and pixel B is located in the pixel center (the pixel position of the second column and the second row), pixel A and pixel B are distributed in two adjacent rows along the lower right diagonal direction. If the preset search direction is from the lower right corner point of the image area currently framed by the sliding window to its upper left corner point, then the pixel A in the first column of the sliding window is searched (traversed) along the preset search direction and the gray value similarity between it and the center pixel B is obtained; then the pixel C in the third column of the sliding window is traversed along the preset search direction and the gray value similarity between it and the center pixel B is obtained, and then the 3x3 sliding window is controlled to slide once according to the preset step size.
[0078] Likewise Figure 3 As shown, when the 3x3 sliding window is framed from the second row of the image to be processed to the fourth row of the image to be processed, and the 3x3 sliding window is framed from the second column of the image to be processed to the fourth column of the image to be processed, a new sliding operation is started. At this time, there is a partially overlapping image area between the image area currently framed by the 3x3 sliding window and the image area framed by the previous sliding operation, wherein the partially overlapping image area includes pixel point B and pixel point C, which are respectively located in the first row of the first column and the second row of the second column of the 3x3 sliding window. Then, the gray value similarity between pixel point B and pixel point C has been calculated in the previous sliding operation, and there is no need to repeat the calculation in the current sliding operation, but directly use the previous calculation result; wherein, pixel point B can be recorded as the aforementioned first reference center pixel point, and pixel point C can be recorded as the aforementioned second reference center pixel point. Therefore, in some embodiments, within an image area framed by a 3x3 sliding window (3x3 bilateral filter kernel), in each sliding operation under the same round of full coverage operation, a pair of specific pixel points located at the same position searched along the same preset search direction only need to calculate the gray value similarity once. It should be noted that the aforementioned 3x3 is 3 times 3, and the 3x3 sliding window represents a sliding window of 3 rows and 3 columns.
[0079] In summary, for a pair of pixel points that may be repeatedly traversed and need to participate in the grayscale value similarity calculation, the grayscale value similarity between this type of pixel point pair is controlled to be calculated only once, and the image information similarity calculated when the specific pair of pixel points is first traversed can be configured as the grayscale value similarity required to be obtained when the specific pair of pixel points is subsequently repeatedly traversed. Compared with the repeated calculation phenomenon existing in the prior art, the number of calculations is reduced by half, and the calculation speed of all pixel points of the image to be processed is increased.
[0080] In the above-mentioned embodiment, during the same round of full coverage operation, each time the sliding window slides a preset step length in the image to be processed, the preset search direction along which the pixel points are searched in the image area currently framed by the sliding window is the same as the preset search direction along which the neighboring pixel points are searched in the image area framed by the sliding window last time; during each sliding operation, the number of pixel points searched along the corresponding preset search direction is equal, so that the pixel points with parallel orientation searched by the sliding window before and after sliding a preset step length are all located in the same row of the image to be processed, wherein the pixel points with parallel orientation refer to the neighboring pixel points located in the same preset search direction and at the same distance from the corresponding central pixel point. In addition, due to the characteristic that the image to be processed is stored in the memory space by row, this embodiment supports the CPU to keep reading the pixel points of the image to be processed from the memory row by row, or the CPU stores the pixel points of the image to be processed in the cache space row by row, thereby reducing the number of cross-row readings, reducing the probability of image data failure in the cache space, and improving the hit rate of the pixel points accessed by the CPU in the cache space.
[0081] Of course, in some embodiments, if the sliding window is in the initial state of image processing where the sliding operation has not yet begun, when the sliding window frames a specific image area in the image to be processed, the number of pixels traversed along the preset search direction in the image area framed by the sliding window is equal to: in the same round of full coverage operation, after the sliding window slides a preset step length in the image to be processed, the number of pixels traversed along the preset search direction in the image area framed by the sliding window. Thus, the sliding window is controlled to translate entirely within the image to be processed.
[0082] Based on the foregoing embodiment, the preset number is 4; the preset number of rounds of full coverage operations are respectively a first full coverage operation, a second full coverage operation, a third full coverage operation and a fourth full coverage operation, wherein the preset search directions corresponding to any two rounds of full coverage operations are not opposite, so that in Embodiment 1 and Embodiment 2, a pair of specific pixel points searched in the current sliding operation is different from any pair of specific pixel points searched in a previously performed sliding operation, so that the pixel positions of the same pair of specific pixel points are not repeatedly traversed, and thus there will be no phenomenon of repeatedly calculating the grayscale value similarity between the pair of specific pixel points.
[0083] In some embodiments, in the first full coverage operation, the preset search direction is from the lower right corner point of the image area currently framed by the sliding window to its upper left corner point, or from the upper left corner point of the image area currently framed by the sliding window to its lower right corner point; wherein, the direction from the lower right corner point of the image area currently framed by the sliding window to its upper left corner point is recorded as the upper left diagonal direction, and the direction from the upper left corner point of the image area currently framed by the sliding window to its lower right corner point is recorded as the lower right diagonal direction. Since all pairs of specific pixel points searched along the upper left diagonal direction will have the phenomenon of pixel position overlap with the specific pixels searched along the lower right diagonal direction, the operation of searching for pixel point pairs along the lower right diagonal direction and the operation of searching for pixel point pairs along the upper left diagonal direction cannot coexist in two rounds of full coverage operations.
[0084] In the second full coverage operation, the preset search direction is from the upper right corner point of the image area currently framed by the sliding window to its lower left corner point, or from the lower left corner point of the image area currently framed by the sliding window to its upper right corner point; wherein, the direction from the upper right corner point of the image area currently framed by the sliding window to its lower left corner point is recorded as the lower left diagonal direction, and the direction from the lower left corner point of the image area currently framed by the sliding window to its upper right corner point is recorded as the upper right diagonal direction, combined with Figure 3 It can be seen that since all pairs of specific pixel points searched along the lower left diagonal direction will overlap with the specific pixels searched along the upper right diagonal direction, the operation of searching for pixel pairs along the upper right diagonal direction and the operation of searching for pixel pairs along the lower left diagonal direction cannot coexist in two rounds of full coverage operations.
[0085] In the third full coverage operation, the preset search direction is a horizontal left direction or a horizontal right direction; Figure 3It can be seen that since all pairs of specific pixel points searched along the horizontal left direction will overlap with the specific pixels searched along the horizontal right direction, the operation of searching for pixel point pairs along the horizontal right direction and the operation of searching for pixel point pairs along the horizontal left direction cannot coexist in two rounds of full coverage operations.
[0086] In the fourth full coverage operation, the preset search direction is a vertical downward direction or a vertical upward direction. Figure 3 It can be seen that since all pairs of specific pixel points searched along the vertical downward direction will overlap with the specific pixels searched along the vertical upward direction, the operation of searching for pixel pairs along the vertical downward direction and the operation of searching for pixel pairs along the vertical upward direction cannot coexist in two rounds of full coverage operations.
[0087] To summarize, in this embodiment, all preset boundary points serving as the search starting points of the image area framed by the sliding window are symmetrical about the center of the sliding window, and these preset boundary points symmetrical about the center traverse the pixel points along the corresponding preset search directions respectively, so that in four rounds of full coverage operations in which the preset search directions are changed round by round, the search range covers the local area of the image to be processed in the corresponding preset search directions to the greatest extent.
[0088] Preferably, the sliding window is represented by a square window, and the side length of the square window is 2×W+1, where W is a positive integer. When the center position of the sliding window slides in the image to be processed, the pixel point covered becomes the central pixel point, and after the sliding window slides a preset step length, at most 2W neighboring pixel points can be framed in a pair of preset search directions.
[0089] As an embodiment, the image pixel processing method further includes:
[0090] In each round of full coverage operation, when the sliding window does not start to slide in the image to be processed, that is, in the initial state of using the sliding window to process the image to be processed, in the initial image area framed by the sliding window in the image to be processed, the pixels are searched in sequence along the corresponding preset search direction in the initial image area, and the spatial proximity between each pair of specific pixel points searched is calculated, and the calculated spatial proximity between each pair of specific pixel points with different relative position relationships is stored in a preset memory space, so that when the sliding window performs a sliding operation in the image to be processed later, the spatial proximity of the corresponding relative position relationship is directly called; wherein, before the sliding window starts to slide in the image to be processed and in each sliding operation performed according to the preset step size, in the image area framed by the sliding window, the spatial proximity between a pair of specific pixel points with the same relative position relationship is equal; wherein the spatial proximity is used to indicate the degree of difference in the spatial distance between two pixel points. Therefore, based on the fact that the preset search direction along which each round of full coverage operation is performed is different, this embodiment saves the general spatial proximity result calculated in the initial image area before each round of full coverage operation starts to perform the sliding operation, so as to be used in the subsequent shifted framed image, so as to more quickly call the spatial proximity of the corresponding position relationship calculated in advance, and avoid repeated calculation of the spatial proximity. Because before the sliding window starts to slide in the image to be processed (it can be before the first sliding operation) and in each sliding operation performed according to the preset step size, the spatial proximity corresponding to each pair of specific pixel points with the same relative position relationship in the image area framed in real time by the sliding window in the image to be processed is equal and has a fixed value, the spatial proximity corresponding to each pair of specific pixel points only needs to be calculated and saved before the sliding window starts the first sliding of each round of full coverage operation. So that in the same round of full coverage operation, when the sliding window subsequently slides in the image to be processed, the relative position relationship between the neighborhood pixel points traversed in real time and the pixel points covered in real time by the center position of the sliding window is called, and the spatial proximity calculated in advance on the corresponding position relationship is avoided. Figure 3 As shown, the spatial proximity between pixel point B and pixel point C is determined by calculating the positional relationship of a pair of specific pixel points in a preset search direction within a 3x3 sliding window before the sliding operation is started (understood as before the bilateral filtering operation is started), and will not change as the 3x3 sliding window slides in the image to be processed.
[0091] It should be noted that each pair of specific pixel points having the same relative position relationship means that the distance between the two pixel points in each pair of specific pixel points in the corresponding preset search direction is equal, and the preset search direction of each pair of specific pixel points is the same.
[0092] Preferably, the shape of the sliding window is parallel to the shape of the initial image area, and the area of the sliding window is equal to the area of the initial image area, so as to obtain a more complete spatial proximity corresponding to each specific pair of pixel points in a preset search direction. The obtained spatial proximity is more representative in the image to be processed and fully describes the positional relationship between the two pixel points in each specific pair of pixel points in various image areas.
[0093] For a sliding operation performed by the sliding window, the image pixel processing method further includes:
[0094] Multiply the grayscale similarity and spatial proximity between a pair of specific pixel points currently searched, and then configure the product as the weight of the first pixel point in the pair of specific pixel points relative to the second pixel point, as the weight of the grayscale value at the pixel position where the first pixel point is located; wherein, the pair of specific pixel points includes the first pixel point and the second pixel point; preferably, in combination with the aforementioned embodiment three, it can be known that any pixel point in the pair of specific pixel points is mutually located in the convolution kernel corresponding to the sliding window with the second pixel point as the center pixel point, so that the first pixel point and the second pixel point are repeatedly traversed in the same round of full coverage operation. Then, control the grayscale similarity and spatial proximity between the pair of specific pixel points currently searched to participate in the accumulation, and then configure the result of the accumulation under the current sliding operation as a total weight, which is used to represent the convolution result of the grayscale value of the image pixel point under a sliding operation and the sliding window. Then, the grayscale value of each first pixel point searched at the pixel position and its configured weight are multiplied and accumulated, and the result of the accumulation under the current sliding operation is configured as the weighted sum of the grayscale values of the pixels in the neighborhood space. Then, the ratio of the aforementioned weighted sum of grayscale values to the total weight is set as the weighted average of the grayscale values of the pixels in the neighborhood space of the second pixel point, which is used to represent the processing result of the local image under one sliding operation. In summary, this embodiment uses the product of grayscale value similarity and spatial proximity as the weight of the grayscale value at the corresponding pixel position of the image to be processed, and then uses the weight to perform weighted averaging on the grayscale values of the corresponding pixels, so that the weighted average result is the result of a denoising process of the image to be processed.
[0095] It should be noted that the currently searched neighborhood pixel point is located in the image area framed by a sliding window with a corresponding central pixel point as the center position; the sliding window is represented by a square window, and the side length of the square window is 2×W+1, where W is a positive integer. When the center position of the sliding window slides in the image to be processed, the pixel point covered becomes the central pixel point, and the sliding window is framed (4W) in one sliding operation (each translation of a preset step length). 2 +4W) neighborhood pixels.
[0096] On the basis of any of the foregoing embodiments, a method for calculating the grayscale value similarity between a pair of specific pixel points is as follows: among the pair of specific pixel points, first, one of the pixel points is set as a central pixel point, and the other pixel point is set as a neighborhood pixel point (not necessarily adjacent to the central pixel point in position), except that there is already a pixel point that is the central pixel point; then, the square of the difference between the grayscale value of the neighborhood pixel point and the grayscale value of a corresponding central pixel point is calculated to obtain square data of the grayscale change value; wherein, the neighborhood pixel point is located in an image area framed by a sliding window with the corresponding central pixel point as the center position, and the neighborhood pixel points participating in the grayscale value similarity calculation are arranged symmetrically left and right and up and down relative to the central pixel point in the image to be processed. image; then the square data of the grayscale change value is processed as a ratio with twice the square of the pixel domain parameter, and then the obtained ratio is used as a parameter and input into a preconfigured exponential function, and then the exponential function value calculated by the CPU is updated to the grayscale value similarity between a neighborhood pixel point and a corresponding center pixel point, that is, the grayscale value similarity between the pair of specific pixels; wherein the pixel domain parameter is a Gaussian distribution parameter, which is used to limit the range of change of the grayscale value similarity and determine the difference between the pixel values; the coefficient of the exponential part of the preconfigured exponential function is a minus sign to make the exponential part a subtracting function, and the exponential part is used to accept an independent variable, and the independent variable is derived from the ratio of the square data of the grayscale change value to twice the square of the pixel domain parameter.
[0097] In the above embodiment, the method for calculating the spatial proximity between a pair of specific pixel points is as follows: among the pair of specific pixel points, first, one of the pixel points is set as the center pixel point, and the other pixel point is set as the neighborhood pixel point (not necessarily adjacent to the center pixel point in position), except that there is already a pixel point that is the center pixel point; then, the square of the difference between the horizontal coordinate of the neighborhood pixel point and the horizontal coordinate of the corresponding center pixel point is calculated to obtain the square of the horizontal axis distance of the pixel; wherein, the neighborhood pixel point is located in the image area framed by the sliding window with the corresponding center pixel point as the center position, and the neighborhood pixel points participating in the spatial proximity calculation are arranged symmetrically with respect to the center pixel point in the left-right and top-bottom directions. In the aforementioned initial image area; the square of the difference between the ordinate of the neighborhood pixel point and the ordinate of a corresponding center pixel point is calculated to obtain the square of the pixel longitudinal axis distance; then the sum of the square of the pixel transverse axis distance and the square of the pixel longitudinal axis distance is processed by ratio with twice the square of the spatial domain parameter, and the obtained ratio is input as a parameter into the preconfigured exponential function, and then the exponential function value calculated by the CPU is set as the spatial proximity between a neighborhood pixel point and a corresponding center pixel point, that is, the spatial proximity between the pair of specific pixels; wherein the spatial domain parameter is a spatial parameter in the Euclidean distance formula, which is used to limit the range of change of the spatial proximity and determines the change of the spatial distance. The coefficient of the exponential part of the preconfigured exponential function is a negative sign to form a subtracting function for the exponential part, and the exponential part is used to accept an independent variable, and the independent variable is derived from the ratio of the sum of the square of the pixel transverse axis distance and the square of the pixel longitudinal axis distance to twice the square of the spatial domain parameter.
[0098] As an embodiment, in the process of executing the image pixel processing method, for the N pairs of specific pixel points traversed by the sliding window, the control CPU calls N calculation registers to parallelly calculate the image information similarity between the N pairs of specific pixel points traversed, and then can continue to call the relevant calculation registers to parallelly calculate the gray value similarity and the product of its spatial proximity between each pair of specific pixel points; wherein each calculation register is used to calculate the image information similarity between a pair of specific pixel points, and the image information similarity includes gray value similarity and spatial proximity, or is used to calculate the gray value similarity and the product of its spatial proximity between two corresponding pixel points in a pair of specific pixel points; different calculation registers independently perform the calculation operation of image information similarity or its corresponding product; wherein N is a positive integer greater than or equal to 1. Preferably, the processor used in this embodiment is a multi-core (for example, 8 cores or 16 cores) structure. Each core is a complete calculation register, and multiple calculation registers perform data calculation in parallel under the control of the Neon instruction set; wherein N is determined by a predefined search number and is associated with the size of the sliding window. This embodiment uses parallel computing to increase the speed of calculating the similarity of image information corresponding to multiple pairs of pixels, thereby speeding up image processing.
[0099] Preferably, the N pairs of specific pixel points traversed in one sliding operation performed by the sliding window are pixel points or neighboring pixel points searched in sequence along one of the preset search directions in an image area framed by the sliding window. The operation speed of a single sliding operation is accelerated, thereby increasing the speed of a full coverage operation on the image to be processed.
[0100] Based on the aforementioned embodiment, a chip is also disclosed, which is used to store the program code corresponding to the image pixel processing method. It is used to reduce the number of times the pixels of the image to be processed enter and exit the cache space when executing the image pixel processing method, wherein the cache space is set between the CPU and the memory used to store the image to be processed. The amount of calculation for the pixels in this embodiment increases linearly with the length and width of the sliding window instead of increasing quadratically. In particular, relative to images with millions of pixels, the degree of improvement in processing efficiency is adapted to the access speed and memory capacity of the cache space of the embedded device, so that after the memory stores limited pixels into the cache space, the CPU quickly reads the correct data and uses it for calculation.
[0101] Especially when more data than current demand is pre-stored in the cache space, reading some data into the cache space in advance can reduce access to the storage medium, so that the CPU reads two fixed rows from the cache space, which is more suitable for the operation of obtaining the difference between the pixels of the adjacent previous row and next row, thereby improving the reading speed and avoiding problems caused by crossing rows.
[0102] When the CPU adopts a multi-core (for example, 8-core or 16-core) structure, each core of the CPU is triggered to process data in parallel; the CPU can also be triggered to independently read and write each memory in the order of cache first and then memory for different memories independently connected to it.
[0103] The directional words such as "up (front)", "down (back)", "left" and "right" mentioned in the above embodiments, unless otherwise specified, refer to the up, down, left, right and other directions of the drawings, and vertical and horizontal refer to the vertical direction and horizontal direction of the drawings.
[0104] Those of ordinary skill in the art will understand that all or part of the steps of implementing the above-mentioned method embodiments can be completed by hardware related to program instructions. These programs can be stored in computer-readable storage media (such as ROM, RAM, magnetic disks or optical disks, etc., which can store program codes). When the program is executed, it executes the steps of the above-mentioned method embodiments. Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit them; although the present invention is described in detail with reference to the above-mentioned embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions described in the above-mentioned embodiments, or replace some or all of the technical features therein by equivalent; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. An image pixel processing method based on unidirectional search, It is characterized in that The image pixel processing method comprises: Whenever the sliding window slides once in the image to be processed according to the preset step length, the pixel points are searched along a preset search direction in the image area currently framed by the sliding window, and the gray value similarity corresponding to each pair of specific pixel points searched in the corresponding preset search direction is calculated; wherein, the pixel point covered by the center position of the sliding window in the currently framed image area is the central pixel point; the central pixel point can always be searched by searching the pixel points along the preset search direction; The gray value similarity corresponding to each pair of specific pixel points searched in the corresponding preset search direction is calculated as follows: whenever a pair of specific pixel points is searched along the corresponding preset search direction, the gray value similarity between a pixel point searched in the corresponding preset search direction and the same preset boundary point of the image area currently framed by the sliding window is calculated; wherein a pixel point searched in the corresponding preset search direction and the same preset boundary point of the image area currently framed by the sliding window constitute a pair of specific pixel points; Alternatively, the gray value similarity between each pair of specific pixel points searched in the corresponding preset search direction is calculated as follows: whenever a pair of specific pixel points is searched along the corresponding preset search direction, the gray value similarity between two pixel points searched in the corresponding preset search direction and symmetrical about the central pixel point is calculated; wherein the two pixel points symmetrical about the central pixel point constitute a pair of specific pixel points; Alternatively, the grayscale value similarity between each pair of specific pixel points searched in the corresponding preset search direction is calculated as follows: whenever a pair of specific pixel points is searched along the corresponding preset search direction, the grayscale value similarity between the neighborhood pixel points searched in the corresponding preset search direction and the central pixel point is calculated non-repeatedly; wherein, any neighborhood pixel point searched in the corresponding preset search direction and the central pixel point form a pair of specific pixel points, and the pixel points in the neighborhood of the central pixel point are neighborhood pixel points.
2. The image pixel processing method according to claim 1, It is characterized in that The image pixel processing method further comprises: Whenever the sliding window slides over all the pixels in the image to be processed, it is determined that the sliding window completes a round of full coverage operation on the image to be processed; When the sliding window performs a preset number of rounds of full coverage operations on the image to be processed, the gray value similarity corresponding to each pair of specific pixel points in all preset search directions is obtained, wherein the preset search directions along which the image to be processed is carried out in different rounds of full coverage operations are different, and the preset search directions along which the image to be processed is carried out in the same round of full coverage operations are kept the same; the preset search directions along which any two rounds of full coverage operations are carried out are not opposite; Among them, the number of preset search directions is set to a preset number.
3. The image pixel processing method according to claim 2, It is characterized in that Before the sliding window starts sliding for the first time in the image to be processed or each time the sliding window slides by a preset step length in the image to be processed, pixel points are searched along a preset search direction in the image area currently framed by the sliding window, and the gray value similarity corresponding to each pair of specific pixel points searched in the preset search direction is calculated to determine that the sliding window has performed a sliding operation in the image to be processed; Whenever all the image areas framed by the sliding window have slid through all the pixels in the image to be processed, and the gray value similarities corresponding to each pair of specific pixels in all preset search directions in the image area framed by the sliding window are obtained, it is determined that the sliding window has completed a round of full coverage operation on the image to be processed; In the same round of full coverage operation, the pixel points covered by the center position of the sliding window in the current sliding operation are different from the pixel points covered by the center position of the sliding window in a previously performed sliding operation; Among them, the gray value similarity is used to indicate the difference between the gray values of two pixels.
4. The image pixel processing method according to claim 3, It is characterized in that During the same round of full coverage operation, each time the sliding window slides a preset step length in the image to be processed, the preset search direction along which the pixel points are searched in the image area currently framed by the sliding window is the same as the preset search direction along which the pixel points are searched in the image area framed by the sliding window last time; During each sliding operation, within the image area framed by the sliding window, the number of pixel points searched out along the corresponding preset search direction is equal.
5. The image pixel processing method according to claim 4, It is characterized in that The preset number is 4; the preset number of rounds of full coverage operations are respectively a first full coverage operation, a second full coverage operation, a third full coverage operation and a fourth full coverage operation; In the first full coverage operation, the preset search direction is from the lower right corner point of the image area currently framed by the sliding window to the upper left corner point thereof, or from the upper left corner point of the image area currently framed by the sliding window to the lower right corner point thereof; In the second full coverage operation, the preset search direction is from the upper right corner point of the image area currently framed by the sliding window to the lower left corner point thereof, or from the lower left corner point of the image area currently framed by the sliding window to the upper right corner point thereof; In the third full coverage operation, the preset search direction is a horizontal left direction or a horizontal right direction; In the fourth full coverage operation, the preset search direction is a vertical downward direction or a vertical upward direction.
6. The image pixel processing method according to claim 5, It is characterized in that The sliding window is represented by a square window, and the side length of the square window is 2×W+1, where W is a positive integer.
7. The image pixel processing method according to claim 3, It is characterized in that When the preset search direction is from the upper left corner point of the image area currently framed by the sliding window to the lower right corner point thereof, the preset boundary point is the upper left corner point of the image area currently framed by the sliding window; When the preset search direction is from the lower right corner point of the image area currently framed by the sliding window to the upper left corner point thereof, the preset boundary point is the lower right corner point of the image area currently framed by the sliding window; When the preset search direction is from the upper right corner point of the image area currently framed by the sliding window to the lower left corner point thereof, the preset boundary point is the upper right corner point of the image area currently framed by the sliding window; When the preset search direction is from the lower left corner point of the image area currently framed by the sliding window to the upper right corner point thereof, the preset boundary point is the lower left corner point of the image area currently framed by the sliding window; When the preset search direction is a horizontal left direction, the preset boundary point is a midpoint of a right boundary of an image area currently framed by the sliding window; When the preset search direction is the horizontal right direction, the preset boundary point is the midpoint of the left boundary of the image area currently framed by the sliding window; When the preset search direction is a vertical upward direction, the preset boundary point is the midpoint of the upper boundary of the image area currently framed by the sliding window; When the preset search direction is a vertical downward direction, the preset boundary point is the midpoint of the lower boundary of the image area currently framed by the sliding window.
8. The image pixel processing method according to claim 3, It is characterized in that In the current sliding operation, if the pixel points searched along the preset search direction are the pixel points searched in a previously performed sliding operation, then the specific pair of pixel points searched in the current sliding operation is different from any specific pair of pixel points searched in the previously performed sliding operation, so that the pixel positions of the same pair of specific pixel points are not repeatedly traversed.
9. The image pixel processing method according to claim 3, It is characterized in that The method for non-repetitively calculating the gray value similarity between the neighborhood pixel points searched in the corresponding preset search direction and the central pixel point includes: If the pixel point covered by the center position of the sliding window in the current sliding operation is a pixel point searched along the preset search direction in a previously executed sliding operation, the pixel point covered by the center position of the sliding window in the current sliding operation is set as a first reference center pixel point, and at the same time, it is determined that the pixel point covered by the center position of the sliding window in the previously executed sliding operation is a pixel point that can be searched along the preset search direction in the image area currently framed by the sliding window, and the pixel point covered by the center position of the sliding window in the previously executed sliding operation is set as a second reference center pixel point; Wherein, in the previously performed sliding operation, the first reference central pixel point and the second reference central pixel point are the pair of specific pixel points; Wherein, in the current sliding operation, the gray value similarity between the first reference central pixel point and the second reference central pixel point is calculated in the previously performed sliding operation; Then, if a pixel point searched along the preset search direction in the image area currently framed by the sliding window is the center pixel point covered by the center position of the sliding window in the previously performed sliding operation, the grayscale value similarity between the aforementioned first reference center pixel point and the second reference center pixel point is directly updated to the grayscale value similarity between a currently searched pixel point and the pixel point covered by the center position of the sliding window in the current sliding operation.
10. The image pixel processing method according to claim 4, It is characterized in that The image pixel processing method further comprises: In each round of full coverage operation, when the sliding window does not start to slide in the image to be processed, within the initial image area framed by the sliding window in the image to be processed, pixel points are searched sequentially along the corresponding preset search direction in the initial image area, and the spatial proximity corresponding to each pair of specific pixel points searched is calculated, and the calculated spatial proximity corresponding to each pair of specific pixel points with different relative position relationships is stored in a preset memory space, so that when the sliding window subsequently performs a sliding operation in the image to be processed, the spatial proximity corresponding to the corresponding relative position relationship is directly called; Before the sliding window starts sliding in the image to be processed and in each sliding operation performed according to the preset step size, in the image area framed by the sliding window, the spatial proximity corresponding to each pair of specific pixel points with the same relative position relationship is equal; Among them, spatial proximity is used to indicate the degree of difference in the spatial positions between two pixels.
11. The image pixel processing method according to claim 10, It is characterized in that For a sliding operation performed by the sliding window, the image pixel processing method further includes: Multiplying the grayscale similarity and spatial proximity between a pair of specific pixel points currently searched, and then configuring the product as the weight of the first pixel point relative to the second pixel point in the pair of specific pixel points as the weight of the grayscale value at the pixel position where the first pixel point is located; wherein the pair of specific pixel points includes the first pixel point and the second pixel point; Control the product of the grayscale similarity and spatial proximity between a pair of specific pixels currently searched to participate in the accumulation, and then configure the accumulated result of the current sliding operation as a total weight; Then, the grayscale value of each first pixel point searched at the pixel position and its configured weight value are multiplied and accumulated, and the accumulated result of the current sliding operation is configured as the weighted sum of the grayscale values of the pixel points in the neighborhood space; Then, the ratio of the aforementioned weighted sum of gray values to the total weight is set as the weighted average of the gray values of the pixels in the neighborhood space of the second pixel, which is used to represent the processing result of the local image under one sliding operation.
12. The image pixel processing method according to claim 4, It is characterized in that In the process of executing the image pixel processing method, for the N pairs of specific pixel points traversed by the sliding window, the CPU is controlled to call N calculation registers to parallelly calculate the image information similarity between the N pairs of specific pixel points traversed; Each calculation register is used to calculate the image information similarity between a pair of specific pixel points, and the image information similarity includes gray value similarity and spatial domain proximity; Here, N is a positive integer greater than or equal to 1.
13. The image pixel processing method according to claim 12, It is characterized in that The N pairs of specific pixel points traversed in one sliding operation performed by the sliding window are pixel points or neighborhood pixel points searched sequentially along a preset search direction within an image area framed by the sliding window.
14. A chip, It is characterized in that The chip is used to store the program code corresponding to the image pixel processing method described in any one of claims 1 to 13.
Citation Information
Patent Citations
Noise reduction method, device and equipment for non-local mean filtering
CN109785246A
Image restoration method, device and apparatus and storage medium
CN111353946A