연구에 대하여

보다 나은 웹성능 향상을 위한 연구를 위해 머스트에서 오픈하는 커뮤니티 공간입니다.

제목주파수 영역에서의 영상처리
작성자머스트 @ 2010.08.09 17:20:15

http://lab.must.or.kr/Frequency-Domain-Filtering.ashx

 

Ideal Lowpass Filter

ImageImage



Code

for (int i = 0; i < height; i++)
{
	int y = i - hh;

	for (int j = 0; j < width; j++)
	{
		int x = j - hw;
		int d = (int)System.Math.Sqrt(x * x + y * y);

		// filter values outside the range
		if ((d > d0))
		{
			data[i, j].Re = 0;
			data[i, j].Im = 0;
		}
	}
}

Butterworth Lowpass Filter

ImageImage



Code

for (int i = 0; i < height; i++)
{
	int y = i - hh;

	for (int j = 0; j < width; j++)
	{
		int x = j - hw;
		double d = System.Math.Sqrt(x * x + y * y);

		double h = 1.0 / (1.0 + System.Math.Pow(d / d0, 2.0 * n));
		data[i, j].Re *= h;
		data[i, j].Im *= h;
	}
}

Gaussian Lowpass Filter

ImageImage



Code

for (int i = 0; i < height; i++)
{
	int y = i - hh;

	for (int j = 0; j < width; j++)
	{
		int x = j - hw;
		double d = System.Math.Sqrt(x * x + y * y);

		double h = System.Math.Exp(-d * d / 2.0 / d0 / d0);
		data[i, j].Re *= h;
		data[i, j].Im *= h;
	}
}

Ideal Highpass Filter

ImageImage



Code

for (int i = 0; i < height; i++)
{
	int y = i - hh;

	for (int j = 0; j < width; j++)
	{
		int x = j - hw;
		int d = (int)System.Math.Sqrt(x * x + y * y);

		// filter values outside the range
		if ((d < d0))
		{
			data[i, j].Re = 0;
			data[i, j].Im = 0;
		}
	}
}

Butterworth Highpass Filter

ImageImage



Code

for (int i = 0; i < height; i++)
{
	int y = i - hh;

	for (int j = 0; j < width; j++)
	{
		int x = j - hw;
		double d = System.Math.Sqrt(x * x + y * y);

		double h = 1.0 / (1.0 + System.Math.Pow(d0 / d, 2.0 * n));
		data[i, j].Re *= h;
		data[i, j].Im *= h;
	}
}

Gaussian Highpass Filter

ImageImage



Code

for (int i = 0; i < height; i++)
{
	int y = i - hh;

	for (int j = 0; j < width; j++)
	{
		int x = j - hw;
		double d = System.Math.Sqrt(x * x + y * y);

		double h = 1.0 - System.Math.Exp(-d * d / 2.0 / d0 / d0);
		data[i, j].Re *= h;
		data[i, j].Im *= h;
	}
}

Homomorphic Filter

ImageImage



Code

for (int i = 0; i < height; i++)
{
	int y = i - hh;

	for (int j = 0; j < width; j++)
	{
		int x = j - hw;
		double d = System.Math.Sqrt(x * x + y * y);

		double h = (γH - γL) * (1.0 - System.Math.Exp(-c * d * d / D0 / D0)) + γL;
		data[i, j].Re *= h;
		data[i, j].Im *= h;
	}
}
공유
QR link to local page