private BitmapSource MatToBitmapSource(Mat mat, ref byte[] gray)
{
PixelFormat pf = PixelFormats.Gray8;
int rawStride = (mat.Width * pf.BitsPerPixel + 7) / 8;
mat.GetArray(out gray);
return BitmapSource.Create(mat.Width, mat.Height, 96, 96, pf, null, gray, rawStride);
}
private BitmapSource MatToBitmapSource(Mat mat, ref ushort[] gray)
{
PixelFormat pf = PixelFormats.Gray16;
int rawStride = (mat.Width * pf.BitsPerPixel + 7) / 8;
mat.GetArray(out gray);
return BitmapSource.Create(mat.Width, mat.Height, 96, 96, pf, null, gray, rawStride);
}