利用opencv函数计算图像的梯度幅度和梯度方向
来源:互联网 发布:卖情侣装好的淘宝店 编辑:程序博客网 时间:2024/06/07 06:12
没有难点,就是为了方便使用记录,自己实现的话比较麻烦,直接使用内置函数计算比较省心。
重点是这个函数:
- x – Source matrix containing real components ( CV_32FC1 ).
- y – Source matrix containing imaginary components ( CV_32FC1 ).
- magnitude – Destination matrix of float magnitudes ( CV_32FC1 ).
- angle – Destionation matrix of angles ( CV_32FC1 ).
- angleInDegress – Flag for angles that must be evaluated in degress.
- stream – Stream for the asynchronous version.
#include<opencv2/opencv.hpp>#include<opencv2/highgui/highgui.hpp>#include<opencv2/imgproc/imgproc.hpp>using namespace std;using namespace cv;int main(){//*****注意:数据类型非常非常重要!!数据类型不一致,程序不报错,但是计算结果严重错误//如果是float类型就全是float,double类型就全是doublefloat data[3][3]={2,4,3,7,5,6,4,-8,9};Mat mat=Mat(3,3,CV_32FC1,data);cout<<mat;cout<<endl<<"卷积运算"<<endl;Mat outmat1,outmat2;float k1[]={-1,0,1}; //水平方向的核float k2[3][1]={-1,0,1}; //垂直的核Mat Kore=Mat(1,3,CV_32FC1,k1);Mat Kore2=Mat(3,1,CV_32FC1,k2);filter2D(mat,outmat1,-1,Kore); //水平卷积运算filter2D(mat,outmat2,-1,Kore2); //垂直卷积运算cout<<outmat1<<endl;cout<<outmat2;Mat tidu;Mat jiaodu;cartToPolar(outmat1,outmat2,tidu,jiaodu,true); //角度的结果在0-360之间cout<<"-----------------"<<endl;cout<<endl<<tidu; //梯度幅度值图cout<<endl<<jiaodu; //角度图waitKey(0);return 0;}
0 0
- 利用opencv函数计算图像的梯度幅度和梯度方向
- Opencv中计算梯度、梯度幅值以及梯度方向的相关函数
- // OpenCV 计算图像的平均梯度
- 图像的梯度计算
- OpenCV与梯度计算相关的函数
- 利用梯度方向在图像上提取直线的方法
- 利用OpenCV的Sobel算子求得图像的梯度信息
- OpenCV 自学笔记33. 计算图像的均值、标准差和平均梯度
- OpenCV 图像平均梯度
- opencv 图像梯度
- OpenCV 使用方向梯度直方图估计图像旋转角度
- 图像梯度计算
- 【C#】图像梯度计算
- 方向导数和梯度
- 方向导数和梯度
- 方向导数和梯度
- 方向导数 和 梯度
- 方向导数和梯度
- @media语法规则
- 应用 Valgrind 发现 Linux 程序的内存问题
- [Camera Drv]系统是如何为Sensor匹配Lens Driver
- javaweb中的listener
- apache-hive-2.0.0安装
- 利用opencv函数计算图像的梯度幅度和梯度方向
- Button取消多次点击事件
- 安卓1114_URI和URL的区别
- InputMethodManager内存泄露现象及解决
- 使用C语言遇到的几个小问题
- 最小路径覆盖,最小点覆盖,最大独立点集,最小边覆盖
- warning LNK4042: 对象被多次指定;已忽略多余的指定
- C++11 并发指南四(<future> 详解三 std::future & std::shared_future)
- [从头学绘画] 第36节 跆拳道二十四品势之7-退溪