一、图像翻转
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);
}