Patent Publication Number: US-8111929-B2

Title: Method and system to detect and quantify blockiness in video files

Description:
FIELD OF THE INVENTION 
     The present invention relates generally to verification of media content. More specifically, it relates to a method and system to detect and quantify blockiness in video files. 
     BACKGROUND OF THE INVENTION 
     Media content is used in a variety of real-world applications today. Examples of media content can be audio and video files. There are certain features associated with the production and broadcasting of media content. Due to the use of new technologies, evolving industry standards and the use of open architecture in the development of media content, verification of features associated with the production and broadcasting of media content is essential for ensuring quality broadcasting of media content. As a result, media content developers, providers, broadcasters and operators need to carry out quality checks to verify media content. 
     Compression techniques are widely used to capture and transmit media content, especially digital video. Block-based transform coding is one of the compression techniques used in which each image frame of a digital video file is decomposed into rectangular regions called blocks and are transform coded. These image frames are then transmitted to a receiver. At the receiver, the coded frames are decoded and the blocks are re-assembled to reconstruct the image. A commonly used transform-coding technique is the Discrete Cosine Transform (DCT). One of the disadvantages of coding by using a block-based DCT transform is that the image is degraded during the coding process at high compression ratios. This is because the quantization noise is generally correlated within each block but not with other blocks. Consequently, the decoded image at the receiver shows discontinuities (image intensity variation) near the adjacent block boundaries. This feature is known as blockiness and is the most common distortion effect in block-based compression techniques, e.g., JPEG, MPEGx and H.26x. Detection of blockiness is one of the most important quality checks related to digital capture and transmission of the images of video files 
     A method for detecting and measuring blockiness is described in the non-patent reference: “Image Blockiness Evaluation Based on Sobel Operator” by C. Perra, F. Massidda and D. D. Giusto. This paper appears in ICIP 2005, International Conference on Image Processing, 2005: Genoa, Italy; Publication date: 11-14 Sep. 2005. The following paragraph describes the method followed in this reference to detect and measure blockiness. 
     A convolution process is performed between the luma part of an image and the two Sobel masks M x  and M y , which are defined as follows:
 
 M   x [3][3]={{−1,0,1},{−2,0,2},{−1,0,1}};
 
 M   y [3][3]={{−1,−2,−1},{0,0,0},{1,2,1}}.
 
The luma part of the image is the achromatic part of the image that is used for determining blockiness in the image. The convolution process is a mathematical operation used by a discrete differentiation operator to calculate 2-dimensional approximations of gradients of image intensity at each pixel point of a digital image. The discrete differentiation operator is known as the Sobel operator. In mathematical terms, the gradient of image intensity at each pixel point is a vector pointing in the direction of largest possible intensity increase and having a length specifying the rate of change of intensity in that direction. Gradient approximation at each pixel point is specified by two values: an approximate value of the derivative of image intensity in the horizontal direction and an approximate value of the derivative of image intensity in the vertical direction. The Sobel operator operates the two Sobel masks M x  [3][3] and M y  [3][3] on each pixel point to calculate gradient values corresponding to the pixel point in the horizontal and vertical direction respectively. M x  and M y  are 3×3 discrete filters which are convolved with a two-dimensional array containing a pixel point value and 8 pixel point values around it for calculating the gradient values corresponding to that pixel point.
 
     The gradient values for a pixel point (i,j) of an image I are calculated as follows: 
     Gradient value of image intensity in the horizontal direction D x (i,j)=I(i,j)*M x (i,j) 
     Gradient value of image intensity in the vertical direction D y (i,j)=I(i,j)*M y (i,j) where * is the convolution operator. Finally, gradient values for the entire image I in the horizontal and vertical direction are obtained as multi-dimensional arrays D x  and D y  respectively. D x  and D y  are then divided into N×N blocks (N=8) to determine blockiness caused by an 8×8 DCT transform. A blockiness detection algorithm is then applied to each block to calculate a blockiness index for the block. The blockiness index is a combination of two measures. The first measure quantifies the intensity variation of pixels at the block boundary. The second quantifies the intensity variation of pixels inside the block. 
     The intensity variation measures are calculated as follows: 
               s   1     =       1   N     ⁢     {         ∑       (     i   ,   j     )     ∈     Ω     1   ⁢   V           ⁢              D   x     ⁡     (     i   ,   j     )              max   ⁡     (     D   x     )           +       ∑       (     i   ,   j     )     ∈     Ω     1   ⁢   H           ⁢              D   y     ⁡     (     i   ,   j     )              max   ⁡     (     D   y     )             }                     s   2     =       1     N   2       ⁢       ∑       (     i   ,   j     )     ∈     Ω   2         ⁢       D   ⁡     (     i   ,   j     )         max   ⁡     (   D   )                   
