FPGA FIR Filter: Application and Algorithm

FPGA FIR Filter: Application and Algorithm


Hello and welcome to this lecture where you learn how to implement
an FIR filter on an FPGA. FIR filter are very common
in signal processing and we will have a look at an
implementation for video signals. The application is a modern TV set where are you often find a feature
like sharpness improvement. And this sharpness improvement can
be implemented with an FIR filter. The lecture consists of several videos and in this video we will have a
look at the algorithm development. So what is the algorithm
for this FIR filter. To understand the algorithm we have to know what frequencies
are in terms of image processing. Frequencies mean that we have certain
amount of structures in our image. And a frequency of zero would
be an image without a structure. And if we have a gradual
change this is low frequency. If we have more frequent changes
this means medium and high frequency. These frequencies can occur in
horizontal or in vertical direction. For our sharpness algorithm we want to
amplify the higher frequencies to get a sharper image. So that would be around this region here. So this is block diagram for this approach. You have an input signal X and with the highpass filter you
identify the high frequencies. Then you amplify them by a certain factor and add them to the input signal
to get the output signal Y. And the amplification factor
allows to set the sharpness for you to be set to low, medium,
high, or switch it off. An image has two dimensions and
you can use a separable filter so first perform vertical sharpening
and then horizontal sharpening. For the highpass filter
we need filter constraints and therefore we have to think
about the size of the filter. You can do experiments
with different filter sizes and different filter frequencies As an initial constraint, an educated guess
we are designing a 7-tap or-9 tap filter. This is medium sized. And we choose the cutoff frequency
at 50% of the frequency range. And now there are different
methodologies to design the coefficients. Here I want to show
you the usage of Octave but there are also other options. In Octave you have a function to
determine the filter coefficients, and then you get certain values. If we have a closer look we
see that the coefficient -4, +4 are very small so
they are nearly zero. And the 9-tap filter is
effectively a 7-tap filter. For an efficient implementation we want
to have discrete filter coefficients, and we choose the resolution so that the
coefficients -3, + 3 are approximately 1. And we want the coefficients as a
fraction with the divisor as a power of 2. This coefficient 0.022661 is about 1/44, so we are rounding a bit and we
are choosing a resolution of 1/32. We take our coefficients
multiply them with 32 and round them. And then we get these values and the
filter function that you see here. The filter coefficients are then multiplied
with the amplification factor A and added to the original signal. So for A=1 you have
here the original signal, this is the highpass filter. And then you get the results for the
complete function of the sharpness filter. Here is another value for A and
you get different coefficients. In our example we take A=1
to get a very good sharpness, to get a high sharpness,
so that we can see something. And maybe later on you can reduce
that to have smaller sharpness factor. With Octave you can see
the frequency response. For low frequencies you
an amplification of 0 dB, so there is no change in that frequency. And for higher frequencies you get a
magnitude of 6 dB, so a factor of 2. Now we can try out or algorithm with
a test image, and again we use Octave. With the image package
we can read a JPEG image. Horizontal filter is here, vertical filter
is horizontal filter transposed. These are the filter functions. And then we write the result. The code is available
at our project website, and if you use your own test image you have
to change the names of the image files. Here you see the test image in the
original version. It’s a harbour scene. Enter after the sharpness
filter you get this result. So depending on the quality
of your video streaming, I hope you can see some differences. Here you see a detail of the test image. It’s the clock of the
tower on the right side. And you see that small structures
are more sharp in the right image, but also noise is more visible, so it’s a trade-off between
sharpness and visibility of noise. And you have to adjust that with
the factor A for the amplification. No we have the algorithm
for the FIR filter, and in the next video I will explain
the implementation on an FPGA. Please have a look at that video.

Leave a Reply

Your email address will not be published. Required fields are marked *