2阶：

10阶：

## 锐化-高通滤波器

2阶：

10阶：

### GHPF

“c++
#include "highpassfilter.h"
static double Distance(int x,int y,int c_x,int c_y){

<pre><code>return sqrt((x-c_x)*(x-c_x)+(y-c_y)*(y-c_y));
</code></pre>

}

void IdealHPFilter(double <em>Filter,int width,int height,double cut_off_frequency){
int center_x=width/2;
int center_y=height/2;
double distance=0.0;
for(int i=0;i<width;i++)
for(int j=0;j<height;j++){
distance=Distance(i,j,center_x,center_y);
if(distance<=cut_off_frequency)
Filter[j</em>width+i]=0.0;
else
Filter[j<em>width+i]=1.0;
}
Filter[width</em>(height+1)/2]+=1.0;
}
void ButterworthHPfilter(double <em>Filter,int width,int height,double cut_off_frequency,int n){
int center_x=width/2;
int center_y=height/2;
for(int i=0;i<width;i++)
for(int j=0;j<height;j++){
double value=1.0;
for(int k=0;k<n;k++)
value</em>=(Distance(i, j, center_x, center_y)/cut_off_frequency);
Filter[j<em>width+i]=1.0-1.0/(1.0+value);
}
Filter[width</em>(height+1)/2]+=1.0;
}
void GaussianHPFilter(double <em>Filter,int width,int height,double cut_off_frequency){
int center_x=width/2;
int center_y=height/2;
for(int i=0;i<width;i++)
for(int j=0;j<height;j++){
double value=Distance(i, j, center_x, center_y);
Filter[j</em>width+i]=1.0-exp(-value<em>value/(2</em>cut_off_frequency<em>cut_off_frequency));
}
Filter[width</em>(height+1)/2]+=1.0;
}

<pre><code class=""><br />## 钝化，高提升，高频强调

* k1=1时k2=1为钝化模板
* k1=1时k2>1为高提升滤波器
* k1=1时，统称高频强调滤波器

![Center 20][]

“c++
#include “Homomorphicfilter.h”

static double Distance(int x,int y,int c_x,int c_y){
return sqrt((x-c_x)*(x-c_x)+(y-c_y)*(y-c_y));
}
void HomorphicFilter(double *filter,int width,int height,double cut_off_frequency,double lambda_l,double lambda_h,double c){
int center_x=width/2;
int center_y=height/2;
double distance;
double distance_2;
double cut_off_frequency_2=cut_off_frequency*cut_off_frequency;
for(int i=0;i<height;i++)
for(int j=0;j<width;j++){
distance=Distance(j, i, center_x, center_y);
distance_2=distance*distance;
filter[i*width+j]=(lambda_h-lambda_l)*(1.0-exp(-c*distance_2/cut_off_frequency_2))+lambda_l;
}
}

## 总结

总结一下，这篇的理论在前面已经介绍了，所以更多是验证前面的结论，观察滤波效果。滤波中值得注意的是振铃现象，对于不能容忍人工缺陷的应用中，如医学图像处理，不能使用带有振铃现象的滤波器，在实际物理中，理想滤波器无法实现，所以更多的使用高斯和其他一些无振铃的滤波器

Subscribe