A method, system, terminal and storage medium for removing large sawteeth from an image
By employing steps such as edge enhancement, scaling, jagged edge detection, and Gaussian blurring, large jagged edges in images are removed with minimal hardware resources, achieving a low-overhead and efficient jagged edge filling effect.
Patent Information
- Application Number
- CN202510133404.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-06
- Publication Date
- 2025-10-24
- Estimated Expiration
- 2045-02-06
AI Technical Summary
Existing technologies cannot effectively remove large aliasing in images, and increasing the pixel block size will cause the hardware overhead to increase exponentially.
Large jagged edges in images are removed using fewer hardware resources through steps such as edge enhancement, binarization, scaling, jagged edge detection, address mapping, interpolation calculation, and Gaussian blur. The process includes image preprocessing, scaling, jagged edge detection, address mapping, interpolation calculation, and Gaussian blur modules.
While preserving image details, it completes large-scale jagged edge filling with low hardware overhead, solving the problem of wasted hardware resources in existing technologies.
Smart Images

Figure CN120031740B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of digital image processing, more particularly to a method, system, terminal and storage medium for removing large sawteeth from an image. BACKGROUND
[0002] In the field of digital image processing, removing sawteeth from an image is a common requirement. Traditional sawteeth removal methods mainly target small sawteeth in a picture, such as processing a picture in a 5*5 pixel block range. Existing processing methods cannot detect and correct large sawteeth. If the size of the pixel block is increased, the hardware overhead will be multiplied, and a method for removing large sawteeth using fewer hardware resources is needed. SUMMARY
[0003] The present application aims to solve the above-mentioned defects of the prior art, and provides a method for removing large sawteeth from an image, a system for removing large sawteeth from an image, a terminal for removing large sawteeth from an image, and a computer-readable storage medium.
[0004] The technical solution adopted by the present application to solve its technical problems is as follows:
[0005] A method for removing large sawteeth from an image is constructed, comprising the following steps:
[0006] After the edges of the original image are enhanced, the luminance data of the original image is converted to a binary image with clear edges;
[0007] The binary image is scaled down by a set scaling ratio, and the sawteeth of the scaled-down image are required to fall completely within the set pixel range;
[0008] The scaled-down image is compared with a preset model to detect a specific pixel model and mark its position and direction, and obtain sawteeth-related information that needs to be filled in;
[0009] According to the sawteeth-related information that needs to be filled in, the starting point of the sawteeth is marked at the starting point of the original image according to the scaling ratio, and the image in the pixel range of the original image is marked with the distance from the starting point of the sawteeth as the weight according to the direction of the sawteeth in a rectangular expansion manner;
[0010] The marked rectangular region is subjected to interpolation calculation, the pixels near the center of the sawteeth are weighted and averaged to obtain the pixel data that needs to be filled in, and the rectangular region is filled in according to the marked weight. After interpolation processing, the large sawteeth of the image have been converted into small sawteeth caused by interpolation;
[0011] The data of the interpolation part is smoothed by Gaussian blur to fade the edges of the small sawteeth.
[0012] The method for removing large sawteeth of an image, wherein, after the edge enhancement of the original image, the brightness data of the original image is converted by binaryzation, comprises:
[0013] Edge information of large sawteeth of the original image is obtained by using an edge detection algorithm, and the obtained edge information is subjected to edge enhancement processing.
[0014] The brightness data of the original image is converted by binaryzation according to a set binaryzation conversion threshold.
[0015] The method for removing large sawteeth of an image, wherein, the set pixel range adopts a 5*5 pixel range.
[0016] The calculation formula of the scaling ratio r is:
[0017] r=A / 5.
[0018] Wherein, the range of the sawtooth size of the original image to be processed is A*A.
[0019] The method for removing large sawteeth of an image, wherein, the calculation formula of the sawtooth center coordinate point (M, N) and the direction D of the original image is:
[0020] (M, N, D)=(5*m, 5*n, D1).
[0021] Wherein, (m, n) is the coordinate center of the current sawtooth in the scaled image, and D1 is the sawtooth direction information in the scaled image.
[0022] The method for removing large sawteeth of an image, wherein, the calculation formula of the weight W (X,Y) is:
[0023]
[0024] Wherein, (m, n) is the coordinate center of the current sawtooth in the scaled image, and D1 is the sawtooth direction information in the scaled image, and the range of the sawtooth size of the original image to be processed is A*A.
[0025] The method for removing large sawteeth of an image, wherein, the interpolation calculation of the marked rectangular region, the weighted average of the pixels near the sawtooth center to the pixel data to be filled, and the filling according to the marked weight in the rectangular region comprise:
[0026] The filling value selects the mean value calculation of the nearest pixel value opposite to the D direction at the sawtooth center point.
[0027] t is the selected pixel number, and the calculation method of the brightness G to be filled is:
[0028]
[0029] The filled pixel brightness value G (X,Y) The calculation method is:
[0030] G (X,Y) = W (X,Y) *G.
[0031] A system for removing large image jaggies, wherein the system comprises an image preprocessing module, a scaling module, a jaggie detection module, an address mapping module, an interpolation calculation module and a Gaussian blur module;
[0032] The image preprocessing module is used for performing binary conversion on the brightness data of the original image after edge enhancement of the original image, to obtain a binary image with clear edges;
[0033] The scaling module is used for proportionally reducing the binary image according to a set scaling ratio, so that the jaggies of the reduced image can completely fall within a set pixel range;
[0034] The jaggie detection module is used for comparing the reduced image with a preset model, detecting a specific pixel model and marking the position and direction, and obtaining jaggie-related information to be filled;
[0035] The address mapping module is used for marking the starting point of the jaggies according to the jaggie-related information to be filled, marking the starting point position of the original image according to the scaling ratio, and marking the image in the pixel range of the original image according to the distance from the starting point of the jaggies as the weight in a rectangular expansion manner according to the direction of the jaggies;
[0036] The interpolation calculation module is used for performing interpolation calculation on the marked rectangular area, weighting and averaging the pixels near the center of the jaggies as the pixel data to be filled, and filling according to the marked weight in the rectangular area; after the interpolation processing, the large jaggies of the image have been converted into small jaggies caused by interpolation;
[0037] The Gaussian blur module is used for performing smoothing filtering on the data of the interpolation part by using Gaussian blur, to fade the edges of the small jaggies.
[0038] The system for removing large image jaggies provided by the application, wherein the binary conversion of the brightness data of the original image after edge enhancement of the original image comprises:
[0039] The edge information of the large-size jaggies of the original image is acquired by using an edge detection algorithm, and the acquired edge information is subjected to edge enhancement processing;
[0040] The luminance data of the original image is binarized according to a set binarization conversion threshold.
[0041] The system for removing large sawteeth of an image provided by the present application, wherein the calculation formula of the sawteeth center coordinate point (M, N) and the direction D of the original image is:
[0042] (M, N, D) = (5*m, 5*n, D1);
[0043] Wherein (m, n) is the coordinate center of the current sawteeth in the scaled image, and D1 is the sawteeth direction information in the scaled image.
[0044] The weight W (X,Y) The calculation formula is:
[0045]
[0046] Wherein (m, n) is the coordinate center of the current sawteeth in the scaled image, and D1 is the sawteeth direction information in the scaled image, and the range of the sawteeth size of the original image to be processed is A*A.
[0047] The marked rectangular region is subjected to interpolation calculation, and the pixels near the sawteeth center are weighted and averaged as the pixel data to be filled, and the filling is performed according to the marked weight in the rectangular region, including:
[0048] The filling value selects the mean value of the nearest pixel value opposite to the D direction at the sawteeth center point.
[0049] t is the number of selected pixels, and the calculation method of the luminance G to be filled is:
[0050]
[0051] The calculation method of the luminance value G of the filled pixel is: (X,Y)
[0052] G (X,Y) = W (X,Y) *G.
[0053] A terminal for removing large sawteeth of an image, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above method when executing the computer program.
[0054] A computer readable storage medium, the computer readable storage medium stores a computer program, wherein the computer program is executed by a processor to implement the steps of the above method.
[0055] The beneficial effects of the present application are that: after the edge of the original image is enhanced, the brightness data of the original image is converted into a binary image with clear edges; the binary image is proportionally reduced according to a set scaling ratio, and the jaggy of the reduced image can completely fall within the set pixel range; the reduced image is compared with a preset model to detect a specific pixel model and mark the position and direction, and obtain the jaggy related information that needs to be filled; according to the jaggy related information that needs to be filled, the jaggy starting point is marked on the starting position of the original image according to the scaling ratio, and the image in the pixel range of the original image is marked with the distance from the jaggy starting point as the weight in the direction of the jaggy in the form of rectangular expansion; the marked rectangular area is calculated by interpolation, the pixels near the center of the jaggy are weighted and averaged as the pixel data that needs to be filled, and the filling is performed according to the marked weight in the rectangular area; after the interpolation processing, the large jaggy of the image is converted into small jaggy caused by interpolation; the data of the interpolation part is smoothed by Gaussian blur to fade the edges of the small jaggy; the image obtained after the above steps can not only retain the details of the image, but also complete the filling of the large jaggy, and the hardware overhead is very low, which can well solve the current industry problem. BRIEF DESCRIPTION OF DRAWINGS
[0056] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the present application will be further described below with reference to the drawings and embodiments. The drawings in the following description are only some embodiments of the present application, and those skilled in the art can also obtain other drawings according to these drawings without creative labor:
[0057] Figure 1 is a flow chart of the method for removing large image jaggy of the preferred embodiment of the present application;
[0058] Figure 2 is a pre-processing effect diagram of the method for removing large image jaggy of the preferred embodiment of the present application;
[0059] Figure 3 is a scaling diagram of the method for removing large image jaggy of the preferred embodiment of the present application;
[0060] Figure 4 is a jaggy detection diagram of the method for removing large image jaggy of the preferred embodiment of the present application;
[0061] Figure 5 is an interpolation effect diagram of the method for removing large image jaggy of the preferred embodiment of the present application;
[0062] Figure 6 is a Gaussian blur effect diagram of the method for removing large image jaggy of the preferred embodiment of the present application;
[0063] Figure 7 The method for removing large sawteeth of an image is a preferred embodiment of the present application.
[0064] Figure 8 The system block diagram for removing large sawteeth of an image is a preferred embodiment of the present application. DETAILED DESCRIPTION
[0065] In order to make the purposes, technical solutions and advantages of the embodiments of the present application clearer, the following will make a clear and complete description of the technical solutions in the embodiments of the present application. Obviously, the described embodiments are some but not all of the embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the protection scope of the present application.
[0066] The method for removing large sawteeth of an image is a preferred embodiment of the present application, as shown in Figure 1 , and referring to Figures 2-7 , the method comprises the following steps.
[0067] S01: After edge enhancement of an original image, the luminance data of the original image is binarized to obtain a binarized image with clear edges.
[0068] The preprocessing effect is shown in Figure 2 . By using this method, the hardware calculation complexity can be reduced. The edge detection algorithm can use a Sobel operator or other methods for convolution operation to obtain the edge information of large-size sawteeth. The binarization conversion threshold can be set reasonably according to the actual image, and is not limited in this regard.
[0069] S02: The binarized image is reduced by an equal proportion according to a set scaling ratio, and the sawteeth of the reduced image are required to fall completely within a set pixel range.
[0070] The comparison before and after scaling is shown in Figure 3 . According to the range A*A of the sawteeth size to be processed, the image is reduced by a specific ratio r, so that the sawteeth of the reduced image can fall completely within a 5*5 pixel range.
[0071] r=A / 5
[0072] In this example, the sawteeth size is about 20*20 pixels, so r=20 / 5=4. It can be understood that this scaling ratio can be defined by oneself, and is not limited in this regard.
[0073] S03: The reduced image is compared with a preset model to detect a specific pixel model and mark the position and direction, and obtain the sawteeth-related information to be filled.
[0074] Still taking the 5*5 pixel image as an example, as shown in Figure 4 The input 5*5 pixel image is compared with the preset model during processing, a specific pixel model is detected and position and direction markers are marked, and the sawtooth related information to be filled is obtained. The result is input to the address mapping module, and more specifically:
[0075] First, the input image of 5 rows and 25 pixels is represented by 25-bit length data. The black part of the image is set to 0, and the white part is set to 1. The preset model is also 25-bit data. Therefore, the 5*5 data to be compared in this example is 0X0008FFF. If the preset model contains this data, the sawtooth coordinates (m, n) of the corresponding model (where (m, n) is the coordinate center of the current sawtooth in the scaled image) and the sawtooth direction information D are output to the next module to complete the sawtooth detection. Of course, the above data description is only an example and is not used to limit, other parameter forms can also be used according to the situation;
[0076] S04: According to the sawtooth related information to be filled, the sawtooth starting point is marked according to the scaling ratio of the original image starting point position, and the image in the pixel range of the original image is marked in a rectangular expansion manner according to the direction of the sawtooth.
[0077] Specifically, the address mapping module marks the sawtooth starting point according to the scaling ratio r of the original image starting point position according to the output result (m, n, D) of the sawtooth detection module. In a rectangular expansion manner, the image in the pixel range of the original image A*A is marked with the distance from the sawtooth starting point as the weight.
[0078] The calculation method of the original image sawtooth center coordinate point (M, N) and direction D1 is:
[0079] (M, N, D1) = (5*m, 5*n, D)
[0080] The weight is related to the distance of the pixel (X, Y) to be calculated from the sawtooth center point (M, N), and the maximum pixel range that needs to be calculated by interpolation is equal to the size of the sawtooth to be removed A*A, which is 20*20 in this example. The weight value changes in the range (1~0.5).
[0081] The weight calculation method is:
[0082]
[0083] S05: Interpolation calculation is performed on the marked rectangular region, and the pixels near the sawtooth center are weighted and averaged as the pixel data to be filled, and the marked weight in the rectangular region is filled;
[0084] Specifically, interpolation calculation is performed on the marked rectangular area, and the pixels near the center of the jaggies are weighted averaged as the pixel data to be filled, and filling is performed according to the weights marked in the rectangular area. After interpolation calculation, the original image is obtained to obtain an image with less jaggies.
[0085] The filling value is the average value of the nearest pixel value at the center of the sawtooth in the opposite direction of D. t is the number of selected pixels. The calculation method of the brightness G to be filled is:
[0086]
[0087] The brightness value of the filled pixel is G (X,Y) =W (X,Y) *G;
[0088] like Figure 5 As shown in the figure, after interpolation, the large aliasing of the image has been converted into small aliasing caused by interpolation;
[0089] S06: Use Gaussian blur to smooth the interpolated data and reduce small jagged edges;
[0090] Gaussian blur effect such as Figure 6 shown.
[0091] like Figure 7 As shown in FIG, the image obtained after the above steps can retain the details of the image and fill the large aliasing. At the same time, the hardware overhead is also very low, which can well solve the current problem encountered in the industry.
[0092] A system for removing large aliasing from an image, such as Figure 8 As shown, the system includes an image preprocessing module 100, a scaling module 101, a jaggies detection module 102, an address mapping module 103, an interpolation calculation module 104 and a Gaussian blur module 105;
[0093] The image preprocessing module 100 is used to perform binary conversion on the brightness data of the original image after enhancing the edges of the original image to obtain a binary image with clear edges;
[0094] The scaling module 101 is used to scale down the binary image in accordance with a set scaling ratio, so that the aliasing requirement of the scaled-down image can be completely within the set pixel range;
[0095] The jaggies detection module 102 is used to compare the reduced image with a preset model, detect specific pixel models and mark their positions and directions, and obtain information related to the jaggies that need to be filled;
[0096] The address mapping module 103 is configured to mark the original image starting point position according to the sawtooth starting point and the scaling ratio, and mark the image in the original image pixel range in a rectangular expansion manner according to the direction of the sawtooth, with the distance from the sawtooth starting point as the weight;
[0097] The interpolation calculation module 104 is configured to perform interpolation calculation on the marked rectangular region, and average the pixels near the sawtooth center as the pixel data to be filled, and fill according to the marked weight in the rectangular region; after the interpolation processing, the large sawtooth is converted into small sawtooth caused by interpolation;
[0098] The Gaussian blur module 105 is configured to perform smoothing filtering on the interpolation part data by using Gaussian blur, and fade the small sawtooth edge;
[0099] The system of the present application can retain the details of the image, complete the filling of the large sawtooth, and has very low hardware overhead, and can well solve the current industry problem; the implementation of each module is described above, and will not be described here;
[0100] A terminal for removing large sawtooth of an image, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above method when executing the computer program.
[0101] A computer readable storage medium, the computer readable storage medium stores a computer program, wherein the computer program is executed by a processor to implement the steps of the above method.
[0102] It should be understood that those skilled in the art can make improvements or changes according to the above description, and all these improvements and changes shall belong to the protection scope of the appended claims of the present application.
Claims
1. A method of removing large sawteeth from an image, characterized by, The method comprises the following steps: After edge enhancement of the original image, the luminance data of the original image is converted into a binary image with clear edges; The binary image is reduced by a set scaling ratio, and the reduced image is required to be completely within the set pixel range; The reduced image is compared with a preset model to detect a specific pixel model and mark the position and direction, and obtain the relevant information of the jaggies to be filled; According to the relevant information of the jaggies to be filled, the starting point of the jaggies is marked on the starting point of the original image according to the scaling ratio, and the jaggies are marked in a rectangular expansion manner according to the direction of the jaggies, with the distance from the starting point of the jaggies as the weight; The marked rectangular region is subjected to interpolation calculation, the pixels near the center of the jaggies are weighted and averaged to obtain the pixel data to be filled, and the pixels are filled according to the marked weight in the rectangular region; after the interpolation processing, the large jaggies in the image are converted into small jaggies caused by interpolation; The interpolation part is subjected to Gaussian blur smoothing filtering to fade the edges of the small jaggies; The set pixel range is 5*5 pixels; The calculation formula of the set scaling ratio r is: r= A / 5; wherein the range of the jaggie size of the original image to be processed is A*A; The calculation formula of the center coordinate (M, N) and the direction D of the jaggies of the original image is: (M, N, D) = (5*m, 5*n, D1); wherein (m, n) is the coordinate center of the current jaggie in the scaled image, and D1 is the direction information of the jaggie in the scaled image; The weight W (X,Y) The calculation formula is: ; The interpolation calculation of the marked rectangular region, the weighted average of the pixels near the center of the jaggies, and the filling of the pixel data to be filled according to the marked weight in the rectangular region comprise: The filling value is selected to be the mean value of the nearest pixel value opposite to the D direction at the center point of the jaggie; t is the number of selected pixels, and the calculation method of the luminance G to be filled is: ; Filled pixel luminance value The calculation method is: = * 。 2. The method of removing large image jaggies according to claim 1, wherein, The edge enhancement of the original image and the binary conversion of the luminance data of the original image comprise: The edge information of the large jaggies of the original image is obtained by using an edge detection algorithm, and the obtained edge information is subjected to edge enhancement processing; The luminance data of the original image is subjected to binary conversion according to a set binary conversion threshold.
3. A system for removing large sawteeth from an image, characterized by The system comprises an image preprocessing module, a scaling module, a jaggie detection module, an address mapping module, an interpolation calculation module, and a Gaussian blur module; The image preprocessing module is used to convert the luminance data of the original image into a binary image with clear edges after edge enhancement of the original image; The scaling module is used to reduce the binary image by a set scaling ratio, and the reduced image is required to be completely within the set pixel range; The jaggie detection module is used to compare the reduced image with a preset model to detect a specific pixel model and mark the position and direction, and obtain the relevant information of the jaggies to be filled; The address mapping module is configured to mark the original image starting point position according to the sawtooth starting point and the scaling ratio, and mark the image in the original image pixel range in a rectangular expansion manner according to the direction of the sawtooth and the distance from the sawtooth starting point as a weight; The interpolation calculation module is configured to perform interpolation calculation on the marked rectangular region, weight-average the pixels near the sawtooth center as the pixel data to be filled, and fill according to the marked weight in the rectangular region; and the large sawtooth in the image after interpolation processing is converted into small sawtooth caused by interpolation; The Gaussian blur module is configured to perform smoothing filtering on the interpolation part data by using Gaussian blur to fade the edges of the small sawtooth; The calculation formula of the sawtooth center coordinate point (M, N) and the direction D of the original image is: (M, N, D) = (5*m, 5*n, D1); wherein (m, n) is the coordinate center of the current sawtooth in the scaled image, and D1 is the sawtooth direction information in the scaled image; Weight W (X,Y) The calculation formula is: ; The interpolation calculation on the marked rectangular region, the weight-average of the pixels near the sawtooth center as the pixel data to be filled, and the filling according to the marked weight in the rectangular region include: The filling value selects the mean value of the nearest pixel value opposite to the D direction at the sawtooth center point; t is the number of selected pixels, and the calculation method of the brightness G to be filled is: ; Filled pixel luminance value The calculation method is: = * 。 4. The system for removing large image jaggies according to claim 3, wherein, The binarization conversion of the brightness data of the original image after the edge enhancement includes: An edge detection algorithm is used to obtain the edge information of the large-size sawtooth of the original image, and the obtained edge information is subjected to edge enhancement processing; The brightness data of the original image is subjected to binarization conversion according to a set binarization conversion threshold.
5. A terminal for removing large sawteeth from an image, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, The processor executes the computer program to realize the steps of the method according to any one of claims 1 to 2.
6. A computer-readable storage medium storing a computer program, the computer-readable storage medium comprising instructions that, when executed by a computer, cause the computer to perform the method of any one of claims 1 to 5. The computer program is executed by the processor to realize the steps of the method according to any one of claims 1 to 2.
Citation Information
Patent Citations
Anti-aliasing method and device in image scaling
CN102521803A
Anti-aliasing system and method based on edge detection
CN118397029A