边缘检测-Prewitt 算子
2010-12-09 14:32
183 查看
边缘检测-Prewitt 算子
Prewitt 算子采用以下算子分别计算一阶 x 方向和 y 方向的图像差分:
|
|
#include <math.h> // Prewitt 算子 // 1. pImageData 图像数据 // 2. nWidth 图像宽度 // 3. nHeight 图像高度 // 4. nWidthStep 图像行大小 bool Prewitt(unsigned char *pImageData, int nWidth, int nHeight, int nWidthStep) { int i = 0; int j = 0; int dx = 0; int dy = 0; int nValue = 0; unsigned char *pLine[3] = { NULL, NULL, NULL }; for (j = 1; j < nHeight - 1; j++) { pLine[0] = pImageData + nWidthStep * (j - 1); pLine[1] = pImageData + nWidthStep * j; pLine[2] = pImageData + nWidthStep * (j + 1); for (i = 1; i < nWidth - 1; i++) { dx = pLine[0][i+1] - pLine[0][i-1] + pLine[1][i+1] - pLine[1][i-1] + pLine[2][i+1] - pLine[2][i-1]; dy = pLine[2][i-1] - pLine[0][i-1] + pLine[2][i] - pLine[0][i] + pLine[2][i+1] - pLine[0][i+1]; nValue = (int) sqrt((float) (dx * dx + dy * dy)); if (nValue > 0xFF) { nValue = 0xFF; } pLine[0][i-1] = (unsigned char) nValue; } } return true; }
相关文章推荐
- matlab边缘检测代码(包含roberts,sobel,prewitt三种算子)
- 13. 用Roberts、Sobel、Prewitt和Laplace算子对一幅灰度图像进行边缘检测。观察异同。
- 使用roberts Prewitt Sobel 三种算子对raw格式图像进行边缘检测
- 边缘检测 (4)Prewitt边缘算子
- 边缘检测类(包括Roberts, Sobel, Prewitt, Kirsch等算子的边缘检测算法) - wtuyzh的专栏 - CSDNBlog
- 边缘检测-Prewitt 算子
- 图像梯度特征的常用边缘检测算子:Sobel、Prewitt、Roberts
- [ZZ] 边缘检测 梯度与Roberts、Prewitt、Sobel、Lapacian算子
- 几种边缘检测算子的比较Roberts,Sobel,Prewitt,LOG,Canny
- 边缘检测之LOG算子
- 图像处理常用边缘检测算子总结
- 【OpenCV入门教程之十二】OpenCV边缘检测:Canny算子,Sobel算子,Laplace算子,Scharr滤波器合辑
- canny 算子实现图像边缘检测(详细过程附源码)
- Prewitt 边缘检测
- 【opencv学习之二十六】边缘检测算子:Canny,Sobel,Laplacian
- Canny边缘检测算子
- opencv cvCanny算子以及与其他边缘检测算子的比较
- 使用Scharr 算子进行边缘检测
- 图像处理常用边缘检测算子总结
- 边缘检测算子之Canny