【发布时间】:2017-03-09 14:10:42
【问题描述】:
我已尝试使用 getRotationMatrix2D(center, angle, scale); 进行图像旋转和缩小 (JPEG)
和warpAffine(image1, image3, rotation, image3.size());
我得到了我想要的结果(如下图)
for (int r = 0;r < image1.rows;r++) {
for (int c = r + 1;c < image1.cols;c++) {
Point center = Point(image1.cols / 2, image1.rows / 2);
Point center1 = Point(image1.cols / 2, image1.rows / 2);
double angle = 90.0;
double scale = 1;
double angle1 = 90.0;
double scale1 = 0.5;
rotation = getRotationMatrix2D(center, angle, scale);
rotation1 = getRotationMatrix2D(center1, angle1, scale1);
但我想在不使用任何库的情况下学习一些简单的旋转和缩减算法(对于像我这样的初学者来说很简单) 得到相同的结果。 在寻找各种解决方案之后,我最终得到了这个 来自https://gamedev.stackexchange.com/questions/67613/how-can-i-rotate-a-bitmap-without-d3d-or-opengl 谁能一点一点地分解简单的线性代数来向我解释我的伪代码?
编辑: 减码
void reduction(Mat image1)
{
for (int r = 0;r < imgC.rows;r++)
{
for (int c = 0;c < imgC.cols;c++)
{
int new_x = c * (125 / 256);
int new_y = r * (125 / 256);
imgC.at<uchar>(r, c) = imgC.at<uchar>(new_y, new_x);
}
}
}
【问题讨论】:
标签: c++ image algorithm opencv rotation