where s 1  signifies the intensity variation at the block boundary, s 2  signifies the intensity variation inside the block, Ω 1V  denotes the pixels along the vertical boundaries of the block, Ω 1H  the pixels along the horizontal boundaries of the block and Ω 2  the inner pixels of the block,
 
     D(i,j)=√{square root over (D x (i,j) 2 +D y (i,j) 2 )}{square root over (D x (i,j) 2 +D y (i,j) 2 )} is the gradient magnitude at the pixel point (i,j), and N, N 2  are two normalization factors. (N, N 2  are the number of elements in the sums s 1  and s 2 ). 
     Once s 1  and s 2  are calculated, S, which is the blockiness index for the block, is calculated by using the following formula: 
     
       
         
           
             S 
             = 
             
                
               
                 
                   
                     s 
                     1 
                     λ 
                   
                   - 
                   
                     s 
                     2 
                     λ 
                   
                 
                 
                   
                     s 
                     1 
                     λ 
                   
                   + 
                   
                     s 
                     2 
                     λ 
                   
                 
               
                
             
           
         
       
     
     Thus blockiness index for each block is calculated and a final blockiness value for the image is calculated using the blockiness indexes of all the blocks. 
     However, the formula given above does not provide accurate measures of s 1  and s 2 . In some conditions, for example, when the intensity variations of pixels inside and outside the block are low, the value of the blockiness index calculated by the formula given above is incorrect or indeterminate. Additionally, if there is true intensity variation at the block boundary or inside the block, the formula gives inaccurate results. Based on the above, there is need for a method to accurately detect and quantify blockiness in a video file. 
     SUMMARY OF THE INVENTION 
     The present invention discloses a method for detecting and quantifying blockiness in a video file. The method includes segmenting image frame of the video file into one or more blocks. The method also includes comparing one or more parameters associated with the one or more blocks with one or more threshold values, where the threshold values signify the intensity variation characteristics of the one or more blocks. Based on the comparison, one or more intensity gradients are determined for the one or more blocks. Further, a blockiness index is computed for the one or more block, based on the one or more intensity gradients. Finally, the method includes determining a level of blockiness for the one or more image frames of the video file. 
     The present invention also discloses a system for detecting and quantifying blockiness in a video file. The video file consists of one or more image frames that are divided into one or more blocks. The system includes a decoder that is configured to segment the one or more frames into one or more blocks. The system also includes a comparator for comparing one or more parameters associated with the one or more blocks with one or more threshold values. Additionally, the system includes a processor. The processor is configured to determine one or more intensity gradients for the one or more blocks, to compute the blockiness index of the one or more blocks, and assign a level of blockiness to the one or more frames, based on the blockiness index. 
    
    
     
       BRIEF DESCRIPTION OF THE FIGURES 
       The accompanying figures, where like reference numerals refer to identical or functionally similar elements throughout the separate views, and which, together with the detailed description below, are incorporated in and form part of the specification, serve to further illustrate various embodiments and explain various principles and advantages, all in accordance with the present invention. 
       The embodiments of the invention will hereinafter be described in conjunction with the appended drawings, provided to illustrate and not to limit the invention, wherein like designations denote like elements, and in which: 
         FIG. 1  is a functional block diagram illustrating the methodology known in the art for compressing, transmitting and reconstructing a digital image file; 
         FIG. 2  is a functional block diagram illustrating a process for calculating the blockiness index of an image, as practiced in one of the prior art methods; 
         FIG. 3  is a diagram illustrating the convolution process used to calculate the blockiness index in the prior art method of  FIG. 2 ; 
         FIG. 4  is a flowchart illustrating a method for detecting and quantifying blockiness in a video file in accordance with an embodiment of the present invention; 
         FIG. 5  is a block diagram illustrating the software modules used to detect and quantify blockiness in a video file in accordance with an embodiment of the present invention; 
         FIGS. 6 and 7  is a flowchart depicting a method for detecting and quantifying blockiness in a video file in accordance with another embodiment of the present invention; and 
         FIG. 8  is a diagram that illustrates the tables used to calculate the blockiness value of a frame image, based on the blockiness values obtained for each block, in accordance with an embodiment of the present invention. 
     
    
    
     DETAILED DESCRIPTION OF THE INVENTION 
     Before describing in detail the particular method and system for detecting and quantifying blockiness in a video file, in accordance with various embodiments of the present invention, it should be observed that the present invention utilizes a combination of method steps and system components related to the method for detecting and quantifying blockiness in a video file. Accordingly, the system components and method steps have been represented, where appropriate, by conventional symbols in the drawings, showing only those specific details that are pertinent for an understanding of the present invention, so as not to obscure the disclosure with details that will be readily apparent to those with ordinary skill in the art, having the benefit of the description herein. 
     In this document, the terms ‘comprises,’ ‘comprising,’ ‘includes,’ ‘including,’ or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, article, system or apparatus that comprises a list of elements does not include only those elements, but may include other elements not expressly listed or inherent to such a process, article or apparatus. 
     The term ‘another’, as used in this document, is defined as at least a second or more. The term ‘includes’, as used herein, is defined as comprising. 
       FIG. 1  is a functional block diagram illustrating the methodology known in the art for compressing, transmitting and reconstructing a digital image file. The block diagram  100  includes functional blocks that show an original image file  102 , a transformed image file  104 , and compressed image data  106  before transmitting the image data. At the receiving end of the transmitted image data, the block diagram  100  shows received compressed image data  108 , decoded transform coefficients  110 , and decompressed image file with blockiness  112 . The transformed image file  104  is obtained from the original image file  102  by applying transformation algorithms to the original image file  102 . Transformation algorithms are compression algorithms that are used to compress image files. A commonly used transform algorithm for compressing image files is the Discrete Cosine Transform (DCT). The DCT is a lossy algorithm, which has good data compaction properties. In the DCT algorithm, an image file is divided into N×N blocks of pixels. The DCT is then applied to the image and the results are quantized and entropy coded. Typically, the transform is applied to each block of 8×8 pixels. After the transformation is applied to the original image file  102 , the transformed image file  104  is represented as a multi-dimensional array comprising 8×8 blocks of transform coefficients containing frequency component values that increase along the vertical and horizontal axis. The transformed image file  104  is then encoded to obtain the compressed image data  106 . Encoding is performed to reduce the size of the data to be transmitted, but this encoding is lossy, and results in precision loss in the image file. Thereafter, the compressed image data  106  is transmitted and received at the receiving end, after which the compressed image data  108  is decoded to obtain 8×8 blocks of decoded transform coefficients  110 . Inverse DCT is then applied to the transform coefficient array to obtain the reconstructed image file with blockiness  112 . 
       FIG. 2  is a functional block diagram illustrating a process for calculating the blockiness index of an image as practiced in one of the prior art methods. Blockiness being an artifact that is responsible for the degradation of an image file in block-transform coding and transmission, the detection of blockiness is an important part of checking received image/video files. As shown in  FIG. 2 , convolution is performed on the decompressed image file with blockiness  202 . The image file  202  is convolved with two Sobel masks that are defined as follows:
 
 M   x [3][3]={{−1,0,1},{−2,0,2},{−1,0,1}};
 
 M   y [3][3]={{−1,−2,−1},{0,0,0},{1,2,1}}.
 
     The convolution results in an image file having gradient approximations  204  for each pixel point in the image. The gradient approximations are approximations of gradients of image intensity at each pixel point in the image. The horizontal component of gradient is a derivative of the image intensity at a pixel point in the horizontal direction, and the vertical component of gradient is a derivative of the image intensity at a pixel point in the vertical direction. 
     The gradients for the image calculated as a multi-dimensional array of values are denoted as:
 
