sobel导数边缘检测(一阶导数求边缘)
2018-02-27 15:48
381 查看
#include "opencv2/imgproc/imgproc.hpp" #include "opencv2/highgui/highgui.hpp" #include <stdlib.h> #include <stdio.h> using namespace cv; /** @function main */ int main() { Mat src, src_gray; Mat grad; char* window_name = "Sobel Demo - Simple Edge Detector"; int scale = 1; int delta = 0; int ddepth = CV_16S; int c; /// 装载图像 src = imread("demo.jpg"); if (!src.data) { return -1; } GaussianBlur(src, src, Size(3, 3), 0, 0, BORDER_DEFAULT); /// 转换为灰度图 cvtColor(src, src_gray, CV_RGB2GRAY); /// 创建显示窗口 namedWindow(window_name, CV_WINDOW_AUTOSIZE); /// 创建 grad_x 和 grad_y 矩阵 Mat grad_x, grad_y; Mat abs_grad_x, abs_grad_y; /// 求 X方向梯度 //Scharr( src_gray, grad_x, ddepth, 1, 0, scale, delta, BORDER_DEFAULT ); Sobel(src_gray, grad_x, ddepth, 1, 0, 3, scale, delta, BORDER_DEFAULT); convertScaleAbs(grad_x, abs_grad_x); /// 求Y方向梯度 //Scharr( src_gray, grad_y, ddepth, 0, 1, scale, delta, BORDER_DEFAULT ); Sobel(src_gray, grad_y, ddepth, 0, 1, 3, scale, delta, BORDER_DEFAULT); convertScaleAbs(grad_y, abs_grad_y); /// 合并梯度(近似) addWeighted(abs_grad_x, 0.5, abs_grad_y, 0.5, 0, grad); imshow(window_name, grad); waitKey(0); return 0; }
相关文章推荐
- opencv的Sobel导数、Scharr滤波器、Laplacian算子、Canny边缘检测
- OpenCV之imgproc 模块. 图像处理(2)实现自己的线性滤波器 给图像添加边界 Sobel 导数 Laplace 算子 Canny 边缘检测
- 边缘检测(edge detection)_Sobel导数 Laplace算子 Canny边缘检测
- unity3d shader之Roberts,Sobel,Canny 三种边缘检测方法
- 【cuda学习笔记】2.纹理对象API的使用,实现sobel边缘检测
- 基础图像处理之混合空间增强——(Java:拉普拉斯锐化、Sobel边缘检测、均值滤波、伽马变换)
- [ZZ] 边缘检测 梯度与Roberts、Prewitt、Sobel、Lapacian算子
- 几种边缘检测算子的比较Roberts,Sobel,Prewitt,LOG,Canny
- [转]图像处理中各种边缘检测的微分算子简单比较(Sobel,Robert,Priwitt,Laplacian,Canny)
- [转载]边缘检测的各种微分算子比较(Sobel,Robert,Prewitt,Laplacian,Canny)
- canny/Sobel/Laplace边缘检测
- Unity之梯度应用实现Roberts、Prewitt、Sobel边缘检测
- 图像特征提取:Sobel边缘检测
- OpenCV图像边缘检测(sobel算法)
- Sobel(索贝尔)边缘检测算子分析及opencv程序测试
- paper 82:边缘检测的各种微分算子比较(Sobel,Robert,Prewitt,Laplacian,Canny)
- [图像处理] Sobel边缘检测算法
- FPGA设计——图像处理(Sobel边缘检测)
- 数字集成电路设计-8-一个简单sobel图像边缘检测加速器的设计,实现,仿真与综合
- 图像特征提取:Sobel边缘检测