32位RGB图像中值滤波
来源:互联网 发布:中国不高兴 知乎 编辑:程序博客网 时间:2024/06/09 14:24
中值滤波对椒盐噪声有很好的滤出效果,下面以3x3滤波器为例,实现中值滤波。
排序,采用选择排序。
void Sort(int data[9]){int i;int j;int minv;int index;index = 0;for (i = 0; i < 9; i++){ minv = data[i];index = i;for (j = i+1; j < 9; j++){if (minv > data[j]) { minv = data[j]; index = j; }}data[index] = data[i];data[i] = minv;}}
中值滤波:
void RGB32MedianFilting(uint8_t* src, uint8_t* dst, int width, int height){int i,j;int m,n;int d;uint32_t row_bytes;uint32_t color;int r_data[9];int g_data[9];int b_data[9];uint32_t* img;uint32_t* ptr;uint32_t* dimg;uint32_t off;row_bytes = width * 4;off = row_bytes + 4;for (i = 1; i < height - 1; i++){ img = (uint32_t*)(src + off);dimg = (uint32_t*)(dst + off);for (j = 1; j < width - 1; j++){ ptr = img;d = 0;for (m = -1; m <= 1; m++){ ptr = img + m * width;for (n = -1; n <= 1; n++){ ptr += n;color = *ptr;r_data[d] = color & 0x000000FF;g_data[d] = (color >> 8) & 0x000000FF;b_data[d] = (color >> 16) & 0x000000FF;d++;}}Sort(r_data);Sort(g_data);Sort(b_data);color &= 0xFF000000;color |= r_data[4] + (g_data[4] << 8) + (b_data[4] << 16);*dimg = color;dimg++;img++;}off += row_bytes;}}
要拓展到5x5,7x7等,也很容易。另外,对边界采取忽略的处理方式。
0 0
- 32位RGB图像中值滤波
- 图像的中值滤波
- 灰度图像中值滤波
- 【转】图像中值滤波
- 图像中值滤波实现
- 图像处理--中值滤波
- 图像增强-中值滤波
- 图像的中值滤波
- Delphi图像处理 -- 中值滤波
- [图像]中值滤波(Matlab实现)
- 中值滤波与图像锐化
- 中值滤波与图像锐化
- MATLAB 图像 均值滤波 中值滤波
- 均值滤波、中值滤波【MATLAB】【图像处理】
- 图像的均值滤波、中值滤波_JAVA
- 图像滤波----高斯滤波/中值滤波/均值滤波
- 灰度图像--图像增强 中值滤波
- RGB图像中值平滑和均值平滑
- Memcached分布式布置方案--一致性Hash分布机制及其改进
- LDA原理
- Kinect开发环境配置:Kinect for Windows SDK(V 1.8) + OpenCV2.4.9 + VS2013 + Win10(x64)
- android 中三种多渠道打包方式
- GreenDao数据库升级方案
- 32位RGB图像中值滤波
- CodeForces
- 运行nodejs显示端口被占用问题的解决
- 将eclipseNeon的编码变成UTF-8
- Objective-C中的关键字
- Ajax入门之XMLHttpRequest核心对象的详解
- git常用命令。。百度随便找的
- linux 查看进程
- C语言高效编程与代码优化