使用C/C++对图像/矩阵向右旋转,具体的实现原理及步骤如下图所示:

#include <iostream>
#include <string.h>
using namespace std;
int main()
{
int w = 4, h = 4;
int imgSize = w * h;
unsigned short *pImg = NULL;
unsigned short *pImgR = NULL;
pImg = new unsigned short[imgSize];
if(pImg != NULL)
{
memset(pImg, 0, sizeof(unsigned short) * imgSize);
}
pImgR = new unsigned short[imgSize];
if(pImgR != NULL)
{
memset(pImgR, 0, sizeof(unsigned short) * imgSize);
}
cout << "右旋前:" << endl;
for (int i = 0; i < h; i++) //行
{
for (int j = 0; j < w; j++) //列
{
pImg[j + i * w] = j + i * w;
cout << pImg[j + i * w] << '\t';
}
cout << en

本文介绍了如何使用C/C++编程语言来实现矩阵和图像的90度向右旋转操作,详细阐述了旋转的具体实现原理和步骤。
最低0.47元/天 解锁文章
3761

被折叠的 条评论
为什么被折叠?



