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);

}

​​​​​​​

相关推荐
学究天人2 分钟前
数学公理体系大全:Comprehensive Collection of Mathematical Axiom Systems(补充卷9)
人工智能·线性代数·算法·数学建模·动态规划·原型模式·抽象代数
ZeekerLin6 分钟前
AI 原生开发落地路线图:从个人提效到团队体系化
大数据·人工智能
代码青铜10 分钟前
从黑盒到“上帝视角”:深度拆解【数据鸟瞰图】功能
人工智能
俊哥V11 分钟前
每日 AI 研究简报 · 2026-07-11
人工智能·ai
武子康20 分钟前
GPT-Live 全双工语音 Agent 深度拆解:连续交互 + 后台委托 + Voice Runtime 三层架构
人工智能·ai·chatgpt·架构·llm·交互
阿黎梨梨21 分钟前
听说大模型总“胡言乱语”?用 RAG 堵住它的嘴!
人工智能
刘小八21 分钟前
LangGraph 人机交互实战:Interrupt、人工审批与工作流恢复
人工智能·python·人机交互
cocoafei22 分钟前
GPT-5.6 后,别再混淆 ChatGPT 和 Codex 额度了
前端·人工智能·chatgpt
范闲25 分钟前
第二章:Octo v0.1.1:从「能用」到「好用」——终端 AI 聊天体验的全面升级
人工智能·后端
念雨思25 分钟前
每日穿搭助手:鸿蒙AI应用开发实战——AI衣橱,每日穿搭不再愁
人工智能·华为·powerpoint·harmonyos·鸿蒙