首页 > 代码库 > 【图像处理】Schmid滤波器
【图像处理】Schmid滤波器
Schmid也是一种类Gabor图像滤波器,在这篇文章[1]中有具体推导和介绍。
一种更简洁的表达公式是:
其中,r为核半径,Z为归一化参数,τ和σ是比较重要的参数,在ReID提取TextFeature中,经常使用如下一系列参数:
(2,1), (4,1), (4,2), (6,1), (6,2), (6,3), (8,1), (8,2), (8,3), (10,1), (10,2), (10,3), (10,4)
此外,还结合前面的Gabor滤波器,γ,θ,λ,σ的参数分别使用:(0.3,0,4,2), (0.3,0,8,2), (0.4,0,4,1), (0.4,0,4,1), (0.3,π/2,4,2), (0.3,π/2,8,2), (0.4,π/2 ,4,1), (0.4,π/2,4,1)
以下是11个滤波核的示意图:
生成Schmid核函数代码:
Mat getSchmidFilter(float tao, float sigma){ float r = sigma/(4.0f*tao); float sigma2 = sigma*sigma; //int half_filter_size = int(r+0.5); int half_filter_size = 10; int filter_size = 2*half_filter_size+1; Mat schmid = Mat::zeros(filter_size,filter_size,CV_32F); float filter_sum = 0.0f; for(int i=0;i<filter_size;i++){ float* s = schmid.ptr<float>(i); for(int j=0;j<filter_size;j++){ float x = i-half_filter_size; float y = j-half_filter_size; r = sqrt(x*x+y*y); float tmp = 2*PI*tao*r/sigma; float tmp2 = r*r/(2.0f*sigma2); s[j] = cos(tmp)*exp(-tmp2); filter_sum += s[j]; } } //cout<<filter_size<<" "<<filter_sum<<endl; //cout<<schmid<<endl; if(abs(filter_sum-0.0f)<1e-6){ return schmid; } for(int i=0;i<filter_size;i++){ float* s = schmid.ptr<float>(i); for(int j=0;j<filter_size;j++){ s[j]/=filter_sum; } } return schmid; }
对图像进行卷积滤波效果如图:
参考文献:
[1] Schmid, Cordelia. "Constructing models for content-based image retrieval."Computer Vision and Pattern Recognition, 2001. CVPR 2001. Proceedings of the 2001 IEEE Computer Society Conference on. Vol. 2. IEEE, 2001.
[2] Gray, Douglas, and Hai Tao. "Viewpoint invariant pedestrian recognition with an ensemble of localized features." Computer Vision–ECCV 2008. Springer Berlin Heidelberg, 2008. 262-275.