opencv_17_翻转与旋转

一、图像翻转

1)void flip_test(Mat& image);

2)void ColorInvert::flip_test(Mat& image) {

Mat dst;

//flip(image, dst, 0); //上下翻转

flip(image, dst, 1); //左右翻转

// flip(image, dst, -1); //180度翻转

imshow("图像旋转", dst);

}

二、图像旋转

coInvert.rotate(src);

void ColorInvert::rotate(Mat& image) {

Mat dst,M;

int w = image.cols;

int h = image.rows;

M = getRotationMatrix2D(Point2f(w / 2, h / 2), 45, 1.0);

double cos = abs(M.at<double>(0, 0));

double sin = abs(M.at<double>(0, 1));

int nw = cos * w + sin * h;

int nh = sin * w + cos * h;

M.at<double>(0, 2) += (nw / 2 - w / 2);

M.at<double>(1, 2) += (nh / 2 - h / 2);

warpAffine(image, dst, M, Size(nw, nh), INTER_LINEAR, 0, Scalar(255, 255, 0));

imshow("旋转演示", dst);

}

​​​​​​​

相关推荐
冬奇Lab1 分钟前
Agent系列(三):Plan-and-Solve——先想清楚,再动手
人工智能·llm·agent
冬奇Lab5 分钟前
每日一个开源项目 #110:ai-engineering-from-scratch - 从零构建 AI 工程全栈能力
人工智能·深度学习·llm
夜郎king5 分钟前
基于 Trae Solo 的 Ant 遗留项目编译方案 —— 以 BaseformEpanet 为例
人工智能·trae solo·水力模型·java水力模型编译
测试员周周8 分钟前
【Appium 系列】第20节-测试项目结构设计 — 从脚本到工程
人工智能·数据挖掘·回归·单元测试·appium·测试用例·测试覆盖率
还是叫明11 分钟前
C#使用YOLO26进行图像识别(目标检测)
opencv·yolo·目标检测·c#
IT_陈寒12 分钟前
SpringBoot自动配置偷偷给我埋了个坑
前端·人工智能·后端
一切皆是因缘际会13 分钟前
AI 从 “模仿智能” 到 “重构世界” 的范式跃迁
大数据·人工智能·深度学习·重构·架构
Are_You_Okkk_15 分钟前
无需配环境、不受设备限!MonkeyCode重新定义研发
大数据·人工智能·开源·团队开发·ai编程
kyraaa115 分钟前
618智能灭蚊器什么牌子好?电灭蚊灯哪个牌子好用?综合测评希亦、绳池等10大热门灭蚊灯品牌!
大数据·人工智能·python
deephub16 分钟前
推理 → 行动 → 观察:用 LangChain + Python 实现一个智能体循环
人工智能·python·langchain·大语言模型·agent