NuGet程序包下载
管理器搜索OpenCvSharp3-AnyCPU下载
引用
//引用
using OpenCvSharp;
图片裁剪
//读取图像
Mat image = new Mat(@"C:\Users\Administrator\Desktop\lena2.jpg", ImreadModes.Color);
int imgWidth = image.Width;
int imgHeight = image.Height;
//设置范围
Range rowRange;
rowRange.Start = 0;
rowRange.End = imgHeight;
Range colRange;
colRange.Start = 200;
colRange.End = 300;
//裁剪图像
Mat cropped_image = image[rowRange, colRange];
//图像保存
Cv2.ImWrite(@"C:\Users\Administrator\Desktop\cut1.jpg", cropped_image);
Cv2.WaitKey(0);