旋转图像PPM
rotate an image PPM
我试图向左/或向右旋转图像ppm。我成功地旋转了180度,但90度似乎不起作用。
这是我的代码
// working 1-D array of pixels pixel
*n_array = new Image(width, height);
// set up the new array dimensions based on ROTATION type
switch (the rotation)
{
case ROTCW:
case ROTCCW:
...
break;
case ROT180:
default: .. break;
}
for (unsigned int idx = 0; idx < (o_width * o_height); idx++)
{
old_y = idx / o_width;
switch (rotation)
{
case ROTCCW: ...
default: cout << "Oups" << std::endl; break;
}
// put pixel into n_array
}
所以这是我的结果…
https://i.stack.imgur.com/Cj6AM.png https://i.stack.imgur.com/yTnbS.png有人有解决办法吗?
您可以在创建新图像后翻转图像尺寸。尝试在switch (rotation) {...}
之后移动GaryImage *n_array = new GrayImage(o_width, o_height);
以使用正确的高度和宽度。
编辑:反正应该是GrayImage *n_array = new GrayImage(n_width, n_height);
相关文章:
- C++,OpenCV,尝试显示图像时"OpenCV(4.3.0) Error: Assertion failed (size.width>0 && size.height>0)"此错误
- 如何使用OpenCV将RBG图像转换为HSV,并将H、S和V值保存为C++中的3个独立图像
- OpenCV EqualizeHist()从彩色图像创建黑白图像
- 将"打开的CV图像"中的"颜色"转换为整数格式
- 将RGB图像保存为PPM格式
- C++射线示踪剂ppm表示没有足够的数据来显示图像
- 翻转 ppm 图像C++麻烦
- C 读取/写作PPM图像文件灰色图像
- 尝试用 C++ 编写 ppm 图像
- 为 ppm/pgm 图像数据创建存储
- 放大的PPM图像(无过滤)
- 读取/写入PPM图像文件C++
- 将任何彩色PPM图像转换为只有8种颜色的彩色图像
- 读取 ppm p6 图像完成时出现问题.C++
- C++处理 PPM 图像
- C++-试图读取.PPM图像,意外输出
- 如何获得ppm图像在(x,y)位置的颜色?
- 阅读PPM图像问题
- 读取/写入 PPM 图像C++,新图像损坏
- 旋转图像PPM