Array of gradient values in the horizontal direction ( D   x )= I*M   x   (1)
 
Array of gradient values in the vertical direction ( D   y )= I*M   y   (2)
 
where * is the convolution operator.
 
     The intensity gradients (D x , D y ) are then decomposed into 8×8 non-overlapping blocks to obtain the decomposed image file  206 . The sets Ω 1V , Ω 1H  and Ω 2  are considered for each 8×8 block. Ω 1V  denotes the pixels along the vertical boundaries of the block, Ω 1H  the pixels along the horizontal boundaries of the block, and Ω 2  the inner pixels of the block. Using the sets Ω 1V , Ω 1H  and Ω 2 , the blockiness index of the image  208  is calculated as follows: 
     The image intensity variation at the block boundary is calculated as: 
     
       
         
           
             
               
                 
                   
                     s 
                     1 
                   
                   = 
                   
                     
                       1 
                       
                         N 
                         1 
                       
                     
                     ⁢ 
                     
                       { 
                       
                         
                           
                             ∑ 
                             
                               
                                 ( 
                                 
                                   i 
                                   , 
                                   j 
                                 
                                 ) 
                               
                               ∈ 
                               
                                 Ω 
                                 
                                   1 
                                   ⁢ 
                                   V 
                                 
                               
                             
                           
                           ⁢ 
                           
                             
                                
                               
                                 
                                   D 
                                   x 
                                 
                                 ⁡ 
                                 
                                   ( 
                                   
                                     i 
                                     , 
                                     j 
                                   
                                   ) 
                                 
                               
                                
                             
                             
                               max 
                               ⁡ 
                               
                                 ( 
                                 
                                   D 
                                   x 
                                 
                                 ) 
                               
                             
                           
                         
                         + 
                         
                           
                             ∑ 
                             
                               
                                 ( 
                                 
                                   i 
                                   , 
                                   j 
                                 
                                 ) 
                               
                               ∈ 
                               
                                 Ω 
                                 
                                   1 
                                   ⁢ 
                                   H 
                                 
                               
                             
                           
                           ⁢ 
                           
                             
                                
                               
                                 
                                   D 
                                   y 
                                 
                                 ⁡ 
                                 
                                   ( 
                                   
                                     i 
                                     , 
                                     j 
                                   
                                   ) 
                                 
                               
                                
                             
                             
                               max 
                               ⁡ 
                               
                                 ( 
                                 
                                   D 
                                   y 
                                 
                                 ) 
                               
                             
                           
                         
                       
                       } 
                     
                   
                 
               
               
                 
                   ( 
                   3 
                   ) 
                 
               
             
           
         
       
     
     The image intensity variation inside the block is calculated as: 
                     s   2     =       1     N   2       ⁢       ∑       (     i   ,   j     )     ∈     Ω   2         ⁢       D   ⁡     (     i   ,   j     )         max   ⁡     (   D   )                     (   4   )                 where   ⁢           ⁢     D   ⁡     (     i   ,   j     )         =             D   x     ⁡     (     i   ,   j     )       2     +         D   y     ⁡     (     i   ,   j     )       2                 (   5   )               
