Image anti-aliasing method and device, equipment and medium
By performing low-pass filtering and fusion processing on the image, the problem of image quality degradation caused by jagged edge noise was solved, and the clarity and quality of the projected image were improved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- SPREADTRUM COMMUNICATION (SHANGHAI) CO LTD
- Filing Date
- 2025-12-31
- Publication Date
- 2026-04-17
AI Technical Summary
During image processing, jagged edges and noise degrade image quality, which is especially noticeable when magnified in projection scenarios, affecting the projection effect.
By performing low-pass filtering on the image to be processed, the fusion weight data of the edge region is determined, and the filtered image is fused with the image to be processed to remove high-frequency components, retain low-frequency components, reduce edge jaggedness, and improve image clarity.
While ensuring image clarity, it reduces edge jaggedness, improves projected image quality, and enhances projection effects.
Smart Images

Figure CN121883265A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image processing technology, and in particular to an image anti-aliasing method, apparatus, device, and medium. Background Technology
[0002] In image processing (e.g., distortion correction), jagged edge noise is introduced, leading to a decrease in image quality. This is especially true in projection scenarios, where images with jagged edge noise are projected, resulting in a magnified image where the jagged edges are more pronounced, severely impacting the quality of the projected image and thus affecting the projection effect. Summary of the Invention
[0003] Therefore, it is necessary to provide an image anti-aliasing method, apparatus, device, and medium to address the aforementioned technical problems.
[0004] In a first aspect, this application provides an image anti-aliasing method, comprising:
[0005] Obtain the image to be processed;
[0006] The image to be processed is low-pass filtered to obtain the filtered image;
[0007] The fusion weight data is determined based on the pixel data of the edge region of the image to be processed;
[0008] Based on the fusion weight data, the filtered image and the image to be processed are fused to obtain an anti-aliased image.
[0009] In one embodiment, determining fusion weight data based on pixel data of the edge region of the image to be processed includes: determining the line direction type corresponding to the edge lines in the edge region based on the pixel data of the edge region; and determining fusion weight data based on the line direction type.
[0010] In one embodiment, determining the line direction type corresponding to the edge lines in the edge region based on the pixel data of the edge region includes: determining the cumulative gradient data corresponding to each pixel point in the preset window in at least two preset directions based on the pixel data of each preset window in the edge region; and determining the line direction type corresponding to the edge lines in the preset window based on the cumulative gradient data.
[0011] In one embodiment, determining the fusion weight data based on the line direction type includes: determining the pixel gradient data of at least two pixels within the preset window in the perpendicular direction corresponding to the line direction type, based on the line direction type and the pixel data of the preset window; and determining the fusion weight data of the center pixel within the preset window based on the pixel gradient data.
[0012] In one embodiment, determining pixel gradient data of at least two pixels within a preset window in the vertical direction corresponding to the line direction type, based on the line direction type and the pixel data of the preset window, includes: in response to the line direction type being a horizontal line direction type, determining pixel gradient data corresponding to every two adjacent rows of pixels within the preset window based on the pixel data of the preset window; in response to the line direction type being a vertical line direction type, determining pixel gradient data corresponding to every two adjacent columns of pixels within the preset window based on the pixel data of the preset window; in response to the line direction type being a positively inclined line direction type, determining pixel gradient data corresponding to every two adjacent pixels within the preset window in the negatively inclined direction based on the pixel data of the preset window; and in response to the line direction type being a negatively inclined line direction type, determining pixel gradient data of every two adjacent pixels within the preset window in the positively inclined direction based on the pixel data of the preset window.
[0013] In one embodiment, fusing the filtered image and the image to be processed according to the fusion weight data includes: determining reference weight data based on the fusion weight data of each pixel in the edge region; for each pixel in the edge region, fusing the pixel value of the pixel in the image to be processed with the pixel value of the corresponding pixel in the filtered image according to the reference weight data and the fusion weight data of the pixel to obtain the target pixel value; wherein, the pixel value of each pixel in the edge region of the anti-aliased image is the target pixel value of the corresponding pixel.
[0014] In one embodiment, fusing the pixel value of a pixel in the image to be processed with the pixel value of the corresponding pixel in the filtered image based on reference weight data and pixel fusion weight data to obtain a target pixel value includes: determining a first pixel value based on the pixel fusion weight data and the pixel value of the pixel in the image to be processed; determining a second pixel value based on the reference weight data, the pixel fusion weight data, and the pixel value of the corresponding pixel in the filtered image; and determining the target pixel value based on the first pixel value, the second pixel value, and the reference weight data.
[0015] Secondly, this application also provides an image anti-aliasing device, comprising:
[0016] The image acquisition module is used to acquire the image to be processed.
[0017] The filtering module is used to perform low-pass filtering on the image to be processed, so as to obtain a filtered image.
[0018] The weight determination module is used to determine the fusion weight data based on the pixel data of the edge region of the image to be processed;
[0019] The fusion processing module is used to fuse the filtered image and the image to be processed according to the fusion weight data to obtain an anti-aliased image.
[0020] Thirdly, this application also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the method provided in the first aspect.
[0021] Fourthly, this application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the method provided in the first aspect.
[0022] Fifthly, this application also provides a computer program product, including a computer program that, when executed by a processor, implements the method provided in the first aspect.
[0023] The aforementioned image anti-aliasing methods, apparatuses, devices, media, and products perform low-pass filtering on the image to be processed to obtain a filtered image, thereby removing high-frequency components and retaining low-frequency components, thus achieving anti-aliasing. Next, based on the pixel data of the edge regions of the image to be processed, fusion weight data is determined, and the filtered image and the image to be processed are fused according to the fusion weight data. This not only compensates for the detail loss caused by filtering in the filtered image, maintaining the sharpness of the anti-aliased image, but also reduces edge jaggedness in the image to be processed, thus achieving anti-aliasing while ensuring image sharpness and improving image quality. In a projection scene, the anti-aliased image is projected and magnified to obtain a projected image. Compared to the projected image obtained without anti-aliasing processing, the jaggedness problem is significantly improved, enhancing the quality of the projected image. Attached Figure Description
[0024] To more clearly illustrate the technical solutions in the embodiments of this application or related technologies, the drawings used in the description of the embodiments of this application or related technologies will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0025] Figure 1 This is a flowchart illustrating an image anti-aliasing method in one embodiment;
[0026] Figure 2 This is a flowchart illustrating the steps for determining the fused weighted data in one embodiment;
[0027] Figure 3A This is a flowchart illustrating the steps for determining the line direction type in one embodiment;
[0028] Figure 3B This is a schematic diagram of the horizontal edge lines within a preset window in one embodiment;
[0029] Figure 3C This is a schematic diagram of the vertical edge lines within a preset window in one embodiment;
[0030] Figure 3D This is a schematic diagram of the edge lines in the positive tilt direction within a preset window in one embodiment;
[0031] Figure 3E This is a schematic diagram of the edge lines in the negative tilt direction within a preset window in one embodiment;
[0032] Figure 4A This is a flowchart illustrating the steps for determining the fused weighted data in one embodiment;
[0033] Figure 4B This is a schematic diagram illustrating the numbering of each pixel within a preset window in one embodiment;
[0034] Figure 5 This is a flowchart illustrating the fusion processing steps in one embodiment;
[0035] Figure 6A This is a flowchart illustrating the steps for obtaining the target pixel value in one embodiment;
[0036] Figure 6B This is a schematic diagram of the projection effect corresponding to the image to be projected in one embodiment;
[0037] Figure 6C This is a schematic diagram of the projection effect corresponding to the image to be projected in one embodiment;
[0038] Figure 7 This is a structural block diagram of an image anti-aliasing device in one embodiment;
[0039] Figure 8 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation
[0040] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0041] It should be noted that the terms "first," "second," etc., used in this application can be used to describe various elements, but these elements are not limited by these terms. These terms are only used to distinguish the first element from the second element. The terms "comprising" and "having," and any variations thereof, used in this application, are intended to cover non-exclusive inclusion. The term "multiple" used in this application refers to two or more. The term "and / or" used in this application refers to one of the embodiments, or any combination of multiple embodiments.
[0042] In one exemplary embodiment, an image anti-aliasing method is provided, such as... Figure 1 As shown, the method includes:
[0043] S110, Obtain the image to be processed.
[0044] The image to be processed is the image that needs to be anti-aliased.
[0045] S120 performs low-pass filtering on the image to be processed to obtain a filtered image.
[0046] Understandably, some jagged edges are high-frequency noise. By using low-pass filtering, the high-frequency components in the image to be processed can be removed while the low-frequency components are retained, thus achieving anti-aliasing.
[0047] One approach is to use a preset low-pass filter to perform low-pass filtering on the image to be processed.
[0048] The filtering method of the preset low-pass filter can be set. For example, a one-dimensional horizontal Gaussian filter kernel is first used to perform convolution calculation on the image to be processed to obtain a horizontally filtered image. Then, a one-dimensional vertical Gaussian filter kernel is used to perform convolution calculation on the horizontally filtered image to obtain the final filtered image.
[0049] S130, determine the fusion weight data based on the pixel data of the edge region of the image to be processed.
[0050] Among them, the pixel data of the edge region is the pixel value of each pixel point in the edge region.
[0051] The range of the edge region can be set as needed, or the edge region can be determined by edge detection technology, or other methods can be used to determine the edge region, which are not limited here.
[0052] The fusion weight data can be understood as the weight data used when performing pixel fusion. Since there are multiple pixels in the edge region, and different pixels correspond to different weights, the fusion weight data is a weight matrix formed by multiple weights.
[0053] Understandably, the fusion weight data is determined based on the pixel values of each pixel in the edge region, which ensures the rationality of the fusion weight data.
[0054] S140, based on the fusion weight data, the filtered image and the image to be processed are fused to obtain an anti-aliased image.
[0055] The fusion process can be understood as a weighted sum of the pixel values of the pixels in the filtered image and the corresponding pixel values in the image to be processed, thereby achieving fusion.
[0056] The aforementioned image anti-aliasing method performs low-pass filtering on the image to be processed, obtaining a filtered image. This removes high-frequency components from the image to be processed while retaining low-frequency components, thus achieving anti-aliasing. Next, based on the pixel data of the edge regions of the image to be processed, fusion weight data is determined. Then, the filtered image and the image to be processed are fused according to the fusion weight data. This not only compensates for the detail loss caused by filtering in the filtered image, maintaining the sharpness of the anti-aliased image, but also reduces edge jaggedness in the image to be processed. Therefore, it achieves anti-aliasing while ensuring image sharpness, improving image quality. In a projection scene, the anti-aliased image is projected and magnified to obtain a projected image. Compared to the projected image obtained without anti-aliasing processing, the jaggedness problem is significantly improved, enhancing the quality of the projected image.
[0057] Based on the technical solutions provided in the above embodiments, an optional embodiment is provided, in which the step of determining the fusion weight data in S130 is refined.
[0058] See Figure 2 The detailed steps for determining the fusion weight data include:
[0059] S210, determine the line direction type corresponding to the edge lines in the edge region based on the pixel data of the edge region.
[0060] Among them, edge lines can be understood as lines formed by multiple pixels in the edge region whose pixel values are less than a preset pixel value.
[0061] The line direction type can include horizontal, vertical, positive slant, and negative slant line direction types, and other direction types are not limited here.
[0062] In determining the line direction type, the coordinate system used is as follows: the top left corner of the image is the origin, the horizontal direction to the right is the positive x-axis, and the vertical direction downwards is the positive y-axis. Of course, other coordinate systems can also be used, and this is not limited here.
[0063] S220, determine the fusion weight data based on the line direction type.
[0064] Different line direction types require different methods for determining the fusion weight data.
[0065] In this embodiment, the line direction type corresponding to the edge lines in the edge region is determined based on the pixel data of the edge region. Then, the fusion weight data is determined based on the line direction type, thereby ensuring that the determined fusion weight data is compatible with the line direction type, thereby improving the rationality of subsequent fusion processing and improving the quality of the final anti-aliased image.
[0066] Based on the technical solutions provided in the above embodiments, an optional embodiment is provided, in which the line direction type determination step in S210 is refined.
[0067] See Figure 3A The steps for determining the line direction type include:
[0068] S310, based on the pixel data of each preset window in the edge region, determine the cumulative gradient data corresponding to each pixel in the preset window in at least two preset directions.
[0069] Among them, at least two preset directions can be horizontal, vertical, positive tilt, or negative tilt.
[0070] In a real-world scenario, a preset window is configured. The preset window is slid one pixel at a time in the edge region and then stopped. Based on the pixel values of each pixel in the preset window, the cumulative gradient data corresponding to each pixel in the preset window in at least two preset directions is determined.
[0071] For example, taking a preset window size of 3×3 as an example, the first cumulative gradient data in the horizontal direction is calculated using the following formula:
[0072]
[0073] In the formula, G h For the first cumulative gradient data, n takes the value of 3, V (x,y) V represents the pixel value of the pixel at coordinates (x, y) within a preset window. (x,y+1) The pixel value of the pixel at coordinates (x, y+1) within the preset window.
[0074] For example, taking a preset window size of 3×3 as an example, the second cumulative gradient data in the vertical direction is calculated using the following formula:
[0075]
[0076] In the formula, G v For the second cumulative gradient data, V (x+1,y) The pixel value of the pixel with coordinates (x+1, y) within the preset window.
[0077] For example, taking a preset window size of 3×3 as an example, the third cumulative gradient data corresponding to the positive tilt direction is calculated using the following formula:
[0078]
[0079] In the formula, G ur For the third cumulative gradient data, V (x+1,y+1) The pixel value of the pixel with coordinates (x+1, y+1) within the preset window.
[0080] For example, taking a preset window size of 3×3 as an example, the fourth cumulative gradient data corresponding to the negative tilt direction is calculated using the following formula:
[0081]
[0082] In the formula, G dr For the fourth cumulative gradient data, V (x-1,y+1) The pixel value of the pixel with coordinates (x-1, y+1) within the preset window.
[0083] S320, based on the cumulative gradient data, determines the line direction type corresponding to the edge lines in the preset window.
[0084] Because the number of pixels involved in the accumulation process varies when calculating cumulative gradient data—for example, 6 pixels are used to calculate the first and second cumulative gradient data, while 4 pixels are used to calculate the third and fourth cumulative gradient data—the cumulative gradient data are normalized to ensure the accuracy of line direction type determination. For instance, the first and second cumulative gradient data are divided by 6 to obtain normalized first and second cumulative gradient data, respectively; the third and fourth cumulative gradient data are divided by 4 to obtain normalized third and fourth cumulative gradient data, respectively. Then, the maximum value is selected from the four cumulative gradient data, and the preset direction corresponding to the maximum value is used as the line direction type for the edge lines in the preset window. For example, the first cumulative gradient data is the largest among the normalized cumulative gradient data, therefore its line direction type is horizontal.
[0085] For example, Figure 3B This is a schematic diagram of the horizontal edge lines within a preset window; Figure 3CThis is a schematic diagram of the vertical edge lines within a preset window; Figure 3D This is a schematic diagram of the edge lines in the positive tilt direction within a preset window; Figure 3E This is a schematic diagram of the edge lines in the negative tilt direction within a preset window.
[0086] In this embodiment, based on the cumulative gradient data of each pixel in at least two preset directions within a preset window, gradient accumulation in multiple directions is achieved, capturing the main direction features of the edge, thereby accurately determining the line direction type corresponding to the edge line and improving the accuracy of subsequent fusion weight data.
[0087] Based on the technical solutions provided in the above embodiments, an optional embodiment is provided, in which the step of determining the fusion weight data in S220 is refined.
[0088] See Figure 4A The steps for determining the fusion weight data include:
[0089] S410, based on the line direction type and the pixel data of the preset window, determine the pixel gradient data of at least two pixels in the preset window in the perpendicular direction corresponding to the line direction type.
[0090] Wherein, if the line direction type is horizontal, the corresponding perpendicular line direction is vertical; if the line direction type is vertical, the corresponding perpendicular line direction is horizontal; if the line direction type is positively inclined, the corresponding perpendicular line direction is negatively inclined; if the line direction type is negatively inclined, the corresponding perpendicular line direction is positively inclined.
[0091] In one optional implementation, the pixel gradient data determination step in S410 may include any of the following:
[0092] (1) In response to the line direction type being horizontal line direction type, determine the pixel gradient data corresponding to each two adjacent rows of pixels in the preset window based on the pixel data of the preset window.
[0093] For example, the preset window size is 3×3. When the line direction type is horizontal, the pixel gradient data a1 between the 0th row and the 1st row, and the pixel gradient data a2 between the 1st row and the 2nd row are calculated.
[0094] The expression for a1 can be:
[0095]
[0096] The expression for a2 can be:
[0097]
[0098] (2) In response to the line direction type being vertical line direction type, determine the pixel gradient data corresponding to each two adjacent columns of pixels in the preset window based on the pixel data of the preset window.
[0099] For example, the preset window size is 3×3. When the line direction type is vertical line direction type, the pixel gradient data b1 between column 0 and column 1, and the pixel gradient data b2 between column 1 and column 2 are calculated.
[0100] The expression for b1 can be:
[0101]
[0102] The expression for b2 can be:
[0103]
[0104] (3) In response to the line direction type being a positive tilt line direction type, the pixel gradient data corresponding to each two adjacent pixels in the negative tilt direction within the preset window is determined based on the pixel data of the preset window.
[0105] For example, see Figure 4B The preset window size is 3×3. When the line direction type is positive slant line direction type, calculate the pixel gradient data c1 between pixel 1 and pixel 3, calculate the pixel gradient data c2 between pixel 6 and pixel 4, calculate the pixel gradient data c3 between pixel 2 and pixel 4, and calculate the pixel gradient data c4 between pixel 5 and pixel 7.
[0106] (4) In response to the line direction type being a negative tilt line direction type, determine the pixel gradient data of every two adjacent pixels in the positive tilt direction within the preset window based on the pixel data of the preset window.
[0107] For example, the preset window size is 3×3. When the line direction type is positive slant line direction type, the pixel gradient data d1 between pixel 1 and pixel 5 is calculated, the pixel gradient data d2 between pixel 3 and pixel 7 is calculated, the pixel gradient data d3 between pixel 0 and pixel 4 is calculated, and the pixel gradient data d4 between pixel 4 and pixel 8 is calculated.
[0108] In the above implementation, a method for calculating pixel gradient data in the corresponding vertical direction is provided for different line direction types to ensure the accuracy of pixel gradient data calculation.
[0109] S420 determines the fusion weight data of the center pixel within the preset window based on the gradient data of each pixel.
[0110] For example, when the line direction type is horizontal, the expression for the first fusion weight data corresponding to the center pixel within the preset window is:
[0111]
[0112] In the formula, The first fusion weight data is α and β, which are adjustment parameters.
[0113] For example, when the line direction type is a vertical line direction type, the expression for the second fusion weight data corresponding to the center pixel within the preset window is:
[0114]
[0115] In the formula, This is the second fusion weight data.
[0116] For example, when the line direction type is a positive tilt direction type, the expression for the third fusion weight data corresponding to the center pixel within the preset window is:
[0117]
[0118] In the formula, This is the third fusion weighted data.
[0119] For example, when the line direction type is a negative tilt direction type, the expression for the fourth fusion weight data corresponding to the center pixel within the preset window is:
[0120]
[0121] In the formula, This is the fourth fusion weight data.
[0122] In this embodiment, for each preset window, pixel gradient data in the corresponding vertical direction is determined based on the direction type of the edge lines within the preset window. This yields the differences between adjacent pixels in the corresponding vertical direction, capturing edge texture and structural features within the preset window. Then, a comprehensive weight is determined based on the pixel gradient data, serving as the fusion weight data for the center pixel of the preset window during subsequent fusion. It is evident that this embodiment utilizes the edge texture and structural features reflected by gradient information to dynamically adjust the contribution of the center pixel, thereby preserving key information and suppressing noise or redundant data during the subsequent fusion process.
[0123] Based on the technical solutions provided in the above embodiments, an optional embodiment is provided, in which the fusion processing steps in S140 are refined.
[0124] See Figure 5 The detailed fusion processing steps include:
[0125] S510 determines reference weight data based on the fusion weight data of each pixel in the edge region.
[0126] For example, the maximum value can be selected from the fusion weight data of each pixel in the edge region as the reference weight data. Of course, other methods can also be used to determine the reference weight data, which are not limited here.
[0127] S520: For each pixel in the edge region, based on the reference weight data and the pixel fusion weight data, the pixel value of the pixel in the image to be processed is fused with the pixel value of the corresponding pixel in the filtered image to obtain the target pixel value.
[0128] In this context, the pixel value of each pixel in the edge region of the anti-aliased image is the target pixel value of that pixel.
[0129] Of course, the pixel values of pixels in the non-edge regions of the anti-aliased image can be the pixel values of the corresponding pixels in the filtered image or the pixel values of the corresponding pixels in the image to be processed.
[0130] In one alternative implementation, see Figure 6A The steps to obtain the target pixel value in S520 include:
[0131] S610, determine the first pixel value based on the pixel fusion weight data and the pixel value of the pixel in the image to be processed.
[0132] Specifically, for each pixel in the edge region, the fusion weight data of that pixel can be multiplied by the pixel value of that pixel in the image to be processed to obtain the first pixel value corresponding to that pixel.
[0133] S620: Determine the second pixel value based on the reference weight data, the pixel fusion weight data, and the pixel value of the corresponding pixel in the filtered image.
[0134] Specifically, for each pixel in the edge region, the reference weight data and the fused weight data of that pixel can be subtracted, and the difference is multiplied by the pixel value of the corresponding pixel in the filtered image to obtain the second pixel value.
[0135] S630 determines the target pixel value based on the first pixel value, the second pixel value, and the reference weight data.
[0136] Specifically, for each pixel in the edge region, the corresponding first pixel value and the corresponding second pixel value can be added together to obtain the sum of pixel values. The ratio between the sum of pixel values and the reference weight data is used as the target pixel value corresponding to that pixel.
[0137] For example, the target pixel value for each pixel in the edge region is calculated as follows:
[0138]
[0139] In the formula, Image dst For the target pixel value, For reference weight data, Image is the fusion weight data for pixels. lpf Image represents the pixel value of the corresponding pixel in the filtered image. org This represents the pixel value of the pixel in the image to be processed.
[0140] In the above implementation, the first pixel value reflects the portion of the pixel value in the target pixel value in the image to be processed, and the second pixel value reflects the portion of the pixel value in the target pixel value in the filtered image. Then, the two parts are summed and normalized by reference weight data to obtain an accurate target pixel value, so as to avoid the problem of poor reliability of the target pixel value due to the introduction of reference weight data.
[0141] In this embodiment, reference weight data is determined based on the fusion weight data of each pixel in the edge region, thereby obtaining dynamically determined reference weight data that conforms to the current image to be processed. Based on the reference weight data and the pixel fusion weight data, the pixel value of the pixel in the image to be processed is fused with the pixel value of the corresponding pixel in the filtered image. It is evident that this embodiment considers not only the fusion weight data but also the reference weight data when performing pixel value fusion, thus obtaining accurate target pixel values.
[0142] In one embodiment, in a projection scenario, the image projection process may include: acquiring a first-shaped image to be projected; performing a shape transformation on the image to be projected to obtain a second-shaped image to be processed; applying the image anti-aliasing method provided in the above embodiment to perform anti-aliasing processing on the image to be processed to obtain an anti-aliased image; and performing projection processing on the anti-aliased image to obtain a projection image of the first shape.
[0143] The first shape can be a rectangle, or any other shape, which is not limited here.
[0144] This can be achieved by employing the principle of perspective transformation to transform the shape of the image to be projected, resulting in a one-to-one correspondence between the pixels of the image to be processed and the image to be projected. The correspondence transformation relationship is as follows:
[0145]
[0146] In the formula, (x i y j (u) represents the pixel coordinates in the image to be processed; i v j ) represents the coordinates of the corresponding pixel in the image to be projected; T is the perspective transformation matrix.
[0147] The second shape is determined by the projection system. For example, if a rectangular image is projected directly through the projection system and results in an inverted trapezoid, then the second shape is set to a regular trapezoid; however, if a rectangular image is projected directly through the projection system and results in a regular trapezoid, then the second shape is an inverted trapezoid. A regular trapezoid can be understood as a trapezoid whose upper base is shorter than its lower base, and an inverted trapezoid can be understood as a trapezoid whose upper base is longer than its lower base. Of course, the second shape is not limited to trapezoids; it can also be other regular or irregular shapes.
[0148] Understandably, shape transformation may compress edges, introducing jagged noise. This jagged noise becomes more pronounced after subsequent projection and magnification, severely impacting the quality of the projected image. Therefore, anti-aliasing processing is necessary. The anti-aliasing methods described in the above embodiments are referenced. The anti-aliasing process does not change the image shape. For example, a trapezoidal image undergoes anti-aliasing processing to obtain a trapezoidal anti-aliased image.
[0149] For example, during the projection process, a rectangular projected image can be obtained by projecting and magnifying an anti-aliased image of a trapezoid.
[0150] In practical scenarios, in a projection system consisting of a projection screen and projection units, the projection optical axis of the projection units needs to be perpendicular to the plane of the projection screen. In this case, if the image to be projected is rectangular, the magnified projection image will also be rectangular. See also... Figure 6B If the projection optical axis of the projection unit is not perpendicular to the plane of the projection screen, the projected image will appear as an inverted trapezoid or a completely irregular quadrilateral.
[0151] Currently, when the problem arises because the projection unit's optical axis is not perpendicular to the plane of the projection screen, the placement of the projection unit needs to be manually adjusted to make its optical axis as perpendicular to the screen as possible. However, this process is not only time-consuming and labor-intensive, but also lacks precision. See also Figure 6CIn this embodiment, a first-shape (e.g., rectangle) image to be projected is transformed into a second-shape image through shape transformation. This ensures that after the projection system projects the second-shape image, it can obtain a projected image of the first shape (e.g., rectangle). However, due to the introduction of shape transformation, some edge parts are compressed, leading to aliasing. Therefore, anti-aliasing processing is performed. By projecting the improved anti-aliased image, a higher-quality projected image can be obtained, thereby improving the projection effect.
[0152] In this embodiment, the first-shaped image to be projected is transformed to obtain a second-shaped image to be processed, which ensures that a projected image of the first shape can be obtained after projection. To address the aliasing problem introduced by the shape transformation, anti-aliasing processing is performed on the image to be processed to obtain an anti-aliased image. After projecting the anti-aliased image, the desired first-shaped projected image can be obtained, and the aliasing problem in the projected image is improved, thereby enhancing the projection effect.
[0153] In one embodiment, in a projection scenario, the image projection process may include: applying the image anti-aliasing method provided in the above embodiment to the image to be processed to obtain an anti-aliased image, wherein both the anti-aliased image and the image to be processed in this step are of a first shape; performing shape transformation on the anti-aliased image to obtain a projection image of a second shape; and performing projection processing on the projection image of the second shape to obtain a projection image of the first shape.
[0154] In this embodiment, since anti-aliasing processing has been performed on the image to be processed before shape transformation, the jaggedness after shape transformation can be reduced to a certain extent. Then, the image to be projected after shape transformation is projected to obtain a projection image with improved quality.
[0155] It should be understood that although the steps in the flowcharts of the above embodiments are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the above embodiments may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages in other steps. It is understood that the steps in different embodiments can be freely combined as needed, and all non-contradictory solutions formed by such combinations are within the scope of protection of this application.
[0156] Based on the same inventive concept, this application also provides an image anti-aliasing device for implementing the image anti-aliasing method described above. This device can be applied to or integrated into a chip or chip module, for example. The solution provided by this device is similar to the implementation described in the above method; therefore, the specific limitations of one or more image anti-aliasing device embodiments provided below can be found in the limitations of the image anti-aliasing method described above, and will not be repeated here.
[0157] In one exemplary embodiment, such as Figure 7 As shown, an image anti-aliasing device is provided, comprising: an image acquisition module 710, a filtering processing module 720, a weight determination module 730, and a fusion processing module 740, wherein:
[0158] Image acquisition module 710 is used to acquire the image to be processed;
[0159] The filtering module 720 is used to perform low-pass filtering on the image to be processed to obtain a filtered image.
[0160] The weight determination module 730 is used to determine the fusion weight data based on the pixel data of the edge region of the image to be processed;
[0161] The fusion processing module 740 is used to fuse the filtered image and the image to be processed according to the fusion weight data to obtain an anti-aliased image.
[0162] In one embodiment, the weight determination module includes: a first determination unit, configured to determine the line direction type corresponding to the edge lines in the edge region based on the pixel data of the edge region; and a second determination unit, configured to determine the fusion weight data based on the line direction type.
[0163] In one embodiment, the first determining unit includes: a first determining subunit, configured to determine the cumulative gradient data corresponding to each pixel in the preset window in at least two preset directions based on the pixel data of each preset window in the edge region; and a second determining subunit, configured to determine the line direction type corresponding to the edge line in the preset window based on the cumulative gradient data.
[0164] In one embodiment, the second determining unit includes: a third determining subunit, configured to determine pixel gradient data of at least two pixels within the preset window in the perpendicular direction corresponding to the line direction type, based on the line direction type and the pixel data of the preset window; and a fourth determining subunit, configured to determine the fusion weight data of the center pixel within the preset window based on the pixel gradient data.
[0165] In one embodiment, the third determining subunit is specifically configured to: in response to a horizontal line direction type, determine pixel gradient data corresponding to every two adjacent rows of pixels within a preset window based on pixel data of a preset window; in response to a vertical line direction type, determine pixel gradient data corresponding to every two adjacent columns of pixels within a preset window based on pixel data of a preset window; in response to a positively tilted line direction type, determine pixel gradient data corresponding to every two adjacent pixels within a preset window in a negatively tilted direction based on pixel data of a preset window; and in response to a negatively tilted line direction type, determine pixel gradient data for every two adjacent pixels within a preset window in a positively tilted direction based on pixel data of a preset window.
[0166] In one embodiment, the fusion processing module includes: a fifth determining subunit, configured to determine reference weight data based on the fusion weight data of each pixel in the edge region; and a first fusion subunit, configured to, for each pixel in the edge region, fuse the pixel value of the pixel in the image to be processed with the pixel value of the corresponding pixel in the filtered image based on the reference weight data and the fusion weight data of the pixel, to obtain a target pixel value; wherein, the pixel value of each pixel in the edge region of the anti-aliased image is the target pixel value of the corresponding pixel.
[0167] In one embodiment, the first fusion subunit is specifically used to: determine a first pixel value based on the fusion weight data of the pixel and the pixel value of the pixel in the image to be processed; determine a second pixel value based on reference weight data, the fusion weight data of the pixel and the pixel value of the corresponding pixel in the filtered image; and determine a target pixel value based on the first pixel value, the second pixel value and the reference weight data.
[0168] Each module in the aforementioned image anti-aliasing device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device as software, so that the processor can call and execute the operations corresponding to each module.
[0169] Regarding the modules / units included in the various devices and products described in the above embodiments, they can be software modules / units, hardware modules / units, or a combination of both. For example, for various devices and products applied to or integrated into a chip, all of their modules / units can be implemented using hardware methods such as circuits, or at least some modules / units can be implemented using software programs that run on a processor integrated within the chip, while the remaining (if any) modules / units can be implemented using hardware methods such as circuits; for various devices and products applied to or integrated into a chip module, all of their modules / units can be implemented using hardware methods such as circuits, and different modules / units can be located in the same component (e.g., chip, circuit module, etc.) or different components of the chip module, or at least some modules / units can be implemented using hardware methods such as circuits. The components can be implemented using software programs that run on the processor integrated within the chip module. The remaining (if any) modules / units can be implemented using hardware methods such as circuits. For various devices and products applied to or integrated into the terminal, each of its components / units can be implemented using hardware methods such as circuits. Different modules / units can be located in the same component (e.g., chip, circuit module, etc.) or in different components within the terminal. Alternatively, at least some modules / units can be implemented using software programs that run on the processor integrated within the terminal, while the remaining (if any) modules / units can be implemented using hardware methods such as circuits.
[0170] In one exemplary embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as follows: Figure 8 As shown, the computer device includes a processor, memory, input / output interfaces, a communication interface, a display unit, and an input device. The processor, memory, and input / output interfaces are connected via a system bus, and the communication interface, display unit, and input device are also connected to the system bus via the input / output interfaces. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The input / output interfaces are used for exchanging information between the processor and external devices. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, mobile cellular networks, Near Field Communication (NFC), or other technologies. When the computer program is executed by the processor, it implements an image anti-aliasing method.
[0171] Those skilled in the art will understand that Figure 8 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0172] In one exemplary embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to perform the following steps:
[0173] Obtain the image to be processed;
[0174] The image to be processed is low-pass filtered to obtain the filtered image;
[0175] The fusion weight data is determined based on the pixel data of the edge region of the image to be processed;
[0176] Based on the fusion weight data, the filtered image and the image to be processed are fused to obtain an anti-aliased image.
[0177] In one embodiment, the step of "determining fusion weight data based on pixel data of the edge region of the image to be processed" implemented by the processor when executing the computer program includes: determining the line direction type corresponding to the edge lines in the edge region based on the pixel data of the edge region; and determining the fusion weight data based on the line direction type.
[0178] In one embodiment, the step of "determining the line direction type corresponding to the edge line in the edge region based on the pixel data of the edge region" implemented by the processor when executing the computer program includes: determining the cumulative gradient data corresponding to each pixel point in the preset window in at least two preset directions based on the pixel data of each preset window in the edge region; and determining the line direction type corresponding to the edge line in the preset window based on the cumulative gradient data.
[0179] In one embodiment, the step of "determining fusion weight data according to line direction type" implemented by the processor when executing the computer program includes: determining pixel gradient data of at least two pixels in the preset window in the perpendicular direction corresponding to the line direction type according to the line direction type and the pixel data of the preset window; and determining fusion weight data of the center pixel in the preset window according to the pixel gradient data.
[0180] In one embodiment, the step of "determining pixel gradient data of at least two pixels in the preset window in the vertical direction corresponding to the line direction type, based on the line direction type and the pixel data of the preset window" implemented by the processor when executing the computer program includes: in response to the line direction type being a horizontal line direction type, determining pixel gradient data corresponding to every two adjacent rows of pixels in the preset window based on the pixel data of the preset window; in response to the line direction type being a vertical line direction type, determining pixel gradient data corresponding to every two adjacent columns of pixels in the preset window based on the pixel data of the preset window; in response to the line direction type being a positively inclined line direction type, determining pixel gradient data corresponding to every two adjacent pixels in the preset window in the negatively inclined direction based on the pixel data of the preset window; and in response to the line direction type being a negatively inclined line direction type, determining pixel gradient data of every two adjacent pixels in the preset window in the positively inclined direction based on the pixel data of the preset window.
[0181] In one embodiment, the step of "fusing the filtered image and the image to be processed according to the fusion weight data" implemented by the processor when executing the computer program includes: determining reference weight data according to the fusion weight data of each pixel in the edge region; for each pixel in the edge region, fusing the pixel value of the pixel in the image to be processed with the pixel value of the corresponding pixel in the filtered image according to the reference weight data and the fusion weight data of the pixel to obtain a target pixel value; wherein, the pixel value of each pixel in the edge region of the anti-aliased image is the target pixel value of the corresponding pixel.
[0182] In one embodiment, the step of "fusing the pixel value of a pixel in the image to be processed with the pixel value of the corresponding pixel in the filtered image based on reference weight data and pixel fusion weight data to obtain a target pixel value" implemented by the processor executing the computer program includes: determining a first pixel value based on the pixel fusion weight data and the pixel value of the pixel in the image to be processed; determining a second pixel value based on the reference weight data, the pixel fusion weight data, and the pixel value of the corresponding pixel in the filtered image; and determining the target pixel value based on the first pixel value, the second pixel value, and the reference weight data.
[0183] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon that, when executed by a processor, implements the steps in the above method embodiments.
[0184] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps in the above method embodiments.
[0185] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments of the above methods. Any references to memory, database, or other media used in the embodiments provided in this application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, artificial intelligence (AI) processors, etc., and are not limited to these.
[0186] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.
[0187] The above embodiments are merely illustrative of several implementation methods of this application, and their descriptions are relatively specific and detailed. However, they should not be construed as limiting the scope of this application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.
Claims
1. An image anti-aliasing method, characterized by, include: Obtain the image to be processed; The image to be processed is subjected to low-pass filtering to obtain a filtered image; Based on the pixel data of the edge region of the image to be processed, determine the fusion weight data; Based on the fusion weight data, the filtered image and the image to be processed are fused to obtain an anti-aliased image.
2. The method according to claim 1, characterized in that, The step of determining the fusion weight data based on the pixel data of the edge region of the image to be processed includes: Based on the pixel data of the edge region, determine the line direction type corresponding to the edge lines in the edge region; The fusion weight data is determined based on the line direction type.
3. The method according to claim 2, characterized in that, The step of determining the line direction type corresponding to the edge lines in the edge region based on the pixel data of the edge region includes: Based on the pixel data of each preset window in the edge region, determine the cumulative gradient data corresponding to each pixel in the preset window in at least two preset directions; Based on the cumulative gradient data, determine the line direction type corresponding to the edge lines in the preset window.
4. The method according to claim 3, characterized in that, The step of determining the fusion weight data based on the line direction type includes: Based on the line direction type and the pixel data of the preset window, determine the pixel gradient data of at least two pixels in the preset window in the perpendicular direction corresponding to the line direction type. Based on the pixel gradient data, determine the fusion weight data of the center pixel within the preset window.
5. The method according to claim 4, characterized in that, The step of determining the pixel gradient data of at least two pixels within the preset window in the perpendicular direction corresponding to the line direction type, based on the line direction type and the pixel data of the preset window, includes: In response to the line direction type being horizontal, the pixel gradient data corresponding to each pair of adjacent rows of pixels within the preset window is determined based on the pixel data of the preset window. In response to the line direction type being a vertical line direction type, the pixel gradient data corresponding to each pair of adjacent columns of pixels within the preset window is determined based on the pixel data of the preset window. In response to the line direction type being a positive tilt line direction type, the pixel gradient data corresponding to every two adjacent pixels in the negative tilt direction within the preset window is determined based on the pixel data of the preset window. In response to the line direction type being a negative tilt line direction type, the pixel gradient data of every two adjacent pixels in the positive tilt direction within the preset window is determined based on the pixel data of the preset window.
6. The method according to any one of claims 1 to 5, characterized in that, The step of fusing the filtered image and the image to be processed according to the fusion weight data includes: Based on the fusion weight data of each pixel in the edge region, the reference weight data is determined; For each pixel in the edge region, the pixel value of the pixel in the image to be processed is fused with the pixel value of the corresponding pixel in the filtered image according to the reference weight data and the fusion weight data of the pixel to obtain the target pixel value. Wherein, the pixel value of each pixel in the edge region of the anti-aliased image is the target pixel value of the corresponding pixel.
7. The method according to claim 6, characterized in that, The step of fusing the pixel value of the pixel in the image to be processed with the pixel value of the corresponding pixel in the filtered image based on the reference weight data and the pixel fusion weight data to obtain the target pixel value includes: The first pixel value is determined based on the fusion weight data of the pixel and the pixel value of the pixel in the image to be processed; The second pixel value is determined based on the reference weight data, the fusion weight data of the pixel, and the pixel value of the corresponding pixel in the filtered image. The target pixel value is determined based on the first pixel value, the second pixel value, and the reference weight data.
8. An image anti-aliasing device, characterized in that, include: The image acquisition module is used to acquire the image to be processed. The filtering module is used to perform low-pass filtering on the image to be processed to obtain a filtered image; The weight determination module is used to determine fusion weight data based on the pixel data of the edge region of the image to be processed; The fusion processing module is used to fuse the filtered image and the image to be processed according to the fusion weight data to obtain an anti-aliased image.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 7.