第六章图像滤波 方向滤波器边缘检测
来源:互联网 发布:js获取客户端端口号 编辑:程序博客网 时间:2024/05/18 03:40
Sobel滤波器
void Sobel( InputArray src, OutputArray dst, int ddepth,
int dx, int dy, int ksize = 3,
double scale = 1, double delta = 0,
int borderType = BORDER_DEFAULT );
用索贝尔算子进行边缘检测:
计算X和Y方向上的导数并进行相加得到Sobel滤波器的范式
找到范式的最大值和最小值
将范式转换成8位图像,并进行二值化的到边缘
#include <iostream>#include <iomanip>#include <opencv2/core/core.hpp>#include <opencv2/imgproc/imgproc.hpp>#include <opencv2/highgui/highgui.hpp>int main(){ // Read input image cv::Mat image = cv::imread("D:/1.jpg", 0); if (!image.data) return 0; // Display the image cv::namedWindow("Original Image"); cv::imshow("Original Image", image); // Compute norm of Sobel cv::Sobel(image, sobelX, CV_16S, 1, 0); cv::Sobel(image, sobelY, CV_16S, 0, 1); cv::Mat sobel; //compute the L1 norm sobel = abs(sobelX) + abs(sobelY); double sobmin, sobmax; cv::minMaxLoc(sobel, &sobmin, &sobmax); // Conversion to 8-bit image // sobelImage = -alpha*sobel + 255 cv::Mat sobelImage; sobel.convertTo(sobelImage, CV_8U, -255. / sobmax, 255); // Display the image cv::namedWindow("Sobel Image"); cv::imshow("Sobel Image", sobelImage); // Apply threshold to Sobel norm (low threshold value) cv::Mat sobelThresholded; cv::threshold(sobelImage, sobelThresholded, 190, 128, cv::THRESH_BINARY); // Display the image cv::namedWindow("Binary Sobel Image (low)"); cv::imshow("Binary Sobel Image (low)", sobelThresholded); // Apply threshold to Sobel norm (high threshold value) cv::threshold(sobelImage, sobelThresholded, 190, 255, cv::THRESH_BINARY); // Display the image cv::namedWindow("Binary Sobel Image (high)"); cv::imshow("Binary Sobel Image (high)", sobelThresholded); cv::waitKey(); return 0;}
阅读全文
0 0
- 第六章图像滤波 方向滤波器边缘检测
- 计算图像的拉普拉斯变换,使用方向滤波器检测边缘
- Opncv学习之使用方向滤波器检测边缘
- 第六章 - 图像变换 - Canny算子边缘检测(cvCanny)
- 第六章 - 图像变换 - Canny算子边缘检测(cvCanny)
- 4、图像滤波+边缘检测+图像增强实例
- 第五章 使用形态学滤波对图像进行边缘及角点检测
- 形态学滤波对图像进行边缘及角点检测
- 图像去噪、滤波 、边缘检测 matlab实现
- 第六章图像滤波低通滤波器
- 第六章 图像滤波 中值滤波器
- FPGA图像处理之边缘检测,中值滤波,图像均衡1。
- 计算机视觉笔记(二)图像处理(1)图像、滤波、边缘检测、车牌识别、SVM
- 图像边缘检测界面
- poj1009图像边缘检测
- 关于图像边缘检测
- 图像边缘检测算法
- 图像边缘检测
- rts中的寻路系统一些小结
- 条件运算符 ? :
- <C语言经典100例>c40 自守数
- java提高篇(45)--Java解析XML汇总
- Python 切割(split())
- 第六章图像滤波 方向滤波器边缘检测
- 【计算方法笔记】矩阵分解求解线性方程组
- 梯度下降算法推导(笔记)
- sql server建表时怎么设置ID字段自增
- php培训学习记录 第六、七天
- 跳跃的杰克(51nod 1615)
- Java学习日志
- Python数据挖掘入门与实践(四)——亲和性分析
- js rowspan