将图像旋转 90、180 或 270 度 [英] Rotate image by 90, 180 or 270 degrees

查看:68
本文介绍了将图像旋转 90、180 或 270 度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将图像旋转 90、180 或 270 度.在 OpenCV4Android 中,我可以使用:

I need to rotate an image by either 90, 180 or 270 degrees. In OpenCV4Android I can use:

Imgproc.getRotationMatrix2D(new Point(center, center), degrees, 1);
Imgproc.warpAffine(src, dst, rotationMatrix, dst.size());

然而,这是我的图像处理算法的一个巨大瓶颈.当然,简单的旋转 90 度的倍数比 warpAffine 的最一般情况要简单得多,并且可以更有效地完成.例如,对于 180 度,我可以使用:

However, this is a huge bottleneck in my image processing algorithm. Of course, a simple rotation by a multiple of 90 degrees is much simpler than the most general case of warpAffine, and can be done much more efficiently. For 180 degrees, for instance, I could use:

Core.flip(src, dst, -1);

其中 -1 表示围绕水平轴和垂直轴翻转.是否有类似的优化可以用于 90 度或 270 度旋转?

where -1 means to flip about both horizontal and vertical axes. Is there a similar optimization I could use for 90 or 270 degree rotations?

推荐答案

这是您在 Google 上搜索的第一个结果,但这些解决方案都没有真正回答问题,或者正确或简洁.

This is the first result when you Google it and none of these solutions really answer the question or is correct or succinct.

Core.rotate(Mat src, Mat dst, Core.ROTATE_90_CLOCKWISE); //ROTATE_180 or ROTATE_90_COUNTERCLOCKWISE

这篇关于将图像旋转 90、180 或 270 度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