山东公司网站开发,现在什么app引流效果好,投资管理有限公司注册要求,百度推广长春分公司文章目录 图像的二阶导数Laplance算子代码示例 图像的二阶导数 在二阶导数的时候#xff0c;最大变化处的值为零即边缘是零值。通过二阶 导数计算#xff0c;依据此理论我们可以计算图像二阶导数#xff0c;提取边缘。 Laplance算子 void Laplacian( InputArray src, Output… 文章目录 图像的二阶导数Laplance算子代码示例 图像的二阶导数 在二阶导数的时候最大变化处的值为零即边缘是零值。通过二阶 导数计算依据此理论我们可以计算图像二阶导数提取边缘。 Laplance算子 void Laplacian( InputArray src, OutputArray dst, int ddepth,int ksize 1, double scale 1, double delta 0,int borderType BORDER_DEFAULT );
/*******************************************************************
* src: 输入图
* dst: 输出图
* ddepth: 输出图深度 CV_16S/CV_32F/CV_64F等
* ksize: 核大小必须是正奇数默认值是1
* scale: 计算导数值时可选的缩放因子
* delta: 可选值,默认为0
* borderType: 边缘处理模式
*********************************************************************/代码示例
#include opencv2/opencv.hpp
#include iostreamusing namespace cv;
int main(int argc, char** argv) {Mat src, dst;src imread(D:/vcprojects/images/lena.png);if (!src.data) {printf(could not load image);}char input_title[] input image;char output_title[] Laplaiance Result;namedWindow(input_title);imshow(input_title, src);Mat gray_src, edge_image;GaussianBlur(src, dst, Size(3, 3), 0, 0);//高斯模糊cvtColor(dst, gray_src, COLOR_BGR2GRAY);//灰度处理Laplacian(gray_src, edge_image, CV_16S, 3);//找图像边缘convertScaleAbs(edge_image, edge_image);//获取边缘绝对值threshold(edge_image, edge_image, 0, 255, THRESH_OTSU | THRESH_BINARY);//增强边缘轮廓namedWindow(output_title, CV_WINDOW_AUTOSIZE);imshow(output_title, edge_image);waitKey(0);return 0;
}