在 C/C++ 中旋转图像

Rotating an image in C/C++(在 C/C++ 中旋转图像)

本文介绍了在 C/C++ 中旋转图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在 C++ 中旋转图像的代码,其功能类似于 matlab 的 imrotate 函数.请推荐一个好的链接.或者如果有人可以提供 imrotate 的代码.

或者至少请解释一下算法.

这不是家庭作业.我的项目需要此代码.我们可以使用任何外部库或代码.

解决方案

获取源代码.

此外,OpenCV2.0 有 许多 MATLAB 风格的函数,例如 imread 等.

I need code for rotating an image in C++ which functions like imrotate function of matlab. Please suggest a good link. Or if someone can provide the code for imrotate.

Or at least please explain the algorithm.

Its not a homework. I need this code for my project. And we can use any external library or code.

解决方案

OpenCV2.0 has several computer vision and image processing tools. Specifically warpAffine (by defining the rotation matrix) will solve your problem with rotating an image.

The 2x3 transformation matrix mentioned in the documentation is as follows:

where θ is the angle of rotation and tx and ty is the translation along the x and y axes respectively.

You can get the source code here.

Also, OpenCV2.0 has many MATLAB-esque functions like imread, etc.

这篇关于在 C/C++ 中旋转图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:在 C/C++ 中旋转图像

基础教程推荐