本系列代码托管于:https://github.com/chintsan-code/opencv4-tutorials
本篇使用的项目为:denoising
#include <opencv2/opencv.hpp>
#include <iostream>
using namespace cv;
using namespace std;
int main(int argc, const char** argv) {
	Mat src = imread("../sample/lena512color.bmp");
	if (src.empty()) {
		cout << "could not load image..." << endl;
		return -1;
	}
	namedWindow("input", WINDOW_AUTOSIZE);
	imshow("input", src);
	// Canny Demo
	Mat edges, dst;
	Canny(src, edges, 50, 150);
	bitwise_and(src, src, dst, edges);
	imshow("edges", dst);
	waitKey(0);
	destroyAllWindows();
	return 0;
}
边缘定义

- 边缘法线:单位向量在该方向上图像像素强度变化最大
 - 边缘方向:与边缘法线垂直的向量方向
 - 边缘位置或中心:图像边缘所在位置
 - 边缘强度:跟沿法线方向的图像局部对比相关,对比越大,越是边缘
 
边缘类型
- 跃迁类型
 

- 屋脊类型
 

提取方式
- 基于梯度的边缘提取
 

Roberts、Sobel、Prewitt算子
- Canny边缘提取
 
Canny:使用canny寻找图像边缘

void Canny( InputArray image, OutputArray edges, double threshold1, double threshold2, int apertureSize = 3, bool L2gradient = false );
- image:输入图像,8-bit
 - edges:输出边缘图,与src具有相同的尺寸,8UC1
 - threshold1:低阈值
 - threshold2:高阈值
 - apertureSize:Sobel算子的卷积核size
 - L2gradient:是否是计算L2梯度
 
                    
                
                        
                        
        
			
			
			
			
			
评论 (0)