图像旋转
定义中心点:src.width() / 2, src.height() / 2
图像旋转函数getRotationMatrix2D,第一个参数为中心点,第二个参数为旋转的角度(33°),第三个参数为缩放的比例
warpAffine函数,将图像进行旋转,旋转后的结果为dst
public static void main(String[] args) {
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
Mat src = Imgcodecs.imread("1.png");
HighGui.imshow("lena",src);
HighGui.waitKey(0);
Mat dst = src.clone();
//定义图像的中心
Point center = new Point(src.width() / 2, src.height() / 2);
Mat rotationMatrix2D = Imgproc.getRotationMatrix2D(center, 33.0, 1.0);//旋转的角度:33.0,缩放的比例:1.0
Imgproc.warpAffine(src,dst,rotationMatrix2D,dst.size(),Imgproc.INTER_NEAREST);
HighGui.imshow("lena",dst);
HighGui.waitKey(0);
}
原图:
结果图: