(原)使用opencv的warpAffine函数对图像进行旋转
转载请注明出处:
http://www.cnblogs.com/darkknightzh/p/5070576.html
参考网址:
http://stackoverflow.com/questions/7813376/rotate-cvmat-using-cvwarpaffine-offsets-destination-image 的plhn的回复
http://blog.csdn.net/xiaowei_cqu/article/details/7616044
http://docs.opencv.org/2.4/doc/tutorials/imgproc/imgtrans/warp_affine/warp_affine.html
使用opencv的warpAffine函数对图像进行旋转
Mat ImgRotate(const Mat& ucmatImg, double dDegree)
{
Mat ucImgRotate; double a = sin(dDegree * CV_PI / );
double b = cos(dDegree * CV_PI / );
int width = ucmatImg.cols;
int height = ucmatImg.rows;
int width_rotate = int(height * fabs(a) + width * fabs(b));
int height_rotate = int(width * fabs(a) + height * fabs(b)); Point center = Point(ucmatImg.cols / , ucmatImg.rows / ); Mat map_matrix = getRotationMatrix2D(center, dDegree, 1.0);
map_matrix.at<double>(, ) += (width_rotate - width) / ; // 修改坐标偏移
map_matrix.at<double>(, ) += (height_rotate - height) / ; // 修改坐标偏移 warpAffine(ucmatImg, ucImgRotate, map_matrix, { width_rotate, height_rotate },
CV_INTER_CUBIC | CV_WARP_FILL_OUTLIERS, BORDER_CONSTANT, cvScalarAll()); return ucImgRotate;
}
(原)使用opencv的warpAffine函数对图像进行旋转的更多相关文章
- Python图像处理丨基于OpenCV和像素处理的图像灰度化处理
摘要:本篇文章讲解图像灰度化处理的知识,结合OpenCV调用cv2.cvtColor()函数实现图像灰度操作,使用像素处理方法对图像进行灰度化处理. 本文分享自华为云社区<[Python图像处理 ...
- opencv —— getRotationMatrix2D、warpAffine 仿射变换实现图像旋转缩放
仿射变换的基本概念 仿射变换是一种二维坐标(x, y)到二维坐标(u, v)的线性变换,其数学表达式形式如下: 对应的齐次坐标矩阵表示形式为: 仿射变换保持了二维图形的“平直性”(直线经仿射变换后依然 ...
- 图像边缘检测--OpenCV之cvCanny函数
图像边缘检测--OpenCV之cvCanny函数 分类: C/C++ void cvCanny( const CvArr* image, CvArr* edges, double threshold1 ...
- 图像边缘检測--OpenCV之cvCanny函数
图像边缘检測--OpenCV之cvCanny函数 分类: C/C++ void cvCanny( const CvArr* image, CvArr* edges, double threshold1 ...
- OpenCV学习2-----使用inpaint函数进行图像修复
安装opencv时,在opencv的安装路径下, sources\samples\cpp\ 路径里面提供了好多经典的例子,很值得学习. 这次的例子是利用inpaint函数进行图像修复. CV_EXP ...
- OpenCV文本图像的旋转矫正
用户在使用Android手机拍摄过程中难免会出现文本图像存在旋转角度.这里采用霍夫变换.边缘检测等数字图像处理算法检测图像的旋转角度,并根据计算结果对输入图像进行旋转矫正. 首先定义一个结构元素,再通 ...
- Python 图像处理 OpenCV (5):图像的几何变换
前文传送门: 「Python 图像处理 OpenCV (1):入门」 「Python 图像处理 OpenCV (2):像素处理与 Numpy 操作以及 Matplotlib 显示图像」 「Python ...
- 【OpenCV入门教程之三】 图像的载入,显示和输出 一站式完全解析(转)
本系列文章由@浅墨_毛星云 出品,转载请注明出处. 文章链接:http://blog.csdn.net/poem_qianmo/article/details/20537737 作者:毛星云(浅墨) ...
- 图像分割之(四)OpenCV的GrabCut函数使用和源码解读
图像分割之(四)OpenCV的GrabCut函数使用和源码解读 分类: 图像处理 计算机视觉 2013-01-23 ...
随机推荐
- JMS-activeMQ
参考资料: http://yuxisanren.iteye.com/blog/1912587 .JMS简介:JMS即Java Message Service,是Java 程序创建.发送.接收和读取企业 ...
- PHP中的魔术方法总结 :__construct, __destruct , __call, __callStatic,__get, __set, __isset, __unset , __sleep, __wakeup, __toStr
PHP中的魔术方法总结 :__construct, __destruct , __call, __callStatic,__get, __set, __isset, __unset , __sleep ...
- linux上安装apache以及httpd.conf基本配置
1.yum安装apache #yum install httpd -y 2.随系统自启动 #chkconfig httpd on 3.开启apache #service httpd start PS: ...
- DataTable 导出Excel 下载 (NPOI)
public class ExcelHelper { public void DownLoadExcelNew(System.Data.DataTable data, Hashtable h, ...
- R语言画正弦曲线
正弦曲线一个周期是2π,我们要先生成x的取值范围. 可以用seq函数生成一个等差序列,步进为0.01 x=seq( 0, 2*pi, 0.01 ) pi表示π y=sin(x) plot(x, ...
- Log4net从下载到使用例子
一.首先下载log4net.dll http://pan.baidu.com/s/1gdigrwJ 二.添加log4net引用 三.代码: using System; using System.C ...
- Android Development Tools 发生checkAndLoadTargetData错误
之前使用时没有出现任何问题的,我把D:\IDE\ADT\adt-bundle-windows-x86_64-20140321\eclipse目录下面的 eclipse.exe重名名为adt.exe并设 ...
- Sql server中Collation conflict问题
SQL语句查询时select A.Code,A.Name,a.Systemcode,B.ID,B.LogType,B.DMCode,B.IP,B.Department,B.CreateBy,B.Cre ...
- Sql Server 面试题
1.用一条SQL语句 查询出每门课都大于80分的学生姓名 name kecheng fenshu 张三 语文 81张三 数学 75李四 语文 ...
- Non-unique Elements
Non-unique Elements You are given a non-empty list of integers (X). For this task, you should return ...