# polyphase sample rate conversion with non-integer factor

I want to do sample rate conversion by subsequently upsampling with factor I=5, and then downsampling with factor D=9.

I have designed a nyquist sample rate conversion filter h() of length M, with matlab's filterbuilder tool for interpolation factor I=5, and decimation factor D=9. Since D > I, I have chosen the normalized cutoff frequency of the filter to be at 1/9, by setting "Band" under filter specifications to 9.

Then I compute I polyphase filters pk(n), which have length K=M/I by sampling h() according to:

pk(n) = h(k + n*I), for k=0,...,I-1 and n=0,...,K-1.

Then I only compute the output samples for each polyphase filter, which are sampled by the downsampling operation. In other words, I compute the output y[m], by sampling the outputs of the polyphase filters yk[] according to:

y[m] =   yk[ floor( m * D / I  ) ]
k    =   ( m * D ) modulo I


Thus, I do not compute samples of yk[] that are not used in the output.

I apply these polyphase filter's first to do sample rate conversion for the rows of the image. Then I apply the same filters to do sample rate conversion for the columns.

However, I get a distorted output image which still, clearly contains alias:

Does anyone know If I'm conceptually doing anything wrong?

• What do mean that you set "Band" to "9". What exactly did you do when you designed the filter? – Jim Clay Aug 15 '13 at 18:02
• In the matlab command line I typed "filterbuilder", then I selected "Nyquist" then a menu pops up in which you can specify filter options: "Band": 9, "Impulse response": FIR, "Filter order mode": minimum, "Filter Type": Sample-rate converter, "Interpolation Factor": 5, "Decimation Factor": 9. I leave the rest of the options to their default settings. As far as I understood "Band" is the inverse of the cutoff frequency. – Luc Aug 15 '13 at 20:52

Your approach seems conceptually sound. I suspect that the problem is one of two things: 1) you have implemented it incorrectly, 2) Your filter bandwidth is too wide.

You are implementing the "smart" approach in that you are doing it the computationally efficient way. I would try doing it the dumb way (insert I-1 zeroes between every sample, filtering with the entire filter, get rid of the extra samples) to verify your implementation and to see if the filter itself is the problem. You can verify your implementation by comparing your resulting samples against the samples produced by the dumb approach. After you have filtered the upsampled data one of the sample "phases" (there are "D" phases whose start samples are samples 0...D-1) should be the same as the smart approach's results. If not, something is wrong in your implementation of either the smart or dumb approach.

If the results do match, then the problem is your filter. You need to look closely at the bandwidth to make sure that it isn't too wide. Since D > I the ideal filter bandwidth, assuming a perfect brick wall filter, is $\frac{I}{2D}$, where the factor of two comes from the Nyquist rate.

• Hi Jim, I thought that the normalized cutoff frequency of the lowpass filter for sample rate conversion should be min( 1/D, 1/I )? When I set "Band" to 9, I can see from the frequency response plot that the cutoff frequency (6dB) of the lowpass filter lies at 1/9 – Luc Aug 15 '13 at 21:26
• You're right, looking at the sample rate of the input image normalized by the nyquist frequency the brick wall filter should have a cutoff frequency of I/D. Looking at the sample rate of the upsampled image, in which I-1 zeros are added in between each original sample, the normalized cutoff frequency should be min( 1/D, i/I ) – Luc Aug 18 '13 at 22:18

I solved my problem. The design methodology as described above is sound. However, there was an error in my implementation of the FIR filter. For symmetrical filters you can replace convolution by correlation, and that's what I did. However, since the polyphase filters are asymmetrical this led to incorrect results. I implemented the FIR filter by convolution and now my sample rate converter works like a charm.

Below you can see the correctly resampled image:

And here's the original input image:

• Can you add the correctly filtered image? It'd be nice for comparison. – Peter K. Aug 18 '13 at 21:53
• Hi, Peter. I've added the correctly resampled image and the original image. Could you accept my answer and upvote it please? Thank you. – Luc Aug 18 '13 at 22:19