Field of the Invention
The present invention relates generally to video coding, and more particularly to utilizing a spatially adaptive preprocessing filter for use in video coding.
Background of the Invention
Current standards, such as H.261, MPEG1, and MPEG2 provide compression of a digital video sequence by utilizing a block motion-compensated Discrete Cosine Transform, DCT, approach. This video encoding technique removes the redundancy present in a video sequence by utilizing a two-step process. In the first step, a block-matching, BM, motion estimation and compensation algorithm estimates the motion that occurs between two temporally adjacent frames. The frames are then compensated for the estimated motion and compared to form a difference image. By taking the difference between the two temporally adjacent frames, all existing temporally redundancy is removed. The information that remains is new information that was not compensated for in the motion estimation and compensation algorithm. This difference image is referred to as the displaced frame difference, DFD.
In the second step, the DFD image is transformed into a frequency domain using the DCT. The DCT has the property of compacting the energy of the DFD image into a few low frequency components. Further compression of the video sequence is obtained by limiting the amount of high frequency information encoded.
If noise is present in a video sequence, then the DFD image will also contain the difference of this noise. Since the noise is uncorrelated in the temporal direction, the energy of the noise present in the DFD image is actually double the noise energy present in any single frame. After applying the DCT, the noise present in the DFD results in an increase in the energy present in the high frequency components. The net effect is the compression technique is forced to use a large number of bits, as compared to the case when the noise is not present, to maintain a particular distortion in the decoded video. In other words, noise present in a video sequence prior to encoding, results in a large decrease in the compression efficiency of any compression technique.
Current approaches for removing noise from a video sequence are inadequate for two reasons. The first reason is that these approaches attempt to remove the noise from the intensity frames of the video sequence. Generally, this type of approach introduces artifacts into the video sequence that are then transferred to the DFD signal and interpreted by the video encoder as new information that must be encoded. In other words, these approaches can also reduce the compression efficiency of the video encoder. The second reason that current approaches are inadequate is that they tend to operate only in the temporal direction. That is, they filter along a single direction between frames. If averaging is used, then the parts of the video sequence that are in motion will be blurred. By blurring the moving objects the video sequence in general will be easier to encode. However, it will look substantially degraded to the viewer. Therefore, the current approaches to removing noise are unable to reduce the amount of information that must be encoded by the video encoder without substantially degrading the decoded video sequence.
Brief Description of the Drawings
FIG. 1. is a block diagram of a preferred embodiment of an apparatus for spatially adaptive filtering for video encoding in accordance with the present invention.
FIG. 2. is a flow diagram of a preferred embodiment of steps of a method for spatially adaptive filtering for video encoding in accordance with the present invention.
Detailed Description of Preferred Embodiments
The method and apparatus described below filter a video sequence prior the encoding process of a video sequence. Specifically, a method and apparatus are described wherein a spatially adaptive filter is used to remove noise directly from the Displaced Frame Difference, DFD, signal. This novel approach removes noise and miscellaneous high frequency components from the DFD signal without the introduction of the filtering artifacts characteristic of current techniques. By reducing the miscellaneous high frequency components the present invention is capable of reducing the amount of information that must be encoded by the video encoder without substantially degrading the decoded video sequence.
In order to describe the method and apparatus certain assumptions are made concerning the input video sequence. Specifically, the video source is assumed to be in a digital format where the number of pixels per row, the number of rows per frame, and the number of frames per second are known prior to processing. Each pixel represents both the luminance and chrominance components using 8 bit integer numbers which span from 0 to 255. As mentioned above, these assumptions are only made to help facilitate the description of the method and apparatus and should not be viewed as restrictions to applications where these assumptions do not hold.
FIG. 1, numeral 100 is a block diagram of a preferred embodiment of an apparatus for spatially adaptive filtering for video encoding in accordance with the present invention. The apparatus comprises a noise variance determiner (102), local variance determiner (104), noise visibility function determiner (106), Gaussian kernel determiner (108), and a convolver (110). Utilizing a DFD (120) signal, the noise variance determiner (102) calculates an estimate of the noise variance .sigma..sub.n.sup.2 (r) (126). Also utilizing the DFD (120) signal the local variance determiner determines an estimate of the local signal variance .sigma..sub..function..sup.2 (r) (128). Based on the local signal variance .sigma..sub..function..sup.2 (r) (128) and noise variance .sigma..sub.n.sup.2 (r) (126) estimates and a predetermined image type parameter .THETA.(130), the noise visibility function determiner determines a noise visibility parameter .upsilon.(.THETA.) (132) which controls the amount of filtering provide by the spatially adaptive preprocessing filter at pixel location (r) .tbd.(i,j). Specifically, the noise visibility parameter .upsilon.(.THETA.) (132) is used by the Gaussian kernel determiner (110) to determine a Gaussian filtering kernel that will provide the proper amount of local filtering based on the local SNR.
The apparatus may be embodied in computer software, a Digital Signal Processor, a gate array, an application specific integrated circuit, a computer diskette having a stored program to impart processing functionality for implementing the steps of the method by the computer, or a memory unit of a computer that includes a program to impart processing functionality for implementing the steps of the method by the computer.
Utilizing the DFD signal, the noise variance determiner (102) determines an estimate of the noise variance .sigma..sub.n.sup.2 (126). This is accomplished by first dividing the DFD signal into 16.times.16 blocks and calculating the energy contained in these blocks. It should be noted that if block matching, BM, is used in generating the DFD signal, then these energy calculations already exist. The energy is calculated using the following expression ##EQU1## where pixel location i,j is a member of block B.sub.m, M and N are the number of pixels contained in a row and column of block B.sub.m, and .sigma..sub.b.sup.2 (B.sub.m) is the energy contained in block B.sub.m. Once the energy, .sigma..sub.B.sup.2 (B.sub.m), is calculated for each block they are rank ordered from highest to lowest energy. The average of the bottom 25% values in this ranking is used as the estimate of the noise variance, .sigma..sub.n.sup.2 (126).
The local signal variance is calculated utilizing the noise variance estimate .sigma..sub.n.sup.2 (126) and a local variance .sigma..sub.l.sup.2 (r). It is known that the local DFD variance .sigma..sub.l.sup.2 (r) is the total of the local signal variance .sigma..sub..function..sup.2 (r) (128) plus the noise variance .sigma..sub.n.sup.2 (126).
Therefore, an estimate of the local signal variance is obtained by subtracting the noise variance estimate from the local DFD signal variance. This is demonstrated below
where ##EQU2## K and L define the local neighborhood that the local signal variance is calculated over. Specifically, the local signal variance .sigma..sub..function..sup.2 (r) (128) is calculated within a block that extends K rows above and below pixel (r).tbd.(i,j), as well as L columns to the left and right.
The visibility parameter .upsilon.(.THETA.) (132) which controls the amount of filtering provide by the spatially adaptive preprocessing filter at pixel location (r).tbd.(i,j), is calculated by the noise visibility function determiner. Based on the local signal variance .sigma..sub..function..sup.2 (r) (128) and noise variance .sigma..sub.n.sup.2 (r) (126) estimates and a predetermined image type parameter .THETA.(130), the noise visibility function determiner determines the noise visibility parameter using the following equation ##EQU3##
To reduce noise present in a DFD signal the predetermined image type parameter .THETA.(130) is typically set at a value of 0.01. For different types of image data the image type parameter .THETA. is adjusted to provide the visibility with a different response. For example, due to their sensitivity to over-smoothing as opposed to the presence of noise, intensity images would require the image type parameter .THETA. to increased when compared to the value used for a DFD signal.
Based on the noise visibility parameter .upsilon.(.THETA.) (132) the Gaussian kernal determiner (108) determines a Gaussian filtering kernel that will provide the proper amount of local filtering based on the local SNR. The response of the Gaussian kernel determiner (108) TO THE NOISE VISIBILITY PARAMETER .upsilon.(.THETA.) (132) is shown below ##EQU4## where (m,n) is the Gaussian filtering, (m,n) is a location in the filters support, and .sigma..sub.g.sup.2 is the variance of the filter. The support of the filter is determined prior to implementation. Typically, to reduce the number of operations required to be performed in the convolver (110), the support of the filter is 5 pixel rows by 5 pixel columns. The variance of the filter is also predetermined and along with the noise visibility parameter .upsilon.(.THETA.) (132) is used to control the amount of smoothing applied to the DFD by the filter.
The noise visibility parameter .upsilon.(.THETA.) (132) controls the amount of smoothing applied to the DFD by the filter, in the following way. If the noise variance .sigma..sub.n.sup.2 (r) (126) is small compared to the local signal variance .sigma..sub..function. (r) (128), than the noise visibility parameter .upsilon.(.THETA.) (132) is also be small. This results in a Gaussian filter g(m,n) with a narrow spatial response or a wide pass-band in the frequency domain. In other words, the filter g(m,n) would provide very little smoothing. This is the desired response, since the noise variance is small compared to the signal variance. For the case when the local signal variance is much smaller than the noise variance, g(m,n) will have a wide spatial response which would result in a narrow passband in the frequency domain. Again, this is the desired response, since the g(m,n) would provide smoothing to a very noisy DFD.
The convolver (110) actually carries out the filtering operation on the DFD signal. That is, the convolver (110) applies the Gaussian filter g(m,n) (138) to the DFD signal (120) through a convolution operation. The convolution operation is characterized by the following equation. ##EQU5## where DFD (140) is the preprocessed DFD signal.
FIG. 2, numeral 200 is a flow diagram of a preferred embodiment of a method for spatially adaptive filtering for use in video encoding. The first step is calculating the noise variance based on the DFD signal (202). Next, a local signal variance is determined based on the calculated noise variance and the DFD signal (204). Utilizing the local signal variance, noise variance, and a predetermined image type parameter, a noise visibility parameter is then calculated (206). A local Gaussian filter is determined based on the noise visibility parameter and a predetermined Gaussian filter variance parameter (208). Then, the local Gaussian filter is convolved with the DFD signal to produce the filtered DFD signal (210).