and D(i,j) signifies the gradient magnitude at each pixel point.
 
     N 1 , N 2  are two normalization factors (N 1 , N 2  are the number of elements in the sums s 1  and s 2 ). 
     In the equations (3) and (4): 
     max(D x )=The maximum gradient value from the gradient values of the pixels of the vertical boundaries (Ω 1V ) of the block 
     max(D y )=The maximum gradient value from the gradient values of the pixels of the horizontal boundaries (Ω 1H ) of the block 
     max(D)=The maximum gradient value from the gradient values of the inner pixels of (Ω 2 ) of the block 
     Once s 1  and s 2  are calculated, S, which is the blockiness index of the block, is calculated by using the following formula: 
     
       
         
           
             
               
                 
                   S 
                   = 
                   
                      
                     
                       
                         
                           s 
                           1 
                           λ 
                         
                         - 
                         
                           s 
                           2 
                           λ 
                         
                       
                       
                         
                           s 
                           1 
                           λ 
                         
                         + 
                         
                           s 
                           2 
                           λ 
                         
                       
                     
                      
                   
                 
               
               
                 
                   ( 
                   6 
                   ) 
                 
               
             
           
         
       
     
     The exponent λ is useful for controlling the slope of the index S, in order to adjust the proposed blockiness measure with human perception tests. 
     The exponent λ in this method is determined experimentally to be 2. The range of S is [0,1] where zero corresponds to the absence of blockiness distortion while one corresponds to an image severely affected by blockiness. 
     Finally, the blockiness value of the image is calculated using the average of blockiness indexes of all the blocks. 
       FIG. 3  is a diagram illustrating the convolution process used in the calculation of blockiness index in the prior art method of  FIG. 2 . The input image file  302  is divided into multiple sets of 9 pixels each, where each set contains a pixel point and eight pixels in a 3×3 region around the pixel point. Each set of 9 pixels is represented by a (3×3) coefficient array containing pixel values of a pixel point and eight pixels around the pixel point. As shown in  FIG. 3 , I 3×3  is such a coefficient array. The convolution process involves convolving the array I 3×3  with a Sobel operator M 3×3  to obtain an equivalent array (I×M) 3×3 . The equivalent array (I×M) 3×3  is comprised of gradient values of image intensity for the set of 9 pixels represented by the array I 3×3 . Thus, the output image file  304  includes gradient approximation values of image intensity at each pixel point (in both the horizontal and vertical directions) in the image. In mathematical terms, gradient of image intensity at each pixel point is a vector pointing in the direction of largest possible intensity increase and having a length specifying the rate of change of intensity in that direction. However, for calculating an accurate gradient value, the image intensity function should be continuous in nature. In a digital image, the intensity function is known only at discrete pixel points and gradients of image intensity can be calculated by assuming an image intensity function for the digital image sampled at the pixel points. Hence, the gradient values obtained are approximations rather than accurate values. 
       FIG. 4  is a flowchart illustrating a method for detecting and quantifying blockiness in a video file, in accordance with an embodiment of the present invention. At step  402 , each frame of the video file is segmented into one or more blocks. In an embodiment of the present invention, each frame is segmented into 8×8 blocks of sub-pixels. Thereafter, for each block, one or more gradients of the image intensity are calculated at each image point. The one or more intensity gradients are the approximations of image intensity calculated as described in the description of  FIG. 2 . In an embodiment, the one or more intensity gradients include an array of gradient values in the horizontal direction (D x ) and an array of gradient values in the vertical direction (D y ) for each pixel point in a block. At step  404 , one or more intensity gradients associated with each block are compared with one or more threshold values. The one or more threshold values are pre-defined values that are compared with the one or more intensity gradients to distinguish true intensity variation from blockiness. In an embodiment, the one or more threshold values are a plain threshold value, a first edge threshold value and a second edge threshold value. The plain threshold value is an experimentally determined value that signifies plain behavior, i.e. low intensity variation. The first edge threshold value is an experimentally determined value that represents true edgy behavior, i.e. high intensity variation along the boundary pixels of the block. The second edge threshold value is an experimentally determined value that represents true edgy behavior, i.e. high intensity variation inside the block. In an example, at step  404 , the maximum gradient value from the array of horizontal gradient values (D x ) of the vertical boundary pixels (Ω 1V ) of a block is compared with the first edge threshold value to determine true intensity variation along the vertical boundary pixels of the block. In this case, if the maximum gradient value is greater than the first edge threshold value, there is a true edge along the vertical boundary pixels of the block. Depending on the result of the comparisons at step  404 , a set of conditions are established. These set of conditions are used for assigning one or more intensity variation parameters for each block at step  406  as described below. In an embodiment, the one or more intensity variation parameters are the image intensity variation at the block boundary (s 1 ) and the image intensity variation inside the block (s 2 ). At step  406 , the one or more intensity variation parameters for each block are determined. s 1  is computed using equation (3) and s 2  is computed using equation (4). s 1  and s 2  are computed subject to the set of conditions established at step  404 . This is done because the values of s 1  and s 2  are finally used in equation (6) for calculating the blockiness index (S) for a block at step  408 . To get an accurate value of S, the set of conditions are used to assign values of s 1  and s 2  in equation (6), overriding the values calculated using equations (3) and (4). In an example, a zero value is assigned to s 1 , if the intensity variation at the block boundary is found to be negligible, as a result of the maximum gradient value of the horizontal and vertical block boundary pixels (Ω 1H  and Ω 1V ) being less than the plain threshold value. In another example, if the maximum gradient value from the array of horizontal gradient values (D x ) of the vertical boundary pixels of a block (Ω 1V ) is greater than the first edge threshold value, there is true intensity variation along the vertical block boundary pixels. Hence, s 1  is calculated from equation (3) using only the array of vertical gradient values (D y ). The blockiness index is a measure of blockiness in a block. The value of the blockiness index ranges from 0 to 1. Based on the blockiness index for each block in a frame, at step  410  a level of blockiness is determined for each frame. The level of blockiness for a frame is a comparative measure of blockiness with respect to blockiness in other frames of the video file. 
       FIG. 5  is a block diagram illustrating the software modules used to detect and quantify the blockiness in a video file, in accordance with an embodiment of the present invention. The Block diagram shows a decompressed video file  502 , a decoder  504 , a comparator  506  and a processor  508 . The decompressed video file  502  is the file at the receiver that has been obtained from a compressed image file received and decoded by using inverse transform algorithms. Each frame of the decompressed video file  502  is then segmented into one or more blocks by the decoder  504 . The comparator  506  compares one or more intensity gradients associated with each of the one or more blocks with one or more threshold values. The one or more threshold values represent pre-defined intensity variation values. The output of the comparator is a set of conditions that is required to calculate the intensity variation parameters of a block. The processor  508  determines the intensity variation parameters of each of the one or more blocks, based on the set of conditions obtained by the comparison in the comparator  506 . The processor  508  is also configured to calculate a blockiness index for each of the one or more blocks and assign a level of blockiness to each of one or more frames of the video file  502 . In an embodiment, the processor  508  includes a selector for selecting blocks from the one or blocks having a blockiness index that is greater than a predefined blockiness value. Based on the number of blocks having blockiness index greater than the predefined blockiness value, the proportion of number of blocks having blockiness index greater than the predefined blockiness value is calculated. This proportion is known as the blockiness measure of a frame. In another embodiment, the software modules used to detect and quantify blockiness in a video file also include a memory unit for storing the one or more threshold values, the one or more intensity gradients, the one or more intensity variation parameters and the values of blockiness index for each of the one or more blocks of a frame. 
       FIGS. 6 and 7  illustrate a flowchart depicting a method for detecting and quantifying blockiness in a video file, in accordance with another embodiment of the present invention. Blockiness is the presence of discontinuities (intensity variation) at block boundaries resulting due to DCT compression of digital images. At step  602 , each frame of the video file is segmented into one or more blocks. In an embodiment, each block is composed of (8×8) pixels. The video file, in this case, is a file that has been compressed by a media content developer by using compression algorithms. The compression algorithms used are required to comply with compression standards such as JPEG, MPEG, H.264, etc. A commonly used algorithm for compression is the DCT algorithm, in which each frame of the video file is split into blocks of 8×8 pixels. 
     At step  604 , one or more intensity gradients for each block of each frame are computed. These gradients are approximations of magnitude and direction of increase of image intensity at each pixel point. In one example, the gradient arrays D x , D y  and D for the pixels in a block are calculated, as described by the equations (1), (2) and (5). From the values in the arrays D x , D y  and D, maximum values of intensity gradients are calculated as follows: 
     A first gradient value, a second gradient value and a third gradient value are calculated for each 8×8 block. The sets Ω 1V , Ω 1H  and Ω 2  are taken into consideration for calculating the first gradient value, the second gradient value and the third gradient value as described below. Ω 1V  denotes the pixels of the vertical boundaries of the block, Ω 1H  the pixels of the horizontal boundaries of the block, and Ω 2  the inner pixels of the block. 
     First gradient value max(D x ): The maximum gradient value from the gradient values of the pixels of the vertical boundaries (Ω 1V ) of the block. 
     Second gradient value max(D y ): The maximum gradient value from the gradient values of the pixels of the horizontal boundaries (Ω 1H ) of the block. 
     Third gradient value max(D): The maximum gradient value from the gradient values of the inner pixels of (Ω 2 ) of the block. 
     For accurate detection of blockiness for each 8×8 block, a clear distinction has to be made between intensity variations due to blockiness and true intensity variations (also known as true edges) inside the block and at the block boundary. Hence, at step  606 , the maximum values of the one or more intensity gradients are compared with one or more threshold values. The one or more threshold values are pre-defined values that are compared with the first gradient value, the second gradient value and the third gradient value to distinguish true intensity variation from blockiness. In an embodiment, the one or more threshold values are a plain threshold value, a first edge threshold value and a second edge threshold value. The plain threshold value is an experimentally determined value that signifies plain behavior, i.e. low intensity variation. For example, if the maximum gradient value among the horizontal gradient values of the boundary pixels of a block is less than the plain threshold value, it means there is low intensity variation of the boundary pixels in the horizontal direction. The first edge threshold value is an experimentally determined value that represents true edgy behavior, i.e. high intensity variation along the boundary pixels of the block. For example, if the maximum gradient value among the horizontal gradient values of the vertical boundary pixels of a block is greater than the first edge threshold value, it means that there is a true edge along the vertical boundary pixels of the block. Similarly, the second edge threshold value is an experimentally determined value that represents true edgy behavior, i.e. high intensity variation inside the block. For example, if the maximum gradient value among the gradient magnitude values of the pixels inside a block is greater than the second edge threshold value, it means that there is a true edge inside the block. In an embodiment of the present invention, the maximum value of the plain threshold value, the first edge threshold value and the second edge threshold value are experimentally determined to be 6, 140 and 200, respectively. These threshold values have been determined based on experiments over a set of video streams. 
     In an embodiment, the first gradient value max(D x ), the second gradient value max(D y ) and the third gradient value max(D) are compared with the plain threshold value, the first edge threshold value and the second edge threshold value as follows:
         max(D x ), max(D y ) and max(D) are individually compared with the plain threshold value.   max(D x ) and max(D y ) are individually compared with the first edge threshold value.   max(D) is compared with the second edge threshold value.       

     Based on these comparisons a set of conditions are established for calculating an edge intensity variation parameter (s 1 ) and an inner intensity variation parameter (s 2 ). s 1  represents image intensity variation at the block boundary and s 2  represents image intensity variation inside the block. Thereafter, at step  610 , the blockiness index (S) of each block is calculated from equation (6) by plugging in the values of s 1  and s 2  for the block, subject to the set of conditions established at step  608 . 
     The blockiness index (S) for the block is calculated using equation (3), equation (4) and the set of conditions that are established based on the comparisons done at step  606 . In an embodiment of the present invention, the edge intensity variation parameter (s 1 ) and the blockiness index (S) is calculated using equation (3) and equation (6) subject to the following four conditions: 
     Condition I. If the first gradient value max(D x ) is less than the plain threshold value, the image intensity variation at the block boundary in the horizontal direction is negligible. Hence s 1  is calculated from equation (3) using only the second gradient value max(D y ) and the gradient values in the vertical direction D y  (i,j). Similarly, if the second gradient value is less than the plain threshold value, s 1  is calculated from equation (3) using the first gradient value max(D x ) and the gradient values in the horizontal direction D x (i,j) 
     Condition II. If both the first gradient value and the second gradient value are less than the plain threshold value, to calculate an accurate value of the blockiness index (S) for the block, s 1  is set to zero in equation (6). This is because if the intensity variation inside the block (s 2 ) is found to be zero from equation (4), then even a small value of s 1  will give an inaccurately high of value of S as per equation (6). 
     Condition III. If the first gradient value is higher than the first edge threshold value, the intensity variation along the vertical block boundary pixels is a true intensity variation in the image. Hence, s 1  is calculated from equation (3) using only the gradient values for the horizontal block boundary pixels i.e. second gradient value max(D y ) and gradient values in the vertical direction D y (i,j). Similarly, if the second gradient value is higher than the first edge threshold value, s 1  is calculated from equation (3) using only the first gradient value max(D x ) and gradient values in the horizontal direction D x (i,j) 
     Condition IV. If both the first gradient value and the second gradient value are higher than the first edge threshold value, there should not be any blockiness at the boundary pixels of the block. Hence, s 1  for the block is set to zero in equation (6). Also, to calculate an accurate value of the blockiness index for the block, the blockiness index (S) for the block is set to zero. This is because since s 1  is zero, any value of s 2  will give an inaccurate blockiness value of 1 as per equation (6). 
     In another embodiment of the present invention, the inner intensity variation parameter (s 2 ) and the blockiness index (S) is calculated using equation (4) and equation (6), subject to the following condition: If the third gradient value is higher than the second edge threshold value, there is true intensity variation inside the block. Hence, to calculate an accurate value of blockiness, s 2  as well as the blockiness index (S) for the block is set to zero in equation (6). 
     In yet another embodiment of the present invention, if the values of s 1  and s 2  are zero, the value of blockiness index from equation (6) is indeterminate, though the accurate value should be zero. Hence, in this embodiment, the value of blockiness index (S) is set to zero. 
     At step  612 , the average value of the blockiness index of all the blocks in a frame is calculated after calculating the blockiness indexes of all the blocks in a frame. 
     Thereafter, at step  702 , the proportion of number of blocks with a blockiness index that is greater than a pre-defined blockiness value (blockiness measure) is calculated for each frame. In one example, Table 1, shown in  FIG. 8 , can be used to calculate the blockiness measure. In this example, the pre-defined blockiness value is taken as 0.4. Thus, the blockiness measure is calculated as:
 
