Mat
从文件中读取
srcMat=new Mat(curPostFilePath,ImreadModes.Grayscale);
bitmap to mat
Mat srcMat = OpenCvSharp.Extensions.BitmapConverter.ToMat(bitmap);
Mat to GrayMat
Mat grayMat = new Mat();
Cv2.CvtColor(srcMat, grayMat, ColorConversionCodes.BGR2GRAY);
Bitmap
Mat to Bitmap
Bitmap res = outMat.ToBitmap();
ImageSource
从文件中读取
OrgImage =new BitmapImage(new Uri(curPostFilePath, UriKind.Absolute));
BitmapImage
Mat To BitmapImage
public byte[] MatToByteArray(Mat mat)
{
List<byte> lstbyte = new List<byte>();
byte[] btArr = lstbyte.ToArray();
int[] param = new int[2] { 1, 80 };
Cv2.ImEncode(".jpg", mat, out btArr, param);
return btArr;
}
BitmapImage bmp = new BitmapImage();
bmp.BeginInit();
bmp.StreamSource = new System.IO.MemoryStream(MatToByteArray(orgMat));
bmp.EndInit();