Anti-aliasing system and method based on edge detection
Through the anti-aliasing method based on edge detection, using blur processing, Sobel operator and GPU parallel computing, the problem of insufficient edge smoothness and real-time performance of traditional algorithms in infrared images is solved, and efficient aliasing removal and detail of infrared images are achieved. retained, improving image quality and processing efficiency.
Patent Information
- Application Number
- CN202410865255.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-01
- Publication Date
- 2024-09-06
- Estimated Expiration
- 2044-07-01
AI Technical Summary
Traditional anti-aliasing algorithms have limitations in edge smoothness, real-time requirements and calculation time in infrared image processing, making it difficult to meet the needs of real-time processing. In particular, the common aliasing effect in infrared images affects image quality.
An anti-aliasing method based on edge detection is used to blur the original infrared image and obtain gradient information, combined with the Sobel operator to detect jagged areas, use interpolation to calculate smooth non-straight edge pixels, and use GPU parallel computing to divide the image into different The resolution and importance are processed in segments, and finally the edge areas are fused by Gaussian filtering.
Significantly improves the smoothness and naturalness of image edges, enhances the real-time and accuracy of processing, achieves efficient recognition and processing of smoothing and aliasing effects of image noise, and outputs high-quality anti-aliased images.
Smart Images

Figure CN118397029B
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image processing, and in particular to an anti-aliasing system and method based on edge detection. Background Art
[0002] Due to the characteristics of infrared image acquisition equipment and factors such as sampling and quantization during the imaging process, there is often an aliasing effect in infrared images, which will reduce the image quality and affect subsequent image analysis and processing tasks.
[0003] Traditional anti-aliasing algorithms have certain limitations in terms of edge smoothness, real-time requirements and anti-aliasing effects. Especially in real-time processing scenarios, traditional algorithms often require a long calculation time and are difficult to meet real-time requirements. Summary of the invention
[0004] In view of the problems existing in the above-mentioned traditional anti-aliasing algorithm, the present invention is proposed.
[0005] Therefore, the problem to be solved by the present invention is how to provide a system and method for improving the clarity, edge continuity and detail retention capability of an image.
[0006] In order to solve the above technical problems, the present invention provides the following technical solutions:
[0007] In the first aspect, an embodiment of the present invention provides an anti-aliasing method based on edge detection, which includes: blurring the input original infrared image, smoothing the noise and retaining the edge information; using the Sobel operator to obtain the image gradient information, judging the edge pixel type according to the gradient amplitude and direction, and detecting the aliasing effect area; for the detected non-straight edge pixels, interpolating the detected non-straight edge pixels according to the pixel values around them; introducing GPU parallel computing, dividing the image into segments with different resolutions and importance, and processing them on different GPU computing threads respectively; performing Gaussian filtering on the interpolated edge area, smoothing the straight edge and oblique edge transition area, fusing the processed edge pixels with the original non-edge pixels, and outputting an anti-aliasing image.
[0008] As a preferred embodiment of the anti-aliasing method based on edge detection according to the present invention, wherein: the blurring process of the input original infrared image includes the following steps: calculating the mean value avg and standard deviation std of the pixel values within a certain neighborhood around each pixel of the image; for each pixel value, calculating the difference from the neighborhood mean value, denoted as diff; according to the value of diff, redistributing the pixel value: if -k*std < diff < k*std, the pixel remains unchanged; if diff ≥ k*std, the pixel value = avg + rand()*std; if diff ≤ -k*std, the pixel value = avg - rand()*std; where k is a constant; rand() is a uniform random number between 0 and 1; repeating the above steps and iterating multiple times until the image reaches the desired degree of blurring and smoothing.
[0009] As a preferred embodiment of the anti-aliasing method based on edge detection according to the present invention, wherein: obtaining the image gradient information by using the Sobel operator includes: performing a convolution operation on the input original image by using the Sobel operator to obtain the gradient information in the horizontal and vertical directions of the image: calculating the pixel gradient magnitude The formula for is:
[0010] ;
[0011] The formula for calculating the gradient direction information is:
[0012] ;
[0013] Wherein, is the horizontal gradient component and is the vertical gradient component.
[0014] As a preferred embodiment of the anti-aliasing method based on edge detection according to the present invention, wherein: judging the edge pixel type according to the gradient magnitude and direction includes: judging whether it is an edge pixel according to The calculation formula of is: The calculation formula for is:
[0015] ;
[0016] According to the value of to judge whether the pixel is a straight edge or a slanted edge The calculation formula for is:
[0017] ;
[0018] Wherein, is the gradient magnitude, is the error range; Edge determines whether it is an edge pixel. If it is an edge pixel, the gradient direction of the edge pixel is determined to determine whether it is a bevel pixel area; a directional gradient histogram of the image is constructed, and the distribution of the gradient value in each direction is counted. Combined with the gradient amplitude judgment, the pixels in the sawtooth area are further analyzed.
[0019] As a preferred solution of the anti-aliasing method based on edge detection of the present invention, the interpolation calculation includes: the interpolation formula is as follows:
[0020] ;
[0021] in, represents the result after interpolation; A, B, C are matrices, which are respectively represented as follows:
[0022] ;
[0023] ;
[0024] ;
[0025] Among them, the A and C matrices are edge smoothing parameters, and the calculation formula of S in the matrix is as follows:
[0026] ;
[0027] Among them, im(i,j) represents the position index of the pixel in the image, where i represents the row index and j represents the column index; x represents the gradient direction of the current pixel; pi represents the circumference π; eps is a constant; v represents the vertical gradient component of the current pixel; u represents the horizontal gradient component of the current pixel. and The gradient direction of the pixel Decide.
[0028] As a preferred solution of the anti-aliasing method based on edge detection described in the present invention, the interpolation calculation also includes: adaptively adjusting the coefficients of the three matrices A, B, and C according to the local neighborhood characteristics of the current pixel to implement an adaptive interpolation strategy.
[0029] As a preferred solution of the anti-aliasing method based on edge detection described in the present invention, the introduction of GPU parallel computing to divide the image into segments of different resolutions and importance includes the following steps: using a dual threshold algorithm for edge pixels to obtain a binary edge image; dividing the edge image into multiple resolution levels, and extracting corresponding edge information for each resolution level; performing scene analysis on the original image, detecting the main objects in the image, and dividing the image into blocks according to the importance of the main objects; evaluating the characteristics of the edge image blocks at each resolution level to obtain a complexity score; giving a weight score to the edge image blocks in each important area according to the importance of the object to which it belongs, and marking the edge image blocks with high scores as complex or important areas; sending different edge image segments to different computing threads of the GPU; according to the scores, assigning complex or important edge image blocks to the high-performance computing units of the GPU, and assigning simple or secondary edge image blocks to the low-performance computing units of the GPU; and each computing thread performs subsequent edge processing operations in parallel on the GPU.
[0030] As a preferred solution of the anti-aliasing method based on edge detection of the present invention, the calculation process of the complexity score is as follows: assuming that the size of the edge image block is MxN, the number of edge pixels is E, and the edge pixel ratio is:
[0031] ;
[0032] Let the gradient values of all edge pixels be {g1, g2, ..., g E}, then the edge gradient mean is:
[0033] ;
[0034] The standard deviation of edge gradient is:
[0035] ;
[0036] For each edge pixel, count the number of neighboring pixels K whose jump is greater than the threshold T in its 8-neighborhood, and get the aliasing coefficient:
[0037] ;
[0038] The complexity score is calculated as follows:
[0039] ;
[0040] in, are the corresponding weight coefficients respectively.
[0041] In the second aspect, in order to further solve the problems existing in the traditional anti-aliasing algorithm, the embodiment of the present invention provides an anti-aliasing system based on edge detection, which includes: a blur processing module, which is used to blur the input original infrared image, smooth the noise and retain the edge information; a Sobel operator module, which is used to obtain the image gradient information using the Sobel operator, and judge the edge pixel type according to the gradient amplitude and direction, and detect the sawtooth effect area; an interpolation calculation module, which is used to perform interpolation calculation on the detected non-straight edge pixels according to the pixel values around them; a GPU parallel computing module, which is used to introduce GPU parallel computing, divide the image into segments with different resolutions and importance, and process them on different GPU computing threads respectively; a Gaussian filtering module, which is used to perform Gaussian filtering on the interpolated edge area, and smooth the straight edge and oblique edge transition area; a fusion module, which is used to fuse the processed edge pixels with the original non-edge pixels, and output an anti-aliasing image.
[0042] In a third aspect, an embodiment of the present invention provides a computer device, comprising a memory and a processor, wherein the memory stores a computer program, wherein: when the computer program is executed by the processor, any step of the anti-aliasing method based on edge detection as described in the first aspect of the present invention is implemented.
[0043] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium having a computer program stored thereon, wherein: when the computer program is executed by a processor, any step of the anti-aliasing method based on edge detection as described in the first aspect of the present invention is implemented.
[0044] The beneficial effects of the present invention are as follows: by calculating the gradients of the image in the horizontal and vertical directions, the present invention can accurately detect the edges in the image and identify different types of edge pixels according to the gradient information; by using interpolation calculation to smooth the non-straight edge pixels, the smoothness of the image edge can be significantly improved, making the image look more natural and smooth; at the same time, by performing segmented processing according to the image resolution and importance, the computing resources can be reasonably allocated, and the accuracy and real-time performance of the processing can be improved; the present invention realizes the smoothing of image noise, the accurate detection of edges, the identification and processing of aliasing effects, and efficient parallel computing processing, and achieves the purpose of outputting high-quality anti-aliasing images. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for describing the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work. Among them:
[0046] Figure 1Flowchart of the anti-aliasing method based on edge detection in Embodiment 1.
[0047] Figure 2 Structural diagram of the anti-aliasing system based on edge detection in Embodiment 1. Detailed implementation manners
[0048] To make the above objects, features, and advantages of the present invention more obvious and understandable, the following will describe the detailed implementation manners of the present invention with reference to the accompanying drawings of the specification.
[0049] In the following description, many specific details are set forth to fully understand the present invention. However, the present invention can also be implemented in other ways different from those described herein. Those skilled in the art can make similar extensions without departing from the connotation of the present invention. Therefore, the present invention is not limited by the specific embodiments disclosed below.
[0050] Secondly, the so-called "one embodiment" or "embodiment" herein refers to a specific feature, structure, or characteristic that can be included in at least one implementation manner of the present invention. The phrase "in one embodiment" appearing in different places in this specification does not necessarily refer to the same embodiment, nor is it a separate or alternative embodiment that is mutually exclusive with other embodiments.
[0051] Embodiment 1
[0052] Referring to Figure 1 and Figure 2 , this is the first embodiment of the present invention. This embodiment provides an anti-aliasing method based on edge detection, including the following steps:
[0053] S1: Blur the input original infrared image to smooth the noise and retain the edge information.
[0054] Preferably, blurring the input original infrared image includes the following steps:
[0055] Calculate the average value avg and standard deviation std of the pixel values within a certain neighborhood (such as a 3x3 window) around each pixel of the image;
[0056] For each pixel value, calculate the difference between it and the neighborhood average value, denoted as diff;
[0057] According to the value of diff, redistribute the pixel value:
[0058] If -k*std < diff < k*std (where k is a small constant, such as 0.5), then keep the pixel unchanged;
[0059] If diff ≥ k*std, pixel value = avg + rand()*std; (where rand() is a uniform random number between 0 and 1)
[0060] If diff≤-k*std, pixel value = avg-rand()*std.
[0061] Repeat the above steps and iterate multiple times until the image reaches the desired blur and smoothness.
[0062] It should be noted that the above method is simple to operate and only involves basic pixel value calculations, without the need for complex convolutions or transformations. The degree of smoothing can be controlled by adjusting the k value and the number of iterations, and certain edge information is retained. The edge pixel values vary greatly and will not be completely blurred.
[0063] S2: Use the Sobel operator to obtain image gradient information, determine the edge pixel type based on the gradient amplitude and direction, and detect the aliasing effect area.
[0064] Preferably, the present invention uses the Sobel operator to perform a convolution operation on the input original image to obtain the gradient information of the image in the horizontal and vertical directions. and , as shown in Table 1:
[0065] Table 1 Gradient information table
[0066]
[0067] Among them, sobelX is a 3x3 convolution kernel matrix, which is used to calculate the horizontal gradient component gradientX of the image, corresponding to the detection of horizontal edges; sobelY is another 3x3 convolution kernel matrix, which is used to calculate the vertical gradient component gradientY of the image, corresponding to the detection of vertical edges.
[0068] Calculate pixel gradient magnitude The formula is:
[0069] ;
[0070] The formula for calculating the gradient direction information is:
[0071] ;
[0072] according to The value of the edge pixel is determined by , and then according to The value of determines whether the pixel is a straight edge or a bevel edge , the specific judgment formula is as follows:
[0073] ;
[0074] ;
[0075] in, The gradient amplitude can be set to 50. The error range is set to 0.001. Edge determines whether it is an edge pixel. If it is determined to be an edge pixel, the gradient direction of the edge pixel is then determined to determine whether it is a bevel pixel area, that is, an area with a more obvious sawtooth effect.
[0076] Furthermore, in order to better characterize the overall distribution characteristics of the image edge, the directional gradient histogram of the image is constructed to count the distribution of the gradient values in each direction. The specific steps are as follows:
[0077] Perform Sobel convolution on the input original image to obtain the horizontal and vertical gradient components G x and G y, According to G x and G y, Calculate the gradient magnitude G and gradient direction θ for each pixel:
[0078] ;
[0079] ;
[0080] Map the gradient direction θ to the range of (0~π], and divide (0~π] into n small intervals, denoted as bin1, bin2, ..., bin n ; For each pixel point, calculate which interval it belongs to based on its θ value; create an array hist of size m to store the count value of each bin, with the initial value set to 0. For each pixel point, increase the count value of the corresponding bin by 1 according to the interval; repeat the operation for all pixels until the statistics of the entire histogram are completed.
[0081] The histogram hist is normalized to obtain the normalized histogram Hhist. According to the distribution characteristics of Hhist, it is determined whether the overall direction of the edge pixels is mainly horizontal, vertical or diagonal. If Hhist(0) and Hhist(m / 2) are large, the edge direction is mainly horizontal and vertical. If Hhist(m / 4) and Hhist(3m / 4) are large, the edge direction is mainly diagonal. Combined with the previous gradient amplitude judgment, the pixels in the jagged area are further analyzed.
[0082] By counting and analyzing the edge direction distribution of the image, the overall direction characteristics of the image edge can be better characterized.
[0083] S3: For the detected non-straight edge pixels, interpolation calculation is performed based on the pixel values around them to smooth the edges and reduce the jagged effect.
[0084] Preferably, the detected oblique edge pixels are interpolated using the following formula to smooth the edge and reduce jagged edges:
[0085] The interpolation formula used in the present invention is shown in the following formula:
[0086]
[0087] in, Represents the result after interpolation; A, B, and C are all matrices, expressed as follows:
[0088] ;
[0089] ;
[0090] ;
[0091] Among them, the A and C matrices are edge smoothing parameters, and the calculation formula of S in the matrix is as follows:
[0092] ;
[0093] Among them, im(i,j) represents the position index of the pixel in the image, where i represents the row index and j represents the column index; x represents the gradient direction of the current pixel; pi represents the circumference of the circle π; eps is a very small constant value, usually 1e -8 , used to avoid the situation where the denominator is 0.
[0094] and The gradient direction of the pixel To determine, that is, get the gradient direction value of the pixel point and normalize it as the A and C matrix parameters. The closer the edge gradient direction is to 45 degrees, the greater the edge smoothing strength, and vice versa.
[0095] Furthermore, during interpolation, the coefficients of the three matrices A, B, and C can be adaptively adjusted according to the local neighborhood features of the current pixel to implement an adaptive interpolation strategy. Specifically:
[0096] According to the gradient amplitude distribution characteristics, determine whether the area belongs to a flat area, an edge area or a texture area:
[0097] If all gradient amplitudes in the neighborhood are small and less than the threshold T1, it is a flat area; if there is an obvious edge transition and some gradient amplitudes are greater than the threshold T2, it is an edge area; if the gradient amplitude difference is large, with both large and small values, it is a texture area.
[0098] For flat areas, increase the weight of the smoothing coefficient in the A and C matrices to enhance the smoothing effect; for edge areas, reduce the weight of the smoothing coefficient in the A and C matrices to weaken the smoothing; for texture areas, introduce local gradient adaptive weights in the A and C matrices; finally, use the adjusted A, B, and C matrices to substitute into the interpolation formula for interpolation calculation.
[0099] Through the above strategy, the coefficient of the interpolation kernel can be adaptively adjusted according to the characteristics of the local neighborhood of the current pixel point, stronger smoothing can be applied to flat areas, smoothing can be weakened to retain details in edge areas, and adaptive interpolation can be performed on texture areas according to the gradient distribution characteristics. This can achieve a better balance between smoothing jagged edges and retaining details, and obtain better visual effects.
[0100] It should be noted that the original values of pixels in non-edge areas are kept unchanged to ensure that the detail areas are clear.
[0101] S4: GPU parallel computing is introduced to divide the image into segments of different resolutions and importance, and process them on different GPU computing threads to improve real-time performance.
[0102] Specifically, in order to improve the accuracy of image recognition, the central processing unit (CPU) will convert the acquired low-precision original image into a higher-precision data type, and then transmit the high-precision image data to the GPU, so that the GPU can process the high-precision image data based on the trained neural network model.
[0103] Furthermore, the central processing unit CPU performs edge detection based on the Sobel operator to obtain edge gradient information to segment the edge image, including resolution segmentation and segmentation of the importance of the image in the scene, and rates the segments, which are input into the GPU respectively, and uses multi-threading or SIMD instructions to optimize the CPU-side edge detection process.
[0104] The details are as follows: First, a double threshold algorithm is used on edge pixels to obtain a binary edge image.
[0105] The edge image is divided into multiple resolution levels, such as original, 1 / 2, 1 / 4 resolution, etc. For each resolution level, the corresponding edge information is extracted.
[0106] Perform scene analysis on the original image, detect the main objects in the image, divide the image into blocks according to the importance of the main objects, such as the main object area, background area, etc., and separate the edge information of areas of different importance.
[0107] The gradient distribution and other characteristics of the edge image blocks at each resolution level are evaluated to obtain a complexity score. For each edge image block in an important area, a weight score is given according to the importance of the object to which it belongs. The edge image blocks with high scores are marked as complex or important areas. For example, a complexity threshold TH is set. C and importance threshold TH I , such as TH C =0.7; TH I = 0.8; for each edge image block, if ComplexityScore ≥ TH C or ImportanceScore ≥ TH I , The image is marked as a complex or important area and assigned to the high-performance computing unit of the GPU for further processing.
[0108] Preferably, the complexity scoring process is:
[0109] Assuming the edge image block size is MxN and the number of edge pixels is E, the edge pixel ratio is:
[0110] ;
[0111] Let the gradient values of all edge pixels be {g1, g2, ..., g E}, then the edge gradient mean is:
[0112] ;
[0113] The standard deviation of edge gradient is:
[0114] ;
[0115] For each edge pixel, count the number of neighboring pixels K whose jump is greater than the threshold T in its 8-neighborhood, and get the aliasing coefficient:
[0116] ;
[0117] Among them, T is usually between 10-20; the final complexity score is calculated as follows:
[0118] ;
[0119] in, are the corresponding weight coefficients respectively.
[0120] In addition, the scoring strategy can be flexibly adjusted according to actual needs.
[0121] Different edge image segments are sent to different computing threads of the GPU. Based on the scores, complex or important edge image blocks are assigned to the high-performance computing units of the GPU, and simple or minor edge image blocks are assigned to the low-performance computing units of the GPU. Each computing thread performs subsequent edge processing operations on the GPU in parallel, such as aliasing removal and thinning.
[0122] Use multi-threaded parallel computing to divide the image into blocks, with each thread processing one block, and use a thread pool to avoid the overhead of creating / destroying threads; use SIMD instructions to accelerate, use SIMD instruction vectorization for Sobel convolution, gradient calculation, non-maximum suppression, etc., reasonably select data layout, and maximize SIMD efficiency; use computing threads and task decomposition to decompose edge detection tasks into multiple stages, with the front and back stages forming computing threads, and different threads responsible for different stages to improve CPU utilization.
[0123] S5: Perform Gaussian filtering on the interpolated edge area, smooth the straight edge and bevel edge transition area, merge the processed edge pixels with the original non-edge pixels, and output an anti-aliased image.
[0124] Preferably, the interpolated edge pixel mask is obtained from step S4, the edge area pixels are marked, and a two-dimensional Gaussian kernel G is constructed, whose size can be set to 5x5 or 7x7, and the standard deviation σ takes an appropriate value, such as 1.0; the original image is grayed or the brightness component is taken to obtain a grayscale image I; the 2D Gaussian kernel G is convolved with the grayscale image I to obtain a smoothed grayscale image I'.
[0125] According to the edge mask, only the edge area pixels are updated to the smoothed I' value, and the non-edge area remains unchanged; if necessary, before updating the edge area pixel value, the I' edge area threshold can be adjusted to enhance or weaken the smoothing effect.
[0126] The smoothed edge area pixels are merged with the original non-edge area pixels to generate the output image O; if it is a grayscale image, the updated I' is directly used as the output O; if it is a color image, the processed RGB three channels are merged to obtain the output color image O.
[0127] Optionally, the detail area in the output O is sharpened and enhanced to make it clearer, and the anti-aliased image O is output.
[0128] It should be noted that by performing Gaussian smoothing filtering on the edge area, the discontinuous jumps caused by aliasing can be effectively eliminated, making the transition between straight edges and bevel edges smoother and more natural. At the same time, by fusion with the original non-edge area, the high-frequency details of the image can be retained without being overly blurred. The final output image has no aliasing interference, smooth edge areas, and clear detail areas.
[0129] The present embodiment also provides an anti-aliasing system based on edge detection, including: a blur processing module, used to perform blur processing on the input original infrared image, smooth noise and retain edge information; a Sobel operator module, used to use the Sobel operator to obtain image gradient information, and judge the edge pixel type according to the gradient amplitude and direction, and detect the aliasing effect area; an interpolation calculation module, used to perform interpolation calculation on the detected non-straight edge pixels according to the pixel values around them; a GPU parallel computing module, used to introduce GPU parallel computing, divide the image into segments with different resolutions and importance, and process them on different GPU computing threads respectively; a Gaussian filtering module, used to perform Gaussian filtering on the interpolated edge area, and smooth the straight edge and oblique edge transition area; a fusion module, used to fuse the processed edge pixels with the original non-edge pixels, and output an anti-aliasing image.
[0130] This embodiment also provides a computer device, which is suitable for the case of an anti-aliasing method based on edge detection, including: a memory and a processor; the memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions to implement the anti-aliasing method based on edge detection proposed in the above embodiment.
[0131] The computer device may be a terminal, and the computer device includes a processor, a memory, a communication interface, a display screen and an input device connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner can be achieved through WIFI, an operator network, NFC (near field communication) or other technologies. The display screen of the computer device may be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device may be a touch layer covered on the display screen, or a key, trackball or touchpad provided on the housing of the computer device, or an external keyboard, touchpad or mouse, etc.
[0132] This embodiment also provides a storage medium on which a computer program is stored. When the program is executed by a processor, the anti-aliasing method based on edge detection proposed in the above embodiment is implemented; the storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (Static Random Access Memory, referred to as SRAM), electrically erasable programmable read-only memory (Electrically Erasable Programmable Read-Only Memory, referred to as EEPROM), erasable programmable read-only memory (Erasable Programmable Read Only Memory, referred to as EPROM), programmable read-only memory (Programmable Red-Only Memory, referred to as PROM), read-only memory (Read-Only Memory, referred to as ROM), magnetic storage, flash memory, magnetic disk or optical disk.
[0133] In summary, the present invention can accurately detect the edges in the image by calculating the horizontal and vertical gradients of the image, and identify different types of edge pixels according to the gradient information; the non-straight edge pixels are smoothed by using interpolation calculation, which can significantly improve the smoothness of the image edge, making the image look more natural and smooth; at the same time, segmented processing is performed according to the image resolution and importance, which can reasonably allocate computing resources and improve the accuracy and real-time performance of the processing; the present invention realizes the smoothing of image noise, accurate detection of edges, identification and processing of aliasing effects, and efficient parallel computing processing, and achieves the purpose of outputting high-quality anti-aliasing images.
[0134] Example 2
[0135] The second embodiment of the present invention provides experimental simulation of an anti-aliasing method based on edge detection / comparison data with the prior art in order to further verify the beneficial effects of the present invention.
[0136] In order to verify the effectiveness of the present invention, a group of original images collected by infrared sensors were specially selected as test objects. These original infrared images have certain noise, and due to the limited resolution of the sensor itself, there is obvious jagged phenomenon in the edge area, which affects the visual quality of the image.
[0137] First, the original infrared image was blurred to smooth the noise and retain the edge information as much as possible. The specific method was to calculate the mean and standard deviation of the pixel values in the 3x3 neighborhood around each pixel, and redistribute the pixel value according to the difference between the pixel value and the mean. If the difference is small (less than 0.5 times the standard deviation), it remains unchanged; if it is greater than or equal to 0.5 times the standard deviation, the pixel value is set to the mean plus a random number between 0 and 1 multiplied by the standard deviation; if it is less than or equal to -0.5 times the standard deviation, the pixel value is set to the mean minus a random number between 0 and 1 multiplied by the standard deviation; this process was iterated 10 times to achieve the desired smoothing effect of the image, while also retaining the characteristic of edge pixels not being blurred to the maximum extent.
[0138] Next, the Sobel operator is used to obtain the gradient information of the blurred image, including the gradient amplitude and direction. The edge pixel is determined based on the gradient amplitude. When the gradient amplitude is greater than 50, it is determined to be an edge. For edge pixels, the image directional gradient histogram is used to determine whether the edge is a bevel edge based on the gradient direction value, that is, there is a more obvious sawtooth effect. The range from 0 to π is divided into 32 bins, the number of pixels in each bin is counted, and the histogram is normalized. If the histogram has obvious peaks at π / 8 and 7π / 8, it means that the edge is mainly oblique and the sawtooth effect is more obvious.
[0139] For the detected oblique edge pixels, an interpolation formula is used to smooth them to reduce the jagged effect. The three matrices A, B, and C in the interpolation formula are adaptively calculated according to the current pixel gradient direction, so that the smoothing strength increases as the gradient direction approaches 45 degrees. At the same time, the coefficients of these three matrices are adjusted according to the characteristics of the current pixel neighborhood. For flat areas, smoothing is enhanced, and for texture areas, smoothing is adaptively performed according to the gradient distribution. This process can achieve a good balance between jagged removal and detail retention. Pixels in non-edge areas remain unchanged.
[0140] In order to further improve the processing speed, the image is divided into different resolutions and importance levels and sent to different computing threads of the GPU for parallel processing.
[0141] First, the CPU divides the edge image into three levels according to resolution: full resolution, 1 / 2 resolution, and 1 / 4 resolution; at the same time, according to the importance of the area where the main object is located, the image is divided into three important blocks: high, medium, and low. For each block, the complexity score is obtained by calculating the edge pixel ratio, gradient mean, gradient standard deviation, and sawtooth coefficient; then combined with the importance weight, the final score is obtained. The complexity threshold is set to 0.7 and the importance threshold is set to 0.8. Blocks with scores higher than these two thresholds are marked as complex or important areas and are preferentially assigned to GPU high-performance units for processing, while the remaining blocks are assigned to low-performance units. At the same time, the CPU uses OpenMP multi-threading and AVX2 SIMD instructions to accelerate the edge detection process.
[0142] Finally, the interpolated edge area is smoothed using a 5x5 Gaussian filter kernel, and then fused with the original non-edge area pixel values to generate an output anti-aliased image. The detail areas in the output result are slightly sharpened to make the details clearer. The data of some experimental processes are shown in the following table:
[0143] Table 2 Part of experimental data
[0144]
[0145] As can be seen from the above table, in terms of processing time, even for test004.png with a relatively high resolution, the processing time is only 163ms, which can meet most real-time processing needs. This is due to the GPU acceleration strategy proposed in the invention content, which divides the image into different levels for parallel processing. At the same time, the CPU side also uses multi-threading and SIMD technology to greatly shorten the processing time. It can be seen from the peak signal-to-noise ratio (PSNR) data that after being processed by this method, the PSNR of most images is about 25dB, which is significantly improved compared to the original image, indicating that the image quality has been improved. The no-reference visual score and the aliasing score also prove the effectiveness of this method.
[0146] The no-reference visual score measures the overall image quality. All test images are above 77 points, indicating a significant visual improvement. The aliasing score specifically evaluates the edge jaggedness. Most images scored above 70 points, indicating that the edge jaggedness has been effectively suppressed.
[0147] It can be seen that the anti-aliasing method based on edge detection proposed in the present invention can effectively smooth the image edge jaggedness while retaining detail information. While ensuring real-time performance, it greatly enhances the visual quality of the image and demonstrates extremely high application value.
[0148] It should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solutions of the present invention may be modified or replaced by equivalents without departing from the spirit and scope of the technical solutions of the present invention, which should all be included in the scope of the claims of the present invention.
Claims
1. An anti-aliasing method based on edge detection, characterized in that: Including: Blur the input original infrared image, smooth the noise and retain the edge information; Use the Sobel operator to obtain the gradient information of the processed image, judge the edge pixel type according to the gradient amplitude and direction, and detect the sawtooth effect area; For the detected non-straight edge pixels, perform interpolation calculation according to the pixel values around them; Introduce GPU parallel computing, divide the image processed by the Sobel operator into segments with different resolutions and importance, and process them on different GPU computing threads respectively; The introducing of GPU parallel computing and dividing the image processed by the Sobel operator into segments with different resolutions and importance includes the following steps: Use the double-threshold algorithm for edge pixels to obtain a binary edge image; divide the edge image into multiple resolution levels, for each resolution level, extract the corresponding edge information; perform scene analysis on the original image, detect the main objects in the image, and divide the image into blocks according to the importance of the main objects; evaluate the features of the edge image blocks at each resolution level to obtain a complexity score; for the edge image blocks in each importance region, give a weight score according to the importance degree of the object to which they belong, and mark the edge image blocks with high scores as complex or important regions; send different edge image segments to different computing threads of the GPU; each computing thread performs edge processing operations in parallel on the GPU; The calculation process of the complexity score is as follows: Assume that the size of the edge image block is MxN and the number of edge pixels is E, then the proportion of edge pixels is: ; Let the gradient values of all edge pixels be {g1, g2, ..., g E }, then the edge gradient mean is: ; The standard deviation of the edge gradient is: ; For each edge pixel, count the number K of neighboring pixels with a jump greater than the threshold T in its 8-neighborhood to obtain the sawtooth coefficient: ; The calculation of the complexity score is as follows: ; in, are the corresponding weight coefficients respectively; Perform Gaussian filtering on the interpolated edge region, smooth the transition regions of straight edges and bevel edges, fuse the processed edge pixels with non-edge pixels, and output the anti-sawtooth image; The blurring process of the input original infrared image includes the following steps: Calculate the mean value avg and standard deviation std of the pixel values within a certain neighborhood around each pixel of the image; For each pixel value, calculate the difference from the mean value avg of the neighborhood pixel values, denoted as diff; According to the value of diff, reassign the pixel value: If -k*std < diff < k*std, keep the pixel unchanged; If diff ≥ k*std, then the pixel value = avg + rand()*std; If diff ≤ -k*std, the pixel value = avg - rand()*std; Where k is a constant; rand() is a uniform random number between 0 and 1; Iterate multiple times until the image reaches the desired blurring and smoothing degree.
2. The anti-aliasing method based on edge detection as claimed in claim 1, characterized in that: The using of the Sobel operator to obtain the image gradient information includes: Use the Sobel operator to perform a convolution operation on the input original image to obtain the gradient information in the horizontal and vertical directions of the image: Calculate pixel gradient magnitude The formula is: ; The formula for calculating the gradient direction information is: ; in, is the horizontal gradient component and is the vertical gradient component.
3. The anti-aliasing method based on edge detection as claimed in claim 2, characterized in that: The judging of the edge pixel type according to the gradient amplitude and direction includes: according to The value of the edge pixel is determined by The calculation formula is: ; according to The value of determines whether the pixel is a straight edge or a bevel edge The calculation formula is: ; in, is the gradient magnitude, is the error range; Judge whether it is an edge pixel by Edge. After judging it as an edge pixel, then judge whether the gradient direction of the edge pixel is a bevel pixel region; Construct the directional gradient histogram of the image and count the distribution of the gradient values in each direction.
4. The anti-aliasing method based on edge detection as claimed in claim 3, characterized in that: The interpolation calculation includes: The interpolation formula is as follows: ; in, Represents the result after interpolation; A, B, and C are matrices, expressed as follows: ; ; ; Among them, the A and C matrices are edge smoothing parameters, and the calculation formula of S in the matrix is as follows: ; Among them, im(i,j) represents the position index of the pixel in the image, where i represents the row index and j represents the column index; x represents the gradient direction of the current pixel; pi represents the circumference π; eps is a constant; v represents the vertical gradient component of the current pixel; u represents the horizontal gradient component of the current pixel. and The gradient direction of the pixel Decide.
5. The anti-aliasing method based on edge detection as claimed in claim 4, characterized in that: The interpolation calculation also includes: The coefficients of the three matrices A, B, and C are adaptively adjusted according to the local neighborhood characteristics of the current pixel to implement an adaptive interpolation strategy.
6. An anti-aliasing system based on edge detection, based on the anti-aliasing method based on edge detection according to any one of claims 1 to 5, characterized in that: include: A fuzzy processing module is used to perform fuzzy processing on the input original infrared image, smooth the noise and retain the edge information; The Sobel operator module is used to obtain image gradient information using the Sobel operator, determine the edge pixel type based on the gradient amplitude and direction, and detect the aliasing effect area; An interpolation calculation module is used to perform interpolation calculation on detected non-straight edge pixels according to the pixel values around them; GPU parallel computing module, used to introduce GPU parallel computing, divide the image into segments of different resolutions and importance, and process them on different GPU computing threads; The method of introducing GPU parallel computing to divide the image processed by the Sobel operator into segments of different resolutions and importances includes the following steps: A binary edge image is obtained by using a double threshold algorithm for edge pixels; the edge image is divided into multiple resolution levels, and the corresponding edge information is extracted for each resolution level; scene analysis is performed on the original image, the main objects in the image are detected, and the image is divided into blocks according to the importance of the main objects; the characteristics of the edge image blocks at each resolution level are evaluated to obtain a complexity score; a weight score is given to the edge image blocks in each important area according to the importance of the object to which it belongs, and the edge image blocks with high scores are marked as complex or important areas; different edge image segments are sent to different computing threads of the GPU; each computing thread performs edge processing operations on the GPU in parallel; The calculation process of the complexity score is as follows: Assuming the edge image block size is MxN and the number of edge pixels is E, the edge pixel ratio is: ; Let the gradient values of all edge pixels be {g1, g2, ..., g E }, then the edge gradient mean is: ; The standard deviation of edge gradient is: ; For each edge pixel, count the number of neighboring pixels K whose jump is greater than the threshold T in its 8-neighborhood, and get the aliasing coefficient: ; The complexity score is calculated as follows: ; in, are the corresponding weight coefficients respectively; Gaussian filter module, used to perform Gaussian filtering on the edge area after interpolation to smooth the straight edge and oblique edge transition area; The fusion module is used to fuse the processed edge pixels with the original non-edge pixels to output an anti-aliased image.
Citation Information
Patent Citations
Power transmission device image edge detection method, device and system
CN109360217A
Image anti-aliasing processing method,and training method and device of image generator
CN110852974A
Apparatus and method for image interpolation using anisotropic gaussian filter
US20110176744A1
Method and system for generating an output image of increased pixel resolution from an input image
US20120328210A1
Non-local means image denoising with an adaptive directional spatial filter
US20160284065A1