(count 3+count 4+count 5+count 6+count 7)/total number of blocks  (7)
 
     At step  704 , the blockiness value of each frame is calculated by using the average value of the blockiness index and the blockiness measure of the frame. For example, an equation for calculating the blockiness value of each frame is experimentally determined to be
 
Blockiness value=(Blockiness measure+3×average value of blockiness index)/4  (8)
 
The blockiness value calculated by using equation (8) is between 0 and 1.
 
     At step  706 , the blockiness value of each frame is used to assign a level of blockiness to each frame. In one example, the formula used to assign a blockiness level to a frame, based on the blockiness value, is as follows: 
     Blockiness level of frame=floor (((blockiness value of frame×100)+5.0)/10), where floor gives the nearest integer. For example, floor (31/10)=3. The ranges of the one or more levels of blockiness, corresponding to this equation, are listed in Table 2 that is shown in  FIG. 8 . 
     Various embodiments, as discussed above, provide a method and system for detecting and quantifying blockiness in video files. The method automatically segments image frames of a video file into blocks. Thereafter, the method computes the blockiness index of each block of an image frame, and determines a blockiness value for each frame. Then the method determines a level of blockiness for each frame of the video file. The blockiness level of a frame, which is a comparative measure of blockiness with respect to other frames, can have a value between 0 and 100. Zero value of a blockiness level indicates no blockiness in a frame. The higher the blockiness level, the higher is the blockiness content in the frame. The blockiness values provided by this method are more accurate, as compared to prior art methods. Additionally, this method ensures that the blockiness levels calculated are not indeterminate for corner cases. Examples of corner cases include cases where either the variation of image intensity inside the block or outside the block, or both, is low. Examples of corner cases also include cases where there is true intensity variation at the boundary edges of a block in a frame or inside the block. 
     The method and system for detecting and quantifying blockiness in video files, as described in the present invention, may be embodied in the form of a computer system. Typical examples of a computer system include a general-purpose computer, a programmed microprocessor, a micro-controller, a peripheral integrated circuit element, and other devices or arrangements of devices, which are capable of implementing the steps that constitute the method of the present invention. 
     The computer system comprises a computer, an input device, a display unit and the Internet. The computer comprises a microprocessor, which is connected to a communication bus. The computer also includes a memory, which may be a Random Access Memory (RAM) and Read Only Memory (ROM). The computer system also comprises a storage device, which can be a hard disk drive or a removable storage drive such as a floppy disk drive, an optical disk drive, and the like. The storage device can also be other similar means for loading computer programs or other instructions into the computer system. 
     The computer system executes a set of instructions that are stored in one or more storage elements to process input data. The storage elements may also hold data or other information, as desired. The storage element may be in the form of an information source or a physical memory element present in the processing machine. Exemplary storage elements include a hard disk, a DRAM, an SRAM and an EPROM. The storage element may be external to the computer system, and connected to or inserted into the computer, to be downloaded at or prior to the time it is used. Examples of such external computer program products are computer-readable storage mediums such as CD-ROMS, Flash chips, floppy disks, and the like. 
     The set of instructions may include various commands that instruct the processing machine to perform specific tasks, such as the steps that constitute the method of the present invention. The set of instructions may be in the form of a software program. The software may be in various forms such as system software or application software. Further, the software may be in the form of a collection of separate programs, a program module with a larger program, or a portion of a program module. The software may also include modular programming in the form of object-oriented programming. The software program with the set of instructions can be embedded in a computer program product, for use with a computer, with the computer program product comprising a computer-usable medium that has a computer-readable program code embodied therein. Processing of input data by the processing machine may be in response to users&#39; commands to the results of previous processing, or in response to a request made by another processing machine. 
     The modules described herein may include processors and program instructions for implementing the functions of the modules described herein. Some or all the functions could be implemented by a state machine that has no stored program instructions, or in one or more application-specific integrated circuits (ASICs), in which each function or some combinations of certain of the functions are implemented as custom logic. 
     In the foregoing specification, the invention and its benefits and advantages have been described with reference to specific embodiments. However, one with ordinary skill in the art would appreciate that various modifications and changes can be made, without departing from the scope of the present invention, as set forth in the claims. Accordingly, the specification and figures are to be regarded in an illustrative rather than a restrictive sense, and all such modifications are intended to be included within the scope of the present invention. The benefits, advantages, solutions to problems, and any element(s) that may cause any benefit, advantage or solution to occur or become more pronounced are not to be construed as critical, required or essential features or elements of any or all the claims. The invention is defined solely by the appended claims, including any amendments made during the pendency of this application and all equivalents of those claims, as issued.