# 2D image scaling using cascaded polyphase FIR filter

Started by January 26, 2006
```Hi,

When looking at many of the video scalers and DSPs for consumer video, the
datasheets usually list several cascaded polyphase FIR filters.  They
usually supply software libraries that generate the filter coefficients
given a pair of numbers describing how much interpolation and decimation.

In attempting to get a much better understanding of basic DSP skills, I
started to build my own model of an image scaler.  I am attempting to use
a very small set of coefficients to mimic the constraints of a video
scaler implemented in an FPGA.  I figure with a typical FPGA I will have
enough internal SRAM to buffer 4 to 6 lines of video, so I could
potentially build a 6-tap filter.  Most of the standard low-pass windowed
filters are unsuited.  The Remez equiripple has an astoundingly bad main
lobe.  I've decided that least-squares gives a reasonable magnitude and
phase response.

Two questions:
1) Where can I find more information on the least-squares method (I have
Lyons 2004, Vaidyanathan 93, fliege 94) and I have a basic understanding
of curve-fitting.  I guess I don't understand what curve I'm trying to
find.  sinc?
2) Can somebody answer in simple terms how the DSP image scalers can work
with such a small set of coefficients?  e.g. assume a 512x512 source is to
be converted to a 1024x1024 image.  Interpolation x 2 with a 4-tap filter
will allow me to use an 8x8 set of coefficients.  Using the PM method, an
optimal filter should have 372x372 coefficients.  How do I get a good
looking image with far less than 372x372 coefficients?

Thanks,

--Mike

```
```"michaelle" <michaelle@belkin.com> wrote in message
news:2-KdnRjggK5EL0XenZ2dnUVZ_sCdnZ2d@giganews.com...
> Hi,
>
> When looking at many of the video scalers and DSPs for consumer video, the
> datasheets usually list several cascaded polyphase FIR filters.  They
> usually supply software libraries that generate the filter coefficients
> given a pair of numbers describing how much interpolation and decimation.
>
> In attempting to get a much better understanding of basic DSP skills, I
> started to build my own model of an image scaler.  I am attempting to use
> a very small set of coefficients to mimic the constraints of a video
> scaler implemented in an FPGA.  I figure with a typical FPGA I will have
> enough internal SRAM to buffer 4 to 6 lines of video, so I could
> potentially build a 6-tap filter.  Most of the standard low-pass windowed
> filters are unsuited.  The Remez equiripple has an astoundingly bad main
> lobe.  I've decided that least-squares gives a reasonable magnitude and
> phase response.
>
> Two questions:
> 1) Where can I find more information on the least-squares method (I have
> Lyons 2004, Vaidyanathan 93, fliege 94) and I have a basic understanding
> of curve-fitting.  I guess I don't understand what curve I'm trying to
> find.  sinc?
> 2) Can somebody answer in simple terms how the DSP image scalers can work
> with such a small set of coefficients?  e.g. assume a 512x512 source is to
> be converted to a 1024x1024 image.  Interpolation x 2 with a 4-tap filter
> will allow me to use an 8x8 set of coefficients.  Using the PM method, an
> optimal filter should have 372x372 coefficients.  How do I get a good
> looking image with far less than 372x372 coefficients?

I think the issue is more one of understanding video processing, artifacts,
etc.  Very large filters aren't common for a lot of very practical video

I believe it's typical to use very short spatial filters in one dimension.
So, there might be horizontal filters and there might be vertical filters
that operate somewhat separately.

Example for 2x interpolation:
(it is not typical to filter before zero-stuffing)
video line:   x1  0  x2  0  x3  0  x4  0  x5

Interpolator [1/2 1 1/2]

Result        x1  (x2+x1)/2  x2  (x3+x2)/2  x3  (x4+x3)/2  x4  (x5+x4)/2  x5

You would probably interpolate in the horizontal before interpolating in the
vertical just because the samples are more readily available and can be
generated sooner - probably implies the need for less memory.

What you mean by a "good looking image" is very important AND you probably
don't mean "image" when one considers motion effects.  For example, what
happens if the video is showing a scene with a telephone pole seen from a
fast-moving train?  or a high rise building with lots of vertical window
frames seen from a similar moving platform?  etc.

Fred

```
```
michaelle wrote:
>
> Hi,
>
> When looking at many of the video scalers ....blah blah blah

> Using the PM method, an
> optimal filter should have 372x372 coefficients.

optimal? I would suggest you invest in a dictionary and look that word
up.

> How do I get a good
> looking image with far less than 372x372 coefficients?

You might try a spline based algorithm for upscaling.

-jim

----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
```