Abstract:
A method and device for generating a perspective image are provided, which are related to multimedia technology. The method comprises the following steps: acquiring the length, height and vanishing point of a required perspective image and the length and height of an original image; for each pixel point (x′, y′) in the perspective image, determining the coordinate (x, y) of a pixel point in the original image corresponding to said pixel point; copying the pixel point at the coordinate (x, y) in the original image to the position corresponding to the coordinate (x′, y′) in said perspective image. The invention utilizes a principle that perspective image is smaller than original image, and employs a form of inverse transform, thereby the calculated pixel points are reduced, and compared with forward calculation, the calculation is greatly reduced, which improves the speed of perspective image generating and saves central processing unit (CPU) resources.

Description:
[0001]    This application claims priority to Chinese Patent Application No. 200910205587.9, filed with the State Intellectual Property Office of People&#39;s Republic of China on Oct. 30, 2009 and entitled “Method and Device for Generating Perspective Image”, which is hereby incorporated by reference in its entirety. 
       FIELD OF THE INVENTION 
       [0002]    The present invention relates to the field of multimedia and particularly to a method and device for generating a perspective image. 
       BACKGROUND OF THE INVENTION 
       [0003]    At present, various animation effects in a mobile terminal bring a good experience to a user as the mobile terminal is enhanced in terms of its configuration, and three-dimensional animation effects, including rotary turning of a page and rotation of a cube, especially present very good visual perception, where generation of a perspective image is crucial to present these three-dimension animation effects. 
         [0004]    As illustrated in  FIG. 1 , a visual effect of a cube can be presented simply by performing perspective transformation on an original image toward the left and the right respectively and then splicing, and a special rotation effect of a cube is achieved by changing the perspective angles of perspective images on the left and the right sequentially resulting in a plurality of three-dimension images and then combining them in a plurality of frames and displaying them rapidly and consecutively. Generally, a frame rate above 15 frames per second is required for relatively smooth visual perception, so the two perspective images on the left and the right have to be generated and displayed in 66 milliseconds. In a real system, a CPU may be occupied by other tasks, so there is actually a period of time shorter than 66 milliseconds for generation of the perspective images. 
         [0005]    In an existing method for generating a perspective image, each of pixel points of an original image is duplicated according to a function group from 
         [0000]    
       
         
           
             
               x 
               ′ 
             
             = 
             
               F 
                
               
                 ( 
                 
                   x 
                   , 
                   y 
                 
                 ) 
               
             
           
         
       
       
         
           
             
               y 
               ′ 
             
             = 
             
               G 
                
               
                 ( 
                 
                   x 
                   , 
                   y 
                 
                 ) 
               
             
           
         
       
     
         [0000]    a coordinate space constituted of the x axis and the y axis into a coordinate space constituted of the x′ axis and the y′ axis, where floating-point and trigonometric function operations involved in the functions F (x, y) and G (x, y) are rather demanding in terms of the performance of a CPU. 
         [0006]    A period of time for generation of perspective images combined in a frame is limited by the performance of a CPU, the size of an image and other factors. In a general low- to mid-end cellular phone system of CDMA, a 240×400 display screen and an ARM9 CPU at 192 MHz, for example, are used, and then there are actually only 40 milliseconds for generation of perspective images combined in a frame after the CPU is occupied by display and other tasks, so there are only 20 milliseconds on average for generation of a perspective image, which may be impractical with the foregoing perspective transformation method. 
       SUMMARY OF THE INVENTION 
       [0007]    Embodiments of the invention provide a method and device for generating a perspective image to improve the speed at which the perspective image is generated and save a CPU resource. 
         [0008]    A method for generating a perspective image includes: 
         [0009]    obtaining length, height and a vanishing point of a required perspective image and length and height of an original image; 
         [0010]    determining, for each of pixel points (x′, y′) in the perspective image, coordinates (x, y) of a pixel point in the original image corresponding to the pixel point (x′, y′), according to the length, the height and the vanishing point of the perspective image and the length and the height of the original image; and 
         [0011]    duplicating the pixel point on the coordinates (x, y) in the original image onto a location in the perspective image corresponding to the coordinates (x′, y′). 
         [0012]    Furthermore, determining, for each of pixel points (x′, y′) in the perspective image, coordinates (x, y) of a pixel point in the original image corresponding to the pixel point (x′, y′), according to the length, the height and the vanishing point of the perspective image and the length and the height of the original image includes: 
         [0013]    determining the coordinates (x, y) of the pixel point in the original image corresponding to the pixel point (x′, y′) according to the length, the height and the vanishing point of the perspective image and the length and the height of the original image, the coordinates (x′, y′) of the pixel point in the perspective image and a preset function group 
         [0000]    
       
         
           
             x 
             = 
             
               f 
                
               
                 ( 
                 
                   x 
                   ′ 
                 
                 ) 
               
             
           
         
       
       
         
           
             y 
             = 
             
               
                 g 
                  
                 
                   ( 
                   
                     
                       x 
                       ′ 
                     
                     , 
                     
                       y 
                       ′ 
                     
                   
                   ) 
                 
               
               . 
             
           
         
       
     
         [0014]    Still furthermore, the function group 
         [0000]    
       
         
           
             x 
             = 
             
               f 
                
               
                 ( 
                 
                   x 
                   ′ 
                 
                 ) 
               
             
           
         
       
       
         
           
             y 
             = 
             
               g 
                
               
                 ( 
                 
                   
                     x 
                     ′ 
                   
                   , 
                   
                     y 
                     ′ 
                   
                 
                 ) 
               
             
           
         
       
     
         [0000]    includes x=x′+n x x′ 2  and y=a(x′)x y′+b(x′), wherein 
         [0000]    
       
         
           
             
               
                 a 
                  
                 
                   ( 
                   
                     x 
                     ′ 
                   
                   ) 
                 
               
               = 
               
                 p 
                 
                   p 
                   - 
                   
                     x 
                     ′ 
                   
                 
               
             
             , 
             
               
                 b 
                  
                 
                   ( 
                   
                     x 
                     ′ 
                   
                   ) 
                 
               
               = 
               
                 
                   
                     H 
                     × 
                     
                       ( 
                       
                         p 
                         - 
                         
                           x 
                           ′ 
                         
                       
                       ) 
                     
                   
                   - 
                   
                     
                       H 
                       ′ 
                     
                     × 
                     p 
                   
                 
                 
                   2 
                    
                   
                     ( 
                     
                       p 
                       - 
                       
                         x 
                         ′ 
                       
                     
                      
                     
                         
                     
                     ) 
                   
                 
               
             
             , 
             
               
 
             
              
             
               n 
               = 
               
                 
                   W 
                   - 
                   
                     W 
                     ′ 
                   
                 
                 
                   W 
                   
                     ′ 
                      
                     
                         
                     
                      
                     2 
                   
                 
               
             
             , 
             H 
           
         
       
     
         [0000]    represents the height of the original image, H′ represents the height of the perspective image, p represents an abscissa of the vanishing point of the perspective image, W represents the length of the original image, and W′ represents the length of the perspective image. 
         [0015]    Preferably, the method further includes: before performing calculation with the function group, 
         [0016]    shifting left a numerator in a parameter by corresponding digits according to a required precision of the parameter; 
         [0017]    performing an integer operation with the left-shifted parameter; and 
         [0018]    shifting right a calculated result by the same digits as that of left-shifting after the integer operation to derive a calculated result in compliance with the required precision. 
         [0019]    Furthermore, determining, for each of pixel points (x′, y′) in the perspective image, coordinates (x, y) of a pixel point in the original image corresponding to the pixel point (x′, y′), according to the length, the height and the vanishing point of the perspective image and the length and the height of the original image includes: 
         [0020]    for each of values of x′ in [0, W′] in the perspective image, determining an abscissa x in the original image corresponding to x′, and for each of values of y′ in [H′x′/2p, H′−H′x′/2p], determining an ordinate y in the original image corresponding to y′, wherein W′ represents the length of the perspective image, H′ represents the height of the perspective image, and p represents an abscissa of the vanishing point of the perspective image. 
         [0021]    Still furthermore, determining, for each of pixel points (x′, y′) in the perspective image, coordinates (x, y) of a pixel point in the original image corresponding to the pixel point (x′, y′), according to the length, the height and the vanishing point of the perspective image and the length and the height of the original image includes: 
         [0022]    for each of values of x′ in [0, W′] in the perspective image, determining an abscissa x in the original image corresponding to x′ in the formula of x=x′+n×x′ 2 , and determining values of a and b in the formulas of 
         [0000]    
       
         
           
             
               a 
                
               
                 ( 
                 
                   x 
                   ′ 
                 
                 ) 
               
             
             = 
             
               p 
               
                 p 
                 - 
                 
                   x 
                   ′ 
                 
               
             
           
         
       
     
         [0000]    and 
         [0000]    
       
         
           
             
               
                 b 
                  
                 
                   ( 
                   
                     x 
                     ′ 
                   
                   ) 
                 
               
               = 
               
                 
                   
                     H 
                     × 
                     
                       ( 
                       
                         p 
                         - 
                         
                           x 
                           ′ 
                         
                       
                       ) 
                     
                   
                   - 
                   
                     
                       H 
                       ′ 
                     
                     × 
                     p 
                   
                 
                 
                   2 
                    
                   
                     ( 
                     
                       p 
                       - 
                       
                         x 
                         ′ 
                       
                     
                      
                     
                         
                     
                     ) 
                   
                 
               
             
             ; 
           
         
       
     
         [0000]    and for each of values of y′ in [H′x′/2p, H′−H′x′/2p], determining an ordinate y in the original image corresponding to y′ according to the determined values of a and b in the formula of y=a(x′)×y′+b(x′). 
         [0023]    Preferably, determining, for each of pixel points (x′, y′) in the perspective image, coordinates (x, y) of a pixel point in the original image corresponding to the pixel point (x′, y′), according to the length, the height and the vanishing point of the perspective image and the length and the height of the original image includes: 
         [0024]    for each of pixel points with y′≦H′/2 in the perspective image, determining the coordinates (x, y) of the pixel point in the original image corresponding to the pixel point (x′, y′) according to the length, the height and the vanishing point of the perspective image and the length and the height of the original image, the coordinates (x′, y′) of the pixel point in the perspective image and a preset function group 
         [0000]    
       
         
           
             x 
             = 
             
               f 
                
               
                 ( 
                 
                   x 
                   ′ 
                 
                 ) 
               
             
           
         
       
       
         
           
             
               y 
               = 
               
                 g 
                  
                 
                   ( 
                   
                     
                       x 
                       ′ 
                     
                     , 
                     
                       y 
                       ′ 
                     
                   
                   ) 
                 
               
             
             ; 
           
         
       
     
         [0000]    and 
         [0025]    for each of the other pixel points in the perspective image, determining directly coordinates (x, H−y) of a pixel point in the original image corresponding to the pixel point (x′, H′−y′) according to the coordinates (x′, y′) of the pixel point with y′≦H′/2 and the coordinates (x, y) of the corresponding pixel point in the original image. 
         [0026]    A device for generating a perspective image includes: 
         [0027]    a unit configured to obtain length, height and a vanishing point of a required perspective image and length and height of an original image; 
         [0028]    a unit configured to determine, for each of pixel points (x′, y′) in the perspective image, coordinates (x, y) of a pixel point in the original image corresponding to the pixel point (x′, y′), according to the length, the height and the vanishing point of the perspective image and the length and the height of the original image; and 
         [0029]    a unit configured to duplicate the pixel point on the coordinates (x, y) in the original image onto a location in the perspective image corresponding to the coordinates (x′, y′). 
         [0030]    Furthermore, the unit configured to determine, for each of pixel points (x′, y′) in the perspective image, coordinates (x, y) of a pixel point in the original image corresponding to the pixel point (x′, y′), according to the length, the height and the vanishing point of the perspective image and the length and the height of the original image includes: 
         [0031]    a unit configured to determine the coordinates (x, y) of the pixel point in the original image corresponding to the pixel point (x′, y′) according to the length, the height and the vanishing point of the perspective image and the length and the height of the original image, the coordinates (x′, y′) of the pixel point in the perspective image and a preset function group 
         [0000]    
       
         
           
             x 
             = 
             
               f 
                
               
                 ( 
                 
                   x 
                   ′ 
                 
                 ) 
               
             
           
         
       
       
         
           
             y 
             = 
             
               
                 g 
                  
                 
                   ( 
                   
                     
                       x 
                       ′ 
                     
                     , 
                     
                       y 
                       ′ 
                     
                   
                   ) 
                 
               
               . 
             
           
         
       
     
         [0032]    Still furthermore, the unit configured to determine, for each of pixel points (x′, y′) in the perspective image, coordinates (x, y) of a pixel point in the original image corresponding to the pixel point (x′, y′), according to the length, the height and the vanishing point of the perspective image and the length and the height of the original image includes: 
         [0033]    a sub-unit configured to, for each of pixel points with y′≦H′/2 in the perspective image, determine the coordinates (x, y) of the pixel point in the original image corresponding to the pixel point (x′, y′) according to the length, the height and the vanishing point of the perspective image and the length and the height of the original image, the coordinates (x′, y′) of the pixel point in the perspective image and a preset function group 
         [0000]    
       
         
           
             x 
             = 
             
               f 
                
               
                 ( 
                 
                   x 
                   ′ 
                 
                 ) 
               
             
           
         
       
       
         
           
             
               y 
               = 
               
                 g 
                  
                 
                   ( 
                   
                     
                       x 
                       ′ 
                     
                     , 
                     
                       y 
                       ′ 
                     
                   
                   ) 
                 
               
             
             ; 
           
         
       
     
         [0000]    and 
         [0034]    a sub-unit configured to, for each of the other pixel points in the perspective image, determine directly coordinates (x, H−y) of a pixel point in the original image corresponding to the pixel point (x′, H′−y′) according to the coordinates (x′, y′) of the pixel point with y′≦H′/2 and the coordinates (x, y) of the corresponding pixel point in the original image. 
         [0035]    A method and device for generating a perspective image according to the embodiments of the invention use the form of inverse transformation under the principle of the area of the perspective image being smaller than that of an original image to thereby reduce the number of calculated pixel points and thus greatly reduce the effort of calculation, improve the speed at which the perspective image is generated and save a CPU resource as compared with a forward operation. 
     
    
     
       BRIEF DESCRIPTION OF THE DRAWINGS 
         [0036]      FIG. 1  is a schematic diagram of a principle of generating a three-dimension animation effect in the prior art; 
           [0037]      FIG. 2  is a flow chart of a method for generating a perspective image according to an embodiment of the invention; and 
           [0038]      FIG. 3  is a schematic diagram of a perspective image to be generated in an embodiment of the invention. 
       
    
    
     DETAILED DESCRIPTION OF THE EMBODIMENTS 
       [0039]    Embodiments of the invention provide a method and device for generating a perspective image in which the form of inverse transformation is used according to the length, the height and the vanishing point of a required perspective image to obtain the coordinates in an original image corresponding to each of points in the perspective image and the point on the corresponding coordinates in the original image is duplicated onto a corresponding location in the perspective image, thereby generating the perspective image. Since the area of the perspective image is smaller than that of the original image, the effort of calculation can be reduced, the speed at which the perspective image is generated can be improved and a CPU resource can be saved. 
         [0040]    As illustrated in  FIG. 2 , a method for generating a perspective image according to an embodiment of the invention includes the following steps. 
         [0041]    A step S 201  is to obtain length, height and a vanishing point of a required perspective image and length and height of an original image. 
         [0042]    The length of the perspective image refers to a difference between abscissas of points with the largest abscissa and with the smallest abscissa in the perspective image, the height of the perspective image refers to a difference between ordinates of points with the largest ordinate and with the smallest ordinate in the perspective image, and the vanishing point refers to a point where straight lines in the perspective image corresponding to horizontal lines in the original image intersect, similarly, the length of the original image refers to a difference between abscissas of points with the largest abscissa and with the smallest abscissa in the original image, and the height of the original image refers to a difference between ordinates of points with the largest ordinate and with the smallest ordinate in the original image. 
         [0043]    A step S 202  is to determine, for each of pixel points (x′, y′) in the perspective image, coordinates (x, y) of a pixel point in the original image corresponding to the pixel point (x′, y′), according to the length, the height and the vanishing point of the perspective image and the length and the height of the original image. 
         [0044]    A step S 203  is to duplicate the pixel point on the coordinates (x, y) in the original image onto a location in the perspective image corresponding to the coordinates (x′, y′). 
         [0045]    Thus the perspective image with a pattern of the original image is generated, and two perspective images of the original image toward the left and the right respectively are acquired and then spliced into a three-dimension patter which constitutes one of frames with an animation effect. 
         [0046]    More than ten frames to tens of frames are typically required for a full animation effect, and parameters of a perspective image, e.g., a vanishing point, length and height thereof, are determined as preset for each of the frames, so the perspective image required for the frame can be generated simply by calculating according to the predetermined parameters. 
         [0047]    Since the area of the perspective image is smaller than that of the original image, the effort of calculation when obtaining the coordinates of the corresponding point in the original image from the coordinates of the pixel point in the perspective image and then duplicating the corresponding point in the original image is much less than that when obtaining the coordinates of the corresponding point in the perspective image from the pixel point in the original image, and generally the height H′ of the perspective image is equal to or slightly larger than the height H of the original image due to different angles of view, and when H′ is slightly larger than H, H′ is typically no more than 1.2 times of H for the sake of a good visual effect. In a practical application, H′ is equal to H in most cases, and since the average length of the perspective image is ½ of the original image, the height W′ of a trapezium is W/2 and the short side thereof ranges from 0 to H′ with H′=H. As can be apparent from the trapezium area formula, the area of the perspective image ranges from ¼ to ½ of the original image, so the effort of calculation can be reduced to ¼ to ½ by obtaining the coordinates of the corresponding points in the original image from the coordinates of the pixel points in the perspective image. 
         [0048]    In the step S 202 , the coordinates (x, y) of the pixel point in the original image corresponding to the pixel point in the perspective image may be calculated with a preset function group 
         [0000]    
       
         
           
             x 
             = 
             
               f 
                
               
                 ( 
                 
                   x 
                   ′ 
                 
                 ) 
               
             
           
         
       
       
         
           
             y 
             = 
             
               
                 g 
                  
                 
                   ( 
                   
                     
                       x 
                       ′ 
                     
                     , 
                     
                       y 
                       ′ 
                     
                   
                   ) 
                 
               
               . 
             
           
         
       
     
         [0049]    The function group may be derived directly from the inverse function of 
         [0000]    
       
         
           
             
               x 
               ′ 
             
             = 
             
               F 
                
               
                 ( 
                 
                   x 
                   , 
                   y 
                 
                 ) 
               
             
           
         
       
       
         
           
             
               y 
               ′ 
             
             = 
             
               G 
                
               
                 ( 
                 
                   x 
                   , 
                   y 
                 
                 ) 
               
             
           
         
       
     
         [0000]    in the prior art or further simplified. 
         [0050]    Due to visually different distances, the corresponding coordinate x′ is nonlinearly increased by a decreasing amplitude when the coordinate x in the original image is linearly increased, and the corresponding coordinate x in the original image is nonlinearly increased by an increasing amplitude when the coordinate x′ in the perspective image is linearly increased. Thus it is sufficient to comply with this regularity of variation in the simplified formulas, which requires that the first-order derivative of the function x=f (x′) is larger than 1 and the second-order derivative thereof is larger than 0. After transformation with the eligible simplified formulas, the resulting perspective image can be made very similar to a perspective image resulting from transformation in a conventional method. 
         [0051]    For example, a simple formula in compliance with the regularity is x=ƒ(x′)=x′+n×x′ 2 , where 
         [0000]    
       
         
           
             
               n 
               = 
               
                 
                   W 
                   - 
                   
                     W 
                     ′ 
                   
                 
                 
                   W 
                   
                     ′ 
                      
                     
                         
                     
                      
                     2 
                   
                 
               
             
             , 
           
         
       
     
         [0000]    the first-order derivative of the function is 1+2nx larger than 1 when x&gt;0, and the second-order derivative of the function is 2n&gt;0, thus complying with the foregoing condition, so this function may be used for transformation of the x coordinate, and then 
         [0000]    
       
         
           
             
               
                 
                   
                     H 
                     ′ 
                   
                   / 
                   2 
                 
                 - 
                 
                   y 
                   ′ 
                 
               
               
                 p 
                 - 
                 
                   x 
                   ′ 
                 
               
             
             = 
             
               
                 
                   H 
                   / 
                   2 
                 
                 - 
                 y 
               
               p 
             
           
         
       
     
         [0000]    may be derived in the perspective image under a principle of triangle similarity and then rearranged into 
         [0000]    
       
         
           
             
               y 
               = 
               
                 
                   
                     H 
                     2 
                   
                   - 
                   
                     
                       p 
                       × 
                       
                         ( 
                         
                           
                             
                               H 
                               ′ 
                             
                             2 
                           
                           - 
                           
                             y 
                             ′ 
                           
                         
                         ) 
                       
                     
                     
                       p 
                       - 
                       
                         x 
                         ′ 
                       
                     
                   
                 
                 = 
                 
                   
                     
                       p 
                       
                         p 
                         - 
                         
                           x 
                           ′ 
                         
                       
                     
                      
                     
                       y 
                       ′ 
                     
                   
                   + 
                   
                     ( 
                     
                       
                         
                           H 
                           × 
                           
                             ( 
                             
                               p 
                               - 
                               
                                 x 
                                 ′ 
                               
                             
                             ) 
                           
                         
                         - 
                         
                           
                             H 
                             ′ 
                           
                           × 
                           p 
                         
                       
                       
                         2 
                          
                         
                           ( 
                           
                             p 
                             - 
                             
                               x 
                               ′ 
                             
                           
                           ) 
                         
                       
                     
                     ) 
                   
                 
               
             
             , 
           
         
       
     
         [0000]    so particularly in the function group 
         [0000]    
       
         
           
             x 
             = 
             
               f 
                
               
                 ( 
                 
                   x 
                   ′ 
                 
                 ) 
               
             
           
         
       
       
         
           
             
               y 
               = 
               
                 g 
                  
                 
                   ( 
                   
                     
                       x 
                       ′ 
                     
                     , 
                     
                       y 
                       ′ 
                     
                   
                   ) 
                 
               
             
             , 
           
         
       
     
         [0000]    x=ƒ(x′)=x′+n×x′ 2  and 
         [0000]    
       
         
           
             
               y 
               = 
               
                 
                   
                     H 
                     2 
                   
                   - 
                   
                     
                       p 
                       × 
                       
                         ( 
                         
                           
                             
                               H 
                               ′ 
                             
                             2 
                           
                           - 
                           
                             y 
                             ′ 
                           
                         
                         ) 
                       
                     
                     
                       p 
                       - 
                       
                         x 
                         ′ 
                       
                     
                   
                 
                 = 
                 
                   
                     
                       p 
                       
                         p 
                         - 
                         
                           x 
                           ′ 
                         
                       
                     
                      
                     
                       y 
                       ′ 
                     
                   
                   + 
                   
                     ( 
                     
                       
                         
                           H 
                           × 
                           
                             ( 
                             
                               p 
                               - 
                               
                                 x 
                                 ′ 
                               
                             
                             ) 
                           
                         
                         - 
                         
                           
                             H 
                             ′ 
                           
                           × 
                           p 
                         
                       
                       
                         2 
                          
                         
                           ( 
                           
                             p 
                             - 
                             
                               x 
                               ′ 
                             
                           
                           ) 
                         
                       
                     
                     ) 
                   
                 
               
             
             , 
           
         
       
     
         [0000]    where H represents the height of the original image, H′ represents the height of the perspective image, and p represents an abscissa of the vanishing point of the perspective image, as illustrated in  FIG. 3 , the vanishing point refers to the point where horizontal lines in the original image intersect in the perspective image, 
         [0000]    
       
         
           
             
               n 
               = 
               
                 
                   W 
                   - 
                   
                     W 
                     ′ 
                   
                 
                 
                   W 
                   
                     ′ 
                      
                     
                         
                     
                      
                     2 
                   
                 
               
             
             , 
           
         
       
     
         [0000]    W represents the length of the original image, and W′ represents the length of the perspective image. 
         [0000]    
       
         
           
             y 
             = 
             
               
                 
                   H 
                   2 
                 
                 - 
                 
                   
                     p 
                     × 
                     
                       ( 
                       
                         
                           
                             H 
                             ′ 
                           
                           2 
                         
                         - 
                         
                           y 
                           ′ 
                         
                       
                       ) 
                     
                   
                   
                     p 
                     - 
                     
                       x 
                       ′ 
                     
                   
                 
               
               = 
               
                 
                   
                     p 
                     
                       p 
                       - 
                       
                         x 
                         ′ 
                       
                     
                   
                    
                   
                     y 
                     ′ 
                   
                 
                 + 
                 
                   ( 
                   
                     
                       
                         H 
                         × 
                         
                           ( 
                           
                             p 
                             - 
                             
                               x 
                               ′ 
                             
                           
                           ) 
                         
                       
                       - 
                       
                         
                           H 
                           ′ 
                         
                         × 
                         p 
                       
                     
                     
                       2 
                        
                       
                         ( 
                         
                           p 
                           - 
                           
                             x 
                             ′ 
                           
                         
                         ) 
                       
                     
                   
                   ) 
                 
               
             
           
         
       
     
         [0000]    may be written as 
         [0000]    
       
         
           
             
               y 
               = 
               
                 
                   
                     a 
                      
                     
                       ( 
                       
                         x 
                         ′ 
                       
                       ) 
                     
                   
                   × 
                   
                     y 
                     ′ 
                   
                 
                 + 
                 
                   b 
                    
                   
                     ( 
                     
                       x 
                       ′ 
                     
                     ) 
                   
                 
               
             
             , 
             
               
 
             
              
             
               
                 where 
                  
                 
                     
                 
                  
                 
                   a 
                    
                   
                     ( 
                     
                       x 
                       ′ 
                     
                     ) 
                   
                 
               
               = 
               
                 
                   
                     p 
                     
                       p 
                       - 
                       
                         x 
                         ′ 
                       
                     
                   
                    
                   
                       
                   
                    
                   and 
                    
                   
                       
                   
                    
                   
                     b 
                      
                     
                       ( 
                       
                         x 
                         ′ 
                       
                       ) 
                     
                   
                 
                 = 
                 
                   
                     
                       
                         H 
                         × 
                         
                           ( 
                           
                             p 
                             - 
                             
                               x 
                               ′ 
                             
                           
                           ) 
                         
                       
                       - 
                       
                         
                           H 
                           ′ 
                         
                         × 
                         p 
                       
                     
                     
                       2 
                        
                       
                         ( 
                         
                           p 
                           - 
                           
                             x 
                             ′ 
                           
                         
                         ) 
                       
                     
                   
                   . 
                 
               
             
           
         
       
     
         [0052]    The parameters shall be calculated with a high precision typically above 2 −8  and even with a precision of 2 −16  for some of the parameters. Since the ARM CPU is not capable of performing calculation on a floating-point number, a floating-point operation on a floating-point number has to be simulated with relevant software, thus degrading the operation speed, and if a parameter is shifted left by the corresponding digits according to the required precision of the parameter prior to calculation and then subject to an integer operation and shifted right by the same digits after the integer operation, then the corresponding precision of the parameter can be maintained while avoiding a floating-point number operation to thereby further improve the operation speed. For example, if n shall be maintained with a precision of 2 −16 , the numerator 
         [0000]    
       
         
           
             
               W 
               - 
               
                 
                   W 
                   ′ 
                 
                  
                 
                     
                 
                  
                 of 
                  
                 
                     
                 
                  
                 n 
               
             
             = 
             
               
                 W 
                 - 
                 
                   W 
                   ′ 
                 
               
               
                 W 
                 
                   ′ 
                    
                   
                       
                   
                    
                   2 
                 
               
             
           
         
       
     
         [0000]    is shifted left by 16 digits prior to calculation thereof and then divided by w′ 2 , and the calculated result is shifted right by 16 digits after multiplication and division operations relating to n are performed, thereby generating a calculated result with a precision of 2 −16 . If two or more parameters are shifted in the same calculation process, the digits by which they are shifted shall be determined by the one of the parameters with a higher precision. For example, if both of parameters a and b are involved in the same calculation process but the precision of a is set as 2 −8  and the precision of b is set as 2 −10 , calculation is performed with the precision of 2 −10  so that the required parameters are shifted left by 10 digits prior to calculation and subject to an integer operation and then shifted right by 10 digits. 
         [0053]    For calculation of n and x, they may be calculated in the following two formulas: 
         [0000]    
       
         
           
             n 
             = 
             
               
                 
                   ( 
                   
                     W 
                     - 
                     
                       W 
                       ′ 
                     
                   
                   ) 
                 
                  
                 
                   &lt;&lt; 
                   16 
                 
               
               
                 W 
                 ′2 
               
             
           
         
       
     
         [0000]    and x=x′+((n×x′ 2 )&gt;&gt;16), thereby resulting in the value of n and the value of x with a required precision. 
         [0054]    Furthermore, since calculation is performed for each of the pixel points in the perspective image and all the values of x, a and b are dependent upon only x′ and independent of y′ in an implementation and y′ is introduced only when the value of y is calculated, x′ may be selected as an outer layer of cyclical nesting for calculation of the coordinates (x, y) in an embodiment of the invention to thereby reduce the effort of calculation. 
         [0055]    For calculation, firstly for each value of x′ in [0, W′] in the perspective image, the abscissa x in the original image corresponding to x′ and the value of a and the value of b are determined, and then for each value of y′ with respect to the value of x′, that is, for each value of y′ in 
         [0000]    
       
         
           
             
               [ 
               
                 
                   
                     
                       H 
                       ′ 
                     
                      
                     
                       x 
                       ′ 
                     
                   
                   
                     2 
                      
                     p 
                   
                 
                 , 
                 
                   
                     H 
                     ′ 
                   
                   - 
                   
                     
                       
                         H 
                         ′ 
                       
                        
                       
                         x 
                         ′ 
                       
                     
                     
                       2 
                        
                       p 
                     
                   
                 
               
               ] 
             
             , 
           
         
       
     
         [0000]    the ordinate y in the original image corresponding to y′ is determined, so that the coordinates in the original image corresponding to the pixel point in the perspective image can be obtained with a less effort of calculation. 
         [0056]    Particularly as can be apparent from  FIG. 3 , for each value of x′, a pixel point is present only with y′ in the range of 
         [0000]    
       
         
           
             
               [ 
               
                 
                   
                     
                       H 
                       ′ 
                     
                      
                     
                       x 
                       ′ 
                     
                   
                   
                     2 
                      
                     p 
                   
                 
                 , 
                 
                   
                     H 
                     ′ 
                   
                   - 
                   
                     
                       
                         H 
                         ′ 
                       
                        
                       
                         x 
                         ′ 
                       
                     
                     
                       2 
                        
                       p 
                     
                   
                 
               
               ] 
             
             , 
           
         
       
     
         [0000]    so it is sufficient to obtain the value of y′taking into account y′ lying within the range of 
         [0000]    
       
         
           
             
               [ 
               
                 
                   
                     
                       H 
                       ′ 
                     
                      
                     
                       x 
                       ′ 
                     
                   
                   
                     2 
                      
                     p 
                   
                 
                 , 
                 
                   
                     H 
                     ′ 
                   
                   - 
                   
                     
                       
                         H 
                         ′ 
                       
                        
                       
                         x 
                         ′ 
                       
                     
                     
                       2 
                        
                       p 
                     
                   
                 
               
               ] 
             
             . 
           
         
       
     
         [0057]    Furthermore, since the perspective image resulting from perspective transformation is an isosceles trapezium which is symmetrical, that is, the perspective image is symmetrical about a symmetrical axis of y′=H′/2, the coordinates in the original image corresponding to the pixel points in the perspective image may be calculated simply by calculating the coordinates for the part of y′&gt;H′/2 or y′&lt;H′/2 in the formulas and then deriving directly the coordinates in the original image corresponding to the pixel points in the other part of the perspective image due to the symmetry. 
         [0058]    For example, if the coordinates (x, y) of the pixel point in the original image corresponding to the coordinates (x′, y′) of the pixel point in the perspective image are determined, the coordinates (x, H−y) of the pixel point in the original image corresponding to the pixel point (x′, H′−y′) may be determined directly, and undoubtedly the effort of calculation can be reduced and the speed of calculation can be improved greatly because the coordinates in the original image corresponding to a part of the pixel points in the perspective image are determined due to the symmetry. 
         [0059]    An embodiment of the invention provides a method and device for generating a perspective image in which the form of inverse transformation is used under the principle of the area of a perspective image being smaller than that of an original image to thereby reduce the number of calculated pixel points and thus greatly reduce the effort of calculation, improve the speed at which the perspective image is generated and save a CPU resource as compared with a forward operation. 
         [0060]    The effort of calculation can be reduced and the precision of calculation can be improved greatly by simplifying an operation function, shifting to obviate a floating-point operation, taking x′ as an outer layer of cyclical nesting and obtaining directly the coordinates in the original image corresponding to the pixel points due to the symmetry, and as experimentally demonstrated, it takes less than 10 milliseconds for the ARM9 CPU at 192 MHz to generate a perspective image with W=240, H=H′=400, W′=120 and p=1200, which can fully accommodate a demand in practice. 
         [0061]    It shall be noted that the foregoing embodiments are merely illustrative of but not to limit the invention, the invention will not be limited to the examples described above and those technical solutions and modifications thereto without departing from the spirit and scope of the invention shall be encompassed in the scope of the claims of the invention.