# Patent

## Title
Method for removing ringing artifacts from locations near dominant edges of an image reconstructed after compression

## Abstract

A method to remove ringing artifacts from locations near dominant edges of an image reconstructed after compression. The image is decomposed into blocks small enough so that each would contain only one significant edge. A significant edge is tested as to whether it is a dominant edge of the image. If there is no dominant edge, the block is not processed. In the remaining blocks, the exact pixels that include the dominant edges are output without filtering. The direction of the dominant edges is inferred, and then the remaining pixels are filtered with a directional de-ringing filter. The de-ringing filter has a main direction that is perpendicular with the direction of the edge, and thus also with an inherent direction of the ringing artifacts.

## Background
This application is a continuation-in-part of U.S. patent application Ser. No. 09/584,036, filed May 30, 2000 now U.S. Pat. No. 6,707,952.


BACKGROUND OF THE INVENTION
1. Field of the Invention
The present invention is related to the field of digital image processing, and more specifically to filtering to remove ringing artifacts from decompressed images.
2. Description of the Related Art
Images are stored in arrays of pixels. Each pixel stores a small portion of an image, in the form of image data. The same is true for both static images (such as photographs), and for video sequences.
The large volume of image data slows down its transmission. To alleviate the problem, compression techniques are used to reduce the amount of data. Sometimes high compression is used for fastest transmission.
A problem arises when a high compression technique is used with insufficient bit rate of transmission. When the image is reconstructed, it includes visual noise, which is also called ringing artifacts. These artifacts are introduced in the places of the image where high spatial frequency DCT (Discrete Cosine transform) components are substantially reduced. This occurs also around the dominant edges of the image.
The prior art has addressed this problem by applying a de-ringing filter, to remove the artifacts. This approach does not work satisfactorily. Either the artifacts are not removed fully, or the dominant edges are filtered too much. In that case, the dominant edges become so smoothened that they no longer appear as dominant, which detracts from the overall image quality.
BRIEF SUMMARY OF THE INVENTION
The present invention overcomes these problems and limitations of the prior art.
Generally, the present invention provides a method for removing ringing artifacts from locations near dominant edges of a reconstructed image. The invention exploits the fact that artifacts near dominant edges has a direction that can be inferred from a main direction of the dominant edge. The invention teaches to filter the image data on either side of the pixels containing the edge. Filtering is with a special directional de-ringing filter according to the invention, which means that the de-ringing filter has a main direction perpendicular with the edge direction.
It will be appreciated that the dominant edges of the image are therefore not smoothened, since they themselves are not filtered. In addition, the artifacts are eliminated through a single filtering pass, since the directional de-ringing filter of the invention is fundamentally perpendicular with their main direction.
The invention will become more readily apparent from the following Detailed Description, which proceeds with reference to the drawings, in which:



BRIEF DESCRIPTION OF THE DRAWINGS
FIG. 1 is a flowchart illustrating a method according to the invention.
FIG. 2 is a first portion of a flowchart illustrating another method according to the invention.
FIG. 3 is a second portion of the flowchart of FIG. 2.



DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENT(S)
As has been mentioned, the present invention provides methods. The methods of the invention can be implemented by software.
Although only two methods are described, that is for illustration. Some of their steps overlap, and a method according to the invention can contain steps of both.
Referring now to FIG. 1, a first method of the invention is described. The method is for filtering image data corresponding to an image. The image data are stored in a plurality of pixels.
According to a box 110, base directions are defined for a plane. The base directions are chosen so that any direction belonging in a plane of the image can be described in terms of them. The preferred base directions are the horizontal and the vertical. Any direction in a plane of the image can be described in terms of a percentage of vertical and a percentage of horizontal.
In its most general form, the invention can be applied for only one of the base directions, which can be an identified, preset direction of interest. This will cover all dominant edges aligned with the preset direction. The method is preferably repeated with all the base directions, so as to cover all the possible directions of the dominant edges of the image.
The whole array of pixels is decomposed into blocks of pixels. The block size is chosen to be small enough to contain only one significant edge, and the associated ringing artifacts near it. A block size that works well is 8×8 pixels.
Each block is tested for containing a significant edge. If evidence of a significant edge is found, then the strongest edge is tested for being a dominant image edge. The testing for containing an edge includes using directional edge detection masks. A number of such masks are selected. Each mask has a mask direction associated with a respective one of the base directions. The masks are applied to at least some of the image data. This identifies at least one of the pixels that stores image data corresponding to an image edge, which is aligned with an identified one of the base directions. Since the base direction is known, the dominant edge direction is also known.
According to a box 120, a block of pixels is selected that contains a dominant edge along one of the base directions. Blocks that do not contain a dominant edge are inferred to not contain ringing artifacts and are preferably not processed.
According to a box 130, once a block has been identified, then at least one pixel of the block is identified whose unfiltered image data best corresponds to an edge. It is preferred to identify all the pixels of the block whose image data contains the dominant edge.
According to a box 140, even though unfiltered, the image data of the identified pixels is output. This will prevent smoothing of the dominant edge of the image. Once output, it is known that the remaining pixels contain image data that do not include the dominant edge.
According to a box 150, a directional de-ringing filter is selected. The filter is selected to have a main direction that is perpendicular to the identified base direction. This ensures that the filter's main direction is also inherently perpendicular with the direction of the dominant edge of the image.
The invention exploits the fact that ringing artifacts have an inherent alignment with the direction of the dominant edge of the image. The selected filter's main direction will turn out to be aligned with the inherent alignment of the ringing artifacts.
According to a box 160, the selected filter is applied to the image data of at least another one of the pixels. It is preferred to apply it to all the pixels remaining after the operation of box 140.
According to a box 170, the filtered image data is also output.
Referring now to FIGS. 2 and 3, a second method of the invention is described. It is a method for generating filtered image data that correspond to an image, from respective unfiltered image data which are stored in a plurality of respective pixels. The second method resembles the first method in a number of ways. For example, it will be recognized that boxes 210 through 260 can correspond to box 120 of FIG. 1.
According to a box 210, the next block of pixels is chosen. If this is the beginning of the process, then the first block of pixels is chosen.
The processing that follows is for the image data of the pixels of the selected block.
According to a box 220, the image data of at least some of the pixels are filtered, which is also known as convolved, with a horizontal edge detection mask EH. A suitable horizontal edge detection mask EH is given by Equation (1):

EH=[−101]  Equation(1)

Preferably all the pixels of the block are so filtered. This will compute a horizontal edge gradient GH(i,j) for each pixel of the block.
According to a box 230, the absolute values of the individual pixel horizontal edge gradients GH(i,j) are summed. The sum, also known as the horizontal edge content of a horizontal edge CHB in the block, is given by Equation (2):




  
    
      
        
          C
          HB
        
        =
        
          
            ∑
            
              i
              ,
              j
            
          
          ⁢
          
            
            
              
                G
                H
              
              ⁡
              
                (
                
                  i
                  ,
                  j
                
                )
              
            
            
          
        
      
    
    
      
        Equation
        ⁢
        
          
        
        ⁢
        
          (
          2
          )
        
      
    
  




According to boxes 240 and 250, the same computation is made for the vertical content. More specifically, the image data of at least some of the pixels are filtered, which is also known as convolved, with a vertical edge detection mask EV. A suitable vertical edge detection mask EV is given by Equation (3):




  
    
      
        
          E
          V
        
        =
        
          [
          
            
              
                
                  -
                  1
                
              
            
            
              
                0
              
            
            
              
                1
              
            
          
          ]
        
      
    
    
      
        Equation
        ⁢
        
          
        
        ⁢
        
          (
          3
          )
        
      
    
  




Preferably all the pixels of the block are filtered according to this method. This will compute a vertical edge gradient GV(i,j) for each pixel of the block.
According to a box 250, the absolute values of the individual pixel vertical edge gradients GV(i,j) are summed. The sum, also known as the vertical edge content of a vertical edge CVB in the block, is given by Equation (4):




  
    
      
        
          C
          VB
        
        =
        
          
            ∑
            
              i
              ,
              j
            
          
          ⁢
          
            
            
              
                G
                v
              
              ⁡
              
                (
                
                  i
                  ,
                  j
                
                )
              
            
            
          
        
      
    
    
      
        Equation
        ⁢
        
          
        
        ⁢
        
          (
          4
          )
        
      
    
  




According to a box 260, the horizontal edge content of the block CHB is compared to the vertical edge content CVB of the block. If CHB is larger than CVB, then the portion of the image of the image data contained in pixels of the block is classified as containing a horizontal edge. Conversely, if CVB is larger than CHB, then the portion of the image is classified as containing a vertical edge.
Optionally and preferably, a maximum edge content statistic MC is determined. MC is preferably determined as per Equation (5).




  
    
      
        MC
        =
        
          
            max
            
              i
              ,
              j
            
          
          ⁢
          
            {
            
              
                
                
                  
                    G
                    H
                  
                  ⁡
                  
                    (
                    
                      i
                      ,
                      j
                    
                    )
                  
                
                
              
              ,
              
                
                
                  
                    G
                    V
                  
                  ⁡
                  
                    (
                    
                      i
                      ,
                      j
                    
                    )
                  
                
                
              
            
            }
          
        
      
    
    
      
        Equation
        ⁢
        
          
        
        ⁢
        
          (
          5
          )
        
      
    
  




