https://blog.csdn.net/andylanzhiyong/article/details/84857915
https://blog.csdn.net/guduruyu/article/details/68942211
https://blog.csdn.net/fengbingchun/article/details/52550460
Core.flip(Mat src, Mat dst, int flipCode)
src:原图
dst:目标图
flipCode: >0: 沿y轴翻转, 0: 沿x轴翻转, <0: x、y轴同时翻转(旋转180)
public static void main(String[] args) {
System.load("D:\\opencv-320\\opencv_java320.dll");
Mat src = Imgcodecs.imread("F:\\opencvPhoto\\test3\\test.jpg");
Mat dst1 = new Mat();
Core.flip(src, dst1, -1); // <0: x、y轴同时翻转(旋转180)
Imgcodecs.imwrite("F:\\opencvPhoto\\test3\\flipCode-1.jpg", dst1);
Mat dst2 = new Mat();
Core.flip(src, dst2, 0); // 0: 沿x轴翻转
Imgcodecs.imwrite("F:\\opencvPhoto\\test3\\flipCode0.jpg", dst2);
Mat dst3 = new Mat();
Core.flip(src, dst3, 1); // >0: 沿y轴翻转
Imgcodecs.imwrite("F:\\opencvPhoto\\test3\\flipCode1.jpg", dst3);
}
OpenCV中的transpose函数实现图像转置,公式为:dst(i, j) = src(j, i)
public static void main(String[] args) {
System.load("D:\\opencv-320\\opencv_java320.dll");
Mat src = Imgcodecs.imread("F:\\opencvPhoto\\test3\\test.jpg");
Mat dst = new Mat();
Core.transpose(src, dst);
Imgcodecs.imwrite("F:\\opencvPhoto\\test3\\transpose.jpg", dst);
}
transpose(src,tmp) + flip(tmp,dst,1)
public static void main(String[] args) {
System.load("D:\\opencv-320\\opencv_java320.dll");
Mat src = Imgcodecs.imread("F:\\opencvPhoto\\test3\\test.jpg");
Mat transpose = new Mat();
Core.transpose(src, transpose);
Mat flip = new Mat();
Core.flip(transpose, flip, 1);
Imgcodecs.imwrite("F:\\opencvPhoto\\test3\\flip.jpg", flip);
}
transpose(src,tmp) + flip(tmp,dst,0)
public static void main(String[] args) {
System.load("D:\\opencv-320\\opencv_java320.dll");
Mat src = Imgcodecs.imread("F:\\opencvPhoto\\test3\\test.jpg");
Mat transpose = new Mat();
Core.transpose(src, transpose);
Mat flip = new Mat();
Core.flip(transpose, flip, 0);
Imgcodecs.imwrite("F:\\opencvPhoto\\test3\\flip.jpg", flip);
}
flip(src,dst,-1)
public static void main(String[] args) {
System.load("D:\\opencv-320\\opencv_java320.dll");
Mat src = Imgcodecs.imread("F:\\opencvPhoto\\test3\\test.jpg");
Mat flip = new Mat();
Core.flip(src, flip, -1);
Imgcodecs.imwrite("F:\\opencvPhoto\\test3\\flip.jpg", flip);
}