Abstract:
Scaling images for display includes determining if a nearest neighbor algorithm has been selected for scaling pixels of an image and, if so, finding the nearest neighbor using a linear interpolation algorithm.

Description:
BACKGROUND 
     This invention relates to scaling images for display. 
     Video and graphics images (source images) are often scaled down from their original resolution to fit onto display devices such as computer monitors or scaled up from their original resolution to provide an image of higher resolution and clarity. In these scaling processes, an averaging process combines (averages) two or more pixels that are spatially and/or temporally contiguous in the source image to form one destination pixel of the displayed image. The averaging process can use a nearest neighbor algorithm or a linear interpolation algorithm to effect the scaling. 
     Referring to FIGS. 1 and 2, the nearest neighbor algorithm computes a destination pixel (y)  10  from two pixels  12   a-b  (x 0 , x 1 ) in a source image as:        y   =     {         x0           if                 0     &lt;=   p0   &lt;   0.5             x1           if                 0.5     &lt;=   p0   &lt;   1                                    
     For four source pixels  14   a-d  (x 2 -x 5 ), y  16  is:        y1   =     {             x2           if                 0     &lt;=   p1   &lt;   0.5             x3           if                 0.5     &lt;=   p1   &lt;   1                
        y2     =     {             x4           if                 0     &lt;=   p1   &lt;   0.5             x5           if                 0.5     &lt;=   p1   &lt;   1                
        y     =     {         y1           if                 0     &lt;=   p2   &lt;   0.5             y2           if                 0.5     &lt;=   p2   &lt;   1                                            
     Thus, the nearest neighbor algorithm chooses the destination pixel y as the source pixel xi nearest to it. 
     The linear interpolation algorithm, on the other hand, computes the destination pixel  10  from two pixels  12   a-b  in a source image as: 
     
       
           y=[x   0 *(1 −p   0 )]+( x   1 * p   0 ) 
       
     
     For four source pixels  14   a-d , y  16  is: 
     
       
           y   1 =[ x   2 *(1 −p   1 )]+( x   3 * p   1 ) 
       
     
     
       
           y   2 =[ x   4 *(1 −p   1 )]+( x   5 * p   1 ) 
       
     
     
       
           y=[y   1 *(1 −p   2 )]+( y   2 * p   2 ) 
       
     
     Thus, the linear interpolation algorithm chooses the destination pixel y as a weighted average of the source pixels xj-xk. The destination pixel need not be one of the source pixels as it is for the nearest neighbor algorithm. 
    
    
     DESCRIPTION OF DRAWINGS 
     FIGS. 1 and 2 are diagrams showing pixels in a source image and in a destination image. 
     FIG. 3 is a block diagram of a computer system. 
     FIG. 4 is a flowchart of a scaling process in accordance with an embodiment of the invention. 
    
    
     DESCRIPTION 
     Referring to FIG. 3, in one embodiment of the invention, a system  20  includes a graphics controller  22  responsible for many of the graphics processing tasks performed on source images stored in a memory  24  before a display device  26  displays the source images. The graphics controller  22  includes a scaler  28  that scales the source images to a resolution supported by the display device  26 . In scaling the source images, the scaler  28  can use a nearest neighbor algorithm or a linear interpolation algorithm depending on a current (real-time) scaling mode. The current scaling mode depends on characteristics of the source image and the system  20  including source image resolution, display resolution, refresh rate, and pixel depth. Each scaling mode supported by the scaler  28  uses one of the algorithms as indicated in two register bits included in the scaler  28 , each register bit indicating one of the two algorithms. The active algorithm is indicated with a one or a zero (depending on system configuration), and the inactive algorithm is indicated with the opposite value. Software can specify which algorithm each mode corresponds to by programming the state of the register bits, or a user of the system  20  may accomplish the same result by programming (or reprogramming) the scaler  28  to use a certain algorithm for a certain mode. 
     Also referring to FIG. 4, the scaler  28  determines ( 30 ) which algorithm is selected for the current scaling mode by examining one or both of the register bits using software and/or hardware. If the linear interpolation algorithm is selected, the scaler  28  performs ( 32 ) linear interpolation using a hardware device as described above, although a software device may be used in addition to or as a substitute for the hardware device. If the nearest neighbor algorithm is selected, the scaler  28  also performs ( 32 ) linear interpolation, but instead of using the actual distances between the destination pixel and the source pixels (pX and (1−pX) in the equations above), the scaler  28  chooses ( 34 ) zero or one as the distance variable p(NN) as shown:          p        (   NN   )       =     {         0           if                 0     &lt;=   pX   &lt;   0.5             1           if                 0.5     &lt;=   pX   &lt;   1                                    
     In this way, the scaler  28  in effect performs ( 32 ) a nearest neighbor calculation using the linear interpolation algorithm as shown (with reference to FIG.  1 ): 
     
       
           y=[x   0 *(1− p ( NN ))]+( x   1 * p ( NN )) 
       
     
     In this linear interpolation algorithm, one source pixel  12   a-b  is multiplied by zero while the other is multiplied by one, effectively calculating y as the source pixel  12   a-b  nearest to y. Of course, this calculation can extend to any number of source pixels. By performing ( 32 ) the linear interpolation algorithm regardless of which algorithm is selected, the scaler  28  need not include any special hardware to implement the nearest neighbor algorithm in excess of the hardware necessary to implement the linear interpolation algorithm. 
     Other embodiments are within the scope of the following claims.