According to a box 270, the maximum edge content statistic MC is compared to a preset smoothness threshold ST. This is equivalent to inquiring whether the strongest edge of the block is a dominant edge of the image. If not, the according to box 280, the selected block is output as the final block. If yes, then processing continues as per the box 310.
According to a next box 310, a binary gradients map B(i,j) is generated, according to equation (6).




  
    
      
        
          B
          ⁡
          
            (
            
              i
              ,
              j
            
            )
          
        
        =
        
          {
          
            
              
                1
              
              
                
                  
                    if
                    ⁢
                    
                      
                    
                    ⁢
                    max
                    ⁢
                    
                      ⌊
                      
                        
                          
                            G
                            H
                          
                          ⁡
                          
                            (
                            
                              i
                              ,
                              j
                            
                            )
                          
                        
                        ,
                        
                          
                            G
                            V
                          
                          ⁡
                          
                            (
                            
                              i
                              ,
                              j
                            
                            )
                          
                        
                      
                      ⌋
                    
                  
                  >
                  
                    Thr
                    EDGE
                  
                
              
            
            
              
                0
              
              
                
                  otherwise
                  ⁢
                  
                    
                  
                
              
            
          
        
      
    
    
      
        Equation
        ⁢
        
          
        
        ⁢
        
          (
          6
          )
        
      
    
  




The binary gradients map B(i,j) is for pixels of the block. Computation of some of the values requires using the image data of pixels adjacent to the block. It will be appreciated that each pixel is classified as more horizontal or more vertical, and also larger than a threshold gradient GT. As such, the threshold gradient GT is different from the threshold smoothness ST defined above.
Similarly to box 130 of FIG. 1, this method also identifies pixels of the block whose image data best correspond to the edge. By this time, it is known that there exists some edge along one of the base directions, and that it is a dominant edge of the image.
Referring to box 320, a threshold sharpness EB is set for each of the pixels of the block, as quantified by the binary gradients map B(i,j).
According to box 330, a filtering mask M×N is determined. Preferably N>=M works better. The larger the M, the more smooth the filtering results. Filtering masks with sizes 3×7, 3×5, 1×7, 1×5, and 3×3 work well. In general, the smaller the image, the smaller the size of the filtering mask should be, so as not to lose the image details.
According to box 340, the filtering mask M×N is applied to the binary gradients map B(i,j) to determine which pixels of the block contained the sharpest edge transition. This is best implemented by using Equation (7).




  
    
      
        
          
            
              
                
                  
                    
                      ∑
                      
                        B
                        ⁡
                        
                          (
                          
                            r
                            ,
                            s
                          
                          )
                        
                      
                    
                    >
                    
                      E
                      B
                    
                  
                
              
              
                
                  
                    
                      i
                      -
                      
                        ⌊
                        
                          M
                          ⁢
                          
                            /
                          
                          ⁢
                          2
                        
                        ⌋
                      
                    
                    ≤
                    r
                    ≤
                    
                      i
                      +
                      
                        ⌊
                        
                          M
                          ⁢
                          
                            /
                          
                          ⁢
                          2
                        
                        ⌋
                      
                    
                  
                
              
            
          
        
        
          
            
              
                j
                -
                
                  ⌊
                  
                    N
                    ⁢
                    
                      /
                    
                    ⁢
                    2
                  
                  ⌋
                
              
              ≤
              s
              ≤
              
                j
                +
                
                  ⌊
                  
                    N
                    ⁢
                    
                      /
                    
                    ⁢
                    2
                  
                  ⌋
                
              
            
          
        
      
    
    
      
        Equation
        ⁢
        
          
        
        ⁢
        
          (
          7
          )
        
      
    
  




Each pixel which satisfies Equation (7) is deemed to have another sharp edge transition. The threshold EB is set low enough so that at least one pixel satisfies Equation (7), and high enough so that at least another one pixel does not.
According to box 350, the pixels that satisfy equation 6 are output without further processing. The remaining pixels are deemed to be non-edge pixels in the block, and to contain the associated ringing artifacts.
According to box 360, a directional filter is selected. The selected filter has a main direction perpendicular to the direction of the edge, as classified by the operation of box 270. If the dominant edge direction has transitions along the vertical direction, then the directional filter LDRH is used. Use of the filter is by operation of Equation (8) below:




  
    
      
        
          
            L
            DRH
          
          ⁡
          
            (
            
              i
              ,
              j
            
            )
          
        
        =
        
          
            
              
                
                  
                
              
            
            
              
                
                  
                    
                      mean
                    
                  
                  
                    
                      
                        
                          
                            
                              
                                i
                                -
                                
                                  ⌊
                                  
                                    M
                                    ⁢
                                    
                                      /
                                    
                                    ⁢
                                    2
                                  
                                  ⌋
                                
                              
                              ≤
                              r
                            
                          
                        
                        
                          
                            
                              r
                              ≤
                              
                                i
                                +
                                
                                  ⌊
                                  
                                    M
                                    ⁢
                                    
                                      /
                                    
                                    ⁢
                                    2
                                  
                                  ⌋
                                
                              
                            
                          
                        
                      
                    
                  
                
              
            
          
          ⁢
          
            
          
          [
          
            
              
                median
              
              
                
                  {
                  
                    L
                    ⁡
                    
                      (
                      
                        r
                        ,
                        s
                      
                      )
                    
                  
                  }
                
              
            
            
              
                
                  
                    j
                    -
                    
                      ⌊
                      
                        N
                        ⁢
                        
                          /
                        
                        ⁢
                        2
                      
                      ⌋
                    
                  
                  ≤
                  s
                
              
              
                
                  
                
              
            
            
              
                
                  s
                  ≤
                  
                    j
                    +
                    
                      ⌊
                      
                        N
                        ⁢
                        
                          /
                        
                        ⁢
                        2
                      
                      ⌋
                    
                  
                
              
              
                
                  
                
              
            
          
          ]
        
      
    
    
      
        Equation
        ⁢
        
          
        
        ⁢
        
          (
          8
          )
        
      
    
  




On the other hand, if the dominant edge direction has transitions along the horizontal direction, then the directional filter LDRV is used. Use of the filter is by operation of Equation (9) below:




  
    
      
        
          
            L
            DRV
          
          ⁡
          
            (
            
              i
              ,
              j
            
            )
          
        
        =
        
          
            
              
                
                  
                
              
            
            
              
                
                  
                    
                      mean
                    
                  
                  
                    
                      
                        
                          
                            
                              
                                i
                                -
                                
                                  ⌊
                                  
                                    M
                                    ⁢
                                    
                                      /
                                    
                                    ⁢
                                    2
                                  
                                  ⌋
                                
                              
                              ≤
                              s
                            
                          
                        
                        
                          
                            
                              s
                              ≤
                              
                                i
                                +
                                
                                  ⌊
                                  
                                    M
                                    ⁢
                                    
                                      /
                                    
                                    ⁢
                                    2
                                  
                                  ⌋
                                
                              
                            
                          
                        
                      
                    
                  
                
              
            
          
          ⁢
          
            
          
          [
          
            
              
                median
              
              
                
                  {
                  
                    L
                    ⁡
                    
                      (
                      
                        r
                        ,
                        s
                      
                      )
                    
                  
                  }
                
              
            
            
              
                
                  
                    j
                    -
                    
                      ⌊
                      
                        N
                        ⁢
                        
                          /
                        
                        ⁢
                        2
                      
                      ⌋
                    
                  
                  ≤
                  r
                
              
              
                
                  
                
              
            
            
              
                
                  r
                  ≤
                  
                    j
                    +
                    
                      ⌊
                      
                        N
                        ⁢
                        
                          /
                        
                        ⁢
                        2
                      
                      ⌋
                    
                  
                
              
              
                
                  
                
              
            
          
          ]
        
      
    
    
      
        Equation
        ⁢
        
          
        
        ⁢
        
          (
          9
          )
        
      
    
  




According to box 370, the image data of the remaining pixels are filtered by the directional filter. According to box 380, the filtered image data is output.
It will be appreciated that, due to the nature of the filter, the invention results in a different mean value for each side of the edge. This phenomenon makes the edge appear a more natural part of the reconstructed image.
A person skilled in the art will be able to practice the present invention in view of the description present in this document, which is to be taken as a whole. Numerous details have been set forth in order to provide a more thorough understanding of the invention. In other instances, well-known features have not been described in detail in order not to obscure unnecessarily the invention.
While the invention has been disclosed in its preferred form, the specific embodiments thereof as disclosed and illustrated herein are not to be considered in a limiting sense. Indeed, it should be readily apparent to those skilled in the art in view of the present description that the invention can be modified in numerous ways. The inventor regards the subject matter of the invention to include all combinations and subcombinations of the various elements, features, functions and/or properties disclosed herein.
The following claims define certain combinations and subcombinations, which are regarded as novel and non-obvious. Additional claims for other combinations and subcombinations of features, functions, elements and/or properties may be presented in this or a related document.

## Claims

1. A method for filtering image data corresponding to an image that are stored in a plurality of pixels, comprising:
defining a plurality of base directions in terms of which any direction belonging in a plane of the image can be described;
identifying a first one of the pixels that stores image data corresponding to an image edge aligned with an identified one of the base directions;
selecting a directional de-ringing filter having at least one main filter direction perpendicular with the identified base direction; and
applying the selected directional de-ringing filter to the image data of at least a second one of the pixels located adjacent to the identified first pixel, so that the pixel that stores image data corresponding to the image edge is not itself filtered.

2. The method of claim 1, further comprising:
selecting a plurality of directional edge detection masks, each having a mask direction associated with a respective one of the base directions, and
applying the masks to at least some of the image data to identify the first pixel.

3. The method of claim 1, further comprising:
computing the edge content in each of the base directions; and
comparing the edge contents of each direction to each other.

4. The method of claim 3, further comprising:
determining a maximum edge content statistic; and
comparing the determined maximum edge content statistic to a threshold smoothness.

5. A method for filtering image data corresponding to an image that are stored in a plurality of pixels, comprising:
identifying a first one of the pixels that stores image data corresponding to an image edge that has a preset edge direction;
selecting a directional de-ringing filter having at least one main filter direction perpendicular with the preset edge direction; and
applying the selected directional de-ringing filter to the image data of at least a second one of the pixels located adjacent to the identified first pixel, so that the pixel that stores image data corresponding to the image edge is not itself filtered.

6. The method of claim 5, further comprising:
selecting a directional edge detection mask having a mask direction associated with the preset direction, and
applying the mask to at least some of the image data to identify the first pixel.

7. The method of claim 5, further comprising:
identifying a third one of the pixels that stores image data that does not correspond to an image edge that has the preset edge direction, and
applying the selected directional de-ringing filter to the image data of the third pixel.

8. A method for generating filtered image data corresponding to an image from respective unfiltered image data stored in a plurality of respective pixels, the method comprising:
selecting a block of pixels;
determining whether a dominant edge can be detected within the block of pixels;
if a dominant edge is detected within the block of pixels, determining an associated angle of the detected dominant edge; and
if a dominant edge is detected within the block of pixels, applying a directional de-ringing filter only to selected pixels within the block, wherein the selected pixels are those lying within the block to either side of the pixels that contain the dominant edge, so that the pixels that contain the dominant edge are not filtered, and wherein the de-ringing filter has a main direction perpendicular to the angle of the detected dominant edge.

9. A method for generating filtered image data according to claim 8 wherein said determining an associated angle of the detected dominant edge includes:
selecting a group of pixels;
selecting a first edge detection mask having a first mask direction; and
convolving the image data of at least some of the selected pixels with the first edge detection mask to detect in a portion of the image corresponding to the group a first edge having a component along the first mask direction.

10. The method of claim 9, further comprising:
selecting a second edge detection mask having a second mask direction perpendicular to the first mask direction;
convolving the image data of at least some of the selected pixels with the second edge detection mask to detect in a portion of the image corresponding to the group a second edge having a component along the second mask direction; and
if such a second edge is detected, applying to at least one of the selected pixels a directional de-ringing filter having a main direction associated with the second mask direction.

11. A method for generating filtered image data corresponding to an image from respective unfiltered image data stored in a plurality of respective pixels, the method comprising:
selecting a block of pixels;
convolving the image data of at least some of the selected pixels with a horizontal edge detection mask to measure a horizontal edge content of a horizontal edge in a portion of the image corresponding to the block;
convolving the image data of at least some of the selected pixels with a vertical edge detection mask to measure a vertical edge content of a vertical edge in a portion of the image corresponding to the block;
comparing the horizontal edge content to the vertical edge content;
classifying the portion of the image as containing a horizontal edge if the horizontal edge content is larger than the vertical edge content, else classifying the portion of the image as containing a vertical edge, if the vertical edge content is larger than the horizontal edge content; and
if the portion of the image is classified as containing a horizontal edge, applying a directional de-ringing filter having a vertical main direction to at least a first one of the selected pixels,
else if the portion of the image is classified as containing a vertical edge, applying a directional de-ringing filter having a horizontal main direction to at least a second one of the pixels in the block.

12. The method of claim 11, further comprising:
determining a maximum edge content statistic, and
wherein the directional de-ringing filter is applied only if the determined maximum edge content statistic is larger than a preset smoothness threshold.