中值滤波
来源:互联网 发布:恐怖杀人案知乎 编辑:程序博客网 时间:2024/05/01 20:21
中值滤波是一种典型的非线性滤波技术,在一定条件下可以克服线性滤波器(如均值滤波)带来的图像细节模糊。
优点:消除杂散噪声点而不会或较小程度地造成边缘模糊。
缺点:对于图像中含有较多点、线、尖角细节的,不适宜采用中值滤波。
基本思想:将模板(如方形、线形、十字形、菱形等)中的像素值从小到大排序,将中值代替模板中间的或者指定位置的像素值。
下面给出模板为3x3大小方形的中值滤波C++源代码:
/**************中值滤波**************//Lumafor( y = 1; y < height-1; y++ ){pBgf += stride;for( x = 1; x < width-1; x++ ){//Insertion-Sort(A):3x3Pel A[9];A[0]=(pBgf-stride)[x-1];A[1]=(pBgf-stride)[x];A[2]=(pBgf-stride)[x+1];A[3] = pBgf[x-1];A[4] = pBgf[x];A[5] = pBgf[x+1];A[6]=(pBgf+stride)[x-1];A[7]=(pBgf+stride)[x];A[8]=(pBgf+stride)[x+1];for(int j=1; j<9; j++){Pel key=A[j];int i=j-1;while( i>0 && A[i]>key ){A[i+1]=A[i];i=i-1;}A[i+1]=key;}pBgf[x] = A[5];//取中值代替模板中心位置的像素值}}height >>= 1;width >>= 1;stride >>= 1;//CbpBgf = pcPicYuvBgf->getCbAddr();for( y = 1; y < height-1; y++ ){pBgf += stride;for( x = 1; x < width-1; x++ ){//Insertion-Sort(A):3x3Pel A[9];A[0]=(pBgf-stride)[x-1];A[1]=(pBgf-stride)[x];A[2]=(pBgf-stride)[x+1];A[3] = pBgf[x-1];A[4] = pBgf[x];A[5] = pBgf[x+1];A[6]=(pBgf+stride)[x-1];A[7]=(pBgf+stride)[x];A[8]=(pBgf+stride)[x+1];for(int j=1; j<9; j++){Pel key=A[j];int i=j-1;while( i>0 && A[i]>key ){A[i+1]=A[i];i=i-1;}A[i+1]=key;}pBgf[x] = A[5];//取中值代替模板中心位置的像素值}}//CrpBgf = pcPicYuvBgf->getCrAddr();for( y = 1; y < height-1; y++ ){pBgf += stride;for( x = 1; x < width-1; x++ ){//Insertion-Sort(A):3x3Pel A[9];A[0]=(pBgf-stride)[x-1];A[1]=(pBgf-stride)[x];A[2]=(pBgf-stride)[x+1];A[3] = pBgf[x-1];A[4] = pBgf[x];A[5] = pBgf[x+1];A[6]=(pBgf+stride)[x-1];A[7]=(pBgf+stride)[x];A[8]=(pBgf+stride)[x+1];for(int j=1; j<9; j++){Pel key=A[j];int i=j-1;while( i>0 && A[i]>key ){A[i+1]=A[i];i=i-1;}A[i+1]=key;}pBgf[x] = A[5];//取中值代替模板中心位置的像素值}}
0 0
- 中值滤波
- 中值滤波
- 中值滤波
- 中值滤波
- 中值滤波
- 中值滤波
- 中值滤波
- 中值滤波
- 中值滤波
- 中值滤波
- 中值滤波
- 中值滤波
- 中值滤波
- 中值滤波
- 中值滤波
- 中值滤波
- 中值滤波VS.均值滤波
- 非线性滤波:中值、双边滤波
- android adapter报错The content of the adapter has changed but ListView did not receive a notification.
- 我的权限系统设计实现MVC4 + WebAPI + EasyUI + Knockout(三)图形化机构树
- properties 读取中文乱码问题
- Core Animation之简单使用CALayer
- 链表中倒数第k个结点
- 中值滤波
- linux设置服务器间互信
- CollabNet Subversion搭建
- Core Animation之基础介绍
- 快速排序, 堆排序,归并排序复杂度问题。
- Matplotlib notes
- 我的权限系统设计实现MVC4 + WebAPI + EasyUI + Knockout(四)授权代码维护
- MongoDB C++开发环境搭建
- iOS 获取通讯录中联系人的所有属性