最近用到了图像向左或者向右旋转90°的情况,纠结了好一会儿,写下来供大家参考。

1 向左旋转90°

//unsigned char *pImgData: 输入图像指针
//int WidthIn, int HeightIn:输入图像宽、高
//unsigned char *pImgOut: 旋转后图像指针
void RotateOfLeft(unsigned char *pImgData, int WidthIn, int HeightIn)
{
int i, j, tempSize;
int WidthOut = HeightIn;
int HeightOut = WidthIn;
unsigned char pImgtemp[*];
for (i = ; i < HeightIn; i ++)
{
for (j = ;j < WidthIn; j ++)
{
*(pImgtemp + i*WidthIn + j) = *(pImgData*WidthIn + j);
}
}
//memcpy(pImgtemp,pImgData,148*36);
for (i = ; i < HeightOut; i ++)
{
for (j = ;j < WidthOut; j ++)
{
*(pImgData + i*WidthOut + j) = *(pImgtemp + (j+)*WidthIn - - i);
}
}
}

2 向右旋转90°

//unsigned char *pImgData: 输入图像指针
//int WidthIn, int HeightIn:输入图像宽、高
//unsigned char *pImgOut: 旋转后图像指针
void RotateOfRight(unsigned char *pImgData, int WidthIn, int HeightIn, unsigned char *pImgOut)
{
int i, j;
int WidthOut = HeightIn;
int HeightOut = WidthIn;
for (i = ; i < HeightOut; i ++)
{
for (j = ;j < WidthOut; j ++)
{
*(pImgOut + i*WidthOut + j) = *(pImgData + (HeightIn - j - 1)*WidthIn + i);
}
}
}

C语言之图像旋转的更多相关文章

  1. NOI题库 09:图像旋转翻转变换

    NOI题库开始的题,也是略水,当然也是大水,所以彼此彼此 09:图像旋转翻转变换 总时间限制: 1000ms 内存限制: 65536kB 描述 给定m行n列的图像各像素点灰度值,对其依次进行一系列操作 ...

  2. 【OpenCV学习笔记】之六 手写图像旋转函数---万丈高楼平地起

    话说,平凡之处显真格,这一点也没错!  比如,对旋转图像进行双线性插值,很简单吧?  可,对我,折腾了大半天,也没有达到预期效果!  尤其是三个误区让我抓瞎好久: 1,坐标旋转公式.   这东西,要用 ...

  3. opencv 图像仿射变换 计算仿射变换后对应特征点的新坐标 图像旋转、缩放、平移

    常常需要最图像进行仿射变换,仿射变换后,我们可能需要将原来图像中的特征点坐标进行重新计算,获得原来图像中例如眼睛瞳孔坐标的新的位置,用于在新得到图像中继续利用瞳孔位置坐标. 仿射变换在:http:// ...

  4. Opencv2.4.4作图像旋转和缩放

    关于下面两个主要函数的讲解: cv::getRotationMatrix2D(center, angle, scale); cv::warpAffine(image, rotateImg, rotat ...

  5. 每日算法37:Rotate Image (图像旋转)

    You are given an n x n 2D matrix representing an image. Rotate the image by 90 degrees (clockwise). ...

  6. [google面试CTCI] 1-6.图像旋转问题

    [字符串与数组] Q:Given an image represented by an NxN matrix, where each pixel in the image is 4 bytes, wr ...

  7. pyhton:图像旋转

    最近一个作业中要用到图像旋转,分享一下学习过程.如有讲错的地方,恳请指正! 图像旋转,想想真简单啊,不就是将图像矩阵乘上一个旋转平移矩阵就完了吗?实际上还真没这么简单.首先这个旋转平移矩阵怎么获得?通 ...

  8. CCF CSP 201503-1 图像旋转 (降维)

    题目链接:http://118.190.20.162/view.page?gpid=T27 问题描述 试题编号: 201503-1 试题名称: 图像旋转 时间限制: 5.0s 内存限制: 256.0M ...

  9. 图像旋转、伸缩的自写matlab实现

    一.图像的旋转 今天的代码不是自己写的,缺少一些时间.但是认认真真推导了一下旋转的公式,代码的思想与原博博主一致,致敬! 愚以为,自己来实现图像旋转算法的关键点有二:其一,确定旋转后的图像边界.其二, ...

随机推荐

  1. ArcGIS10.x Engine直连提示连接超时ORA-12170 来自:http://www.iarcgis.com/?p=1004

    导语 随着Esri大力宣传直连,用户也越来越由服务连接,改为直连,当然ArcGIS Engine开发用户也不例外. 环境 Oracle数据库,ArcGIS版本不限,不过由于9版本多以服务连接,以10版 ...

  2. 偏差-方差分解Bias-Variance Decomposition

    转自: http://www.cnblogs.com/jmp0xf/archive/2013/05/14/Bias-Variance_Decomposition.html

  3. TinyXml 与 Rapidxml效率对照

    曾经在做开发中一直使用TinyXml,在网上搜索说Rapidxml的效率比tinyXml高.个人比較喜欢追求效率.所以忍不住尝试性使用Rapidxml. RapidXml 的官方站点例如以下: htt ...

  4. 基于开源项目的在线网络视频直播项目---pc端的推流

    https://github.com/winlinvip/simple-rtmp-server/issues/66 https://github.com/justinmakaila/iOS-Frame ...

  5. HDU 4277 USACO ORZ(暴力+双向枚举)

    USACO ORZ Time Limit: 5000/1500 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total ...

  6. SVN下Update出现代码文件删除状态问题

    有时候在SVN上更新了代码,发觉别人提交的东西,服务上明明就是有,但本机却空空如也.只好打开 "Repo-browser",从服务器上强拉下来.结果图标显示红叉,显示为删除状态. ...

  7. oracle 10g的备份和还原

    采用 expdp备份,impdp还原. 注意这二者不等同于exp和imp.oracle 10g以前,可以采用exp.imp,10g及以后,expdp + impdp矣.据说10g里面,如果采用exp, ...

  8. 【bzoj3224】Tyvj 1728 普通平衡树

    交了一发pb_ds #include<ext/pb_ds/assoc_container.hpp> #include<algorithm> #include<iostre ...

  9. 定时任务 bash 对远程数据库 备份 读写

    1g表 每行都有可能被更新,故全表备份 检测备份是否在进行 [root@hadoop1 ~]# netstat --numeric-ports | grep 3306tcp        0      ...

  10. Lightoj 1005 Rooks(DP)

    A rook is a piece used in the game of chess which is played on a board of square grids. A rook can o ...