### How To Use Bandpass Filters – C# Guide

Bandpass filters are the counterpart of bandreject filters. Therefore, they attenuate every frequency outside the ring. In case you’re just tuning in, let me clarify what I...

Filter by Category

- C# Tutorial(85)
- C# Image Processing(69)
- Morphological Processes(20)
- Image Processing(16)
- Image Restoration and Reconstruction(16)
- Image Segmentation(13)
- C# Data Structures And Algorithms(11)
- Color Image Processing(8)
- Frequency Domain Filtering(8)
- Image Noise(6)
- Grayscale Morphology(5)
- Thresholding(4)
- Order-Statistic Filters(4)
- Mean Filters(4)
- Sorting Algorithms(4)
- Morphological Reconstruction(3)
- Edge Detection(3)
- Simple Lists(2)
- RGB to HSI Color Model(2)
- Adaptive Filters(2)
- Tone and Color Corrections(2)
- Linked Lists(2)
- Stacks(1)
- Queues(1)
- Point Detection(1)
- Line Detection(1)
- C# Arrays(1)
- Region Segmentation Using Superpixels(1)
- Region Segmentation With K Means Clustering(1)
- Region Splitting And Merging(1)
- Sorted Lists(1)
- Region Growing Segmentation(1)
- Digital Image Watermarking(1)
- Using Color In Image Segmentation(1)
- Social Games(1)
- Bandreject Filters(1)
- Bandpass filters(1)
- Notch Filters(1)
- Landing Pages(1)
- Intensity Slicing and Color Coding(1)
- Color Slicing(1)
- Histogram Processing Color Images(1)
- Color Image Smoothing And Sharpening(1)
- C# Basics(1)

Back to Latest Articles
###
How To Use Bandpass Filters – C# Guide

###
How To Use Bandreject Filters – C# Guide

###
How To Use Laplacian Filter – C# Guide

###
How To Use Gaussian Highpass Filter – C# Guide

###
How To Use Butterworth Highpass Filter – C# Guide

###
How To Use Ideal Highpass Filter – C# Guide

###
How To Use Gaussian Lowpass Filter – C# Guide

###
How To Use Butterworth Lowpass Filter – C# Guide

###
How To Use Ideal Lowpass Filter With FFT – C# Guide

###
How To Use Fourier Transform On Images – C# Guide

Frequency Domain Filtering

Bandpass filters are the counterpart of bandreject filters. Therefore, they attenuate every frequency outside the ring. In case you’re just tuning in, let me clarify what I...

Frequency Domain Filtering

We use bandreject filters to attenuate a ring of frequencies around the center of a 2 dimensional frequency map. Now what does all that mean? We’re going to focus on...

Frequency Domain Filtering

We use Laplacian filter to sharpen images. We are going to talk about the details how exactly this filter works. In essence, it’s one of the highpass filters, which...

C# Tutorial

Gaussian highpass filter processes images in frequency domain. It attenuates low frequencies without creating ringing artifacts.

C# Tutorial

Butterworth highpass filter is used to filter images in frequency domain. We can control how smooth transition beyond cut off frequency.

C# Tutorial

Ideal highpass filter is used to filter images in the frequency domain. It attenuates low frequencies and keeps high frequencies.

C# Tutorial

We’ve talked about ideal lowpass filter and Butterworth lowpass filter already. And now, we shall get to know the last type of lowpass filters, which is Gaussian lowpass...

C# Image Processing

Butterworth lowpass filter is used to modify images in the frequency domain.

C# Image Processing

Ideal lowpass filter is a filter used to modify frequency values in the frequency domain, and for transforming an image into a frequency domain, we have to use Fourier transform....

C# Image Processing

Fourier transform is an equation that turns normal pixel values into complex numbers. But to know what these complex numbers mean, we should give a little more context to them by...

How To Use Bandpass Filters – C# Guide

Bandpass filters are the counterpart of bandreject filters. Therefore, they attenuate every frequency outside the ring.

In case you’re just tuning in, let me clarify what I meant by all above.

We use bandpass filters to process data in the frequency domain and we will focus on processing image data in this guide. Therefore we need to transform image into frequency domain before we do anything with filters. For that we need to use Fourier transform.

To filter data we have to multiply each frequency with filter formula. Each filter has its own but there are similarities between bandpass and bandreject filters. Much like how highpass and lowpass filters differ one another.

As we can use ideal, Butterworth and Gaussian bandreject filters, we can also use their bandpass counterparts. In other words, they attenuate frequencies bandreject filters pass and pass frequencies that bandreject attenuates.

This filter attenuates frequencies instantly at the edge of the ring.

Function that applies this filter is very similar to the bandreject one, since all we needed to change are conditions which frequencies to attenuate.

```
public static Complex[][][] IdealBandpassFilter(Complex[][][] frequencies, double d0, double W)
{
Complex[][][] filtered = frequencies;
for (int i = 0; i < 3; i++)
{
for (int u = 0; u < Size; u++)
{
for (int v = 0; v < Size; v++)
{
double d = Math.Sqrt((Math.Pow(u - Size / 2, 2) + Math.Pow(v - Size / 2, 2)));
if (d <= (d0 - W/2) || d >= (d0 + W/2))
{
filtered[i][u][v] *= 0f;
}
}
}
}
```` return filtered;`

` }`

As with all other Butterworth filters, this one has an additional parameter called order. When we set the order of the filter, we basically control how smooth the transition between attenuated and passed frequencies is.

We need the formula for Butterworth bandreject filter and subtract it from 1. Here’s the code that applies this.

```
public static Complex[][][] ButterworthBandpassFilter(Complex[][][] frequencies, double d0, int n, double W)
{
Complex[][][] filtered = frequencies;
for (int i = 0; i < 3; i++)
{
for (int u = 0; u < Size; u++)
{
for (int v = 0; v < Size; v++)
{
double d = Math.Sqrt((Math.Pow(u - Size / 2, 2) + Math.Pow(v - Size / 2, 2)));
filtered[i][u][v] *= 1f - (float)(1f / (1 + Math.Pow(d * W / (d
```*d - d0*d0), 2 * n)));
}
}
}
` return filtered;`

` }`

Gaussian bandpass filter makes the smoothest transition between attenuated and passed frequencies of the three. The same principle as with other bandpass filters applies here as well. In other words, we need the formula from Gaussian bandreject filter.

```
public static Complex[][][] GaussianBandpassFilter(Complex[][][] frequencies, double d0, double W)
{
Complex[][][] filtered = frequencies;
for (int i = 0; i < 3; i++)
{
for (int u = 0; u < Size; u++)
{
for (int v = 0; v < Size; v++)
{
double d = Math.Sqrt((Math.Pow(u - Size / 2, 2) + Math.Pow(v - Size / 2, 2)));
filtered[i][u][v]
```*= (float)(Math.Pow(Math.E, (-Math.Pow((d*d - d0*d0) / (d * W), 2))));
}
}
}
` return filtered;`

` }`

I recommend checking out the entire project. I implemented fast Fourier transform so the computation time is much shorter than DFT. However it does have some constraints, like the size and shape of the images it takes. Hopefully this guide was helpful and instructive.