Mat 的格式化输出

            Mat mat = new Mat(5, 3, MatType.CV_8UC3);
            Cv2.Randu(mat, Scalar.All(0d), Scalar.All(255d));
 
            Console.WriteLine("直接输出:");
            Console.WriteLine(mat);
 
            Console.WriteLine("格式化输出:默认风格");
            Console.WriteLine(Cv2.Format(mat));
 
            Console.WriteLine("格式化输出:Python风格");
            Console.WriteLine(Cv2.Format(mat, FormatType.Python));
 
            Console.WriteLine("格式化输出:CSV风格");
            Console.WriteLine(Cv2.Format(mat, FormatType.CSV));
 
            Console.WriteLine("格式化输出:NumPy风格");
            Console.WriteLine(Cv2.Format(mat, FormatType.NumPy));
 
            Console.WriteLine("格式化输出:c风格");
            Console.WriteLine(Cv2.Format(mat, FormatType.C));
 
            Console.WriteLine("格式化输出一行:Python风格");
            Console.WriteLine(Cv2.Format(mat.Row(0), FormatType.Python));
 
            Console.WriteLine("格式化输出一列:Python风格");
            Console.WriteLine(Cv2.Format(mat.Col(0), FormatType.Python));
 
            Console.WriteLine("格式化输出ROI 矩形:Python风格");
            Console.WriteLine(Cv2.Format(new Mat(mat, new Rect(0, 0, 2, 2)), FormatType.Python));
 
            Console.WriteLine("格式化输出ROI Range:Python风格");
            Console.WriteLine(Cv2.Format(new Mat(mat, new OpenCvSharp.Range(0, 2),new OpenCvSharp.Range(0, 2)), FormatType.Python));

输出结果:

直接输出:
Mat [ 5*3*CV_8UC3, IsContinuous=True, IsSubmatrix=False, Ptr=0x2a34cdfaf10, Data=0x2a34ce0f440 ]
 
格式化输出:默认风格
[ 91,   2,  79, 179,  52, 205, 236,   8, 181;
 239,  26, 248, 207, 218,  45, 183, 158, 101;
 102,  18, 118,  68, 210, 139, 198, 207, 211;
 181, 162, 197, 191, 196,  40,   7, 243, 230;
  45,   6,  48, 173, 242, 125, 175,  90,  63]
 
格式化输出:Python风格
[[[ 91,   2,  79], [179,  52, 205], [236,   8, 181]],
 [[239,  26, 248], [207, 218,  45], [183, 158, 101]],
 [[102,  18, 118], [ 68, 210, 139], [198, 207, 211]],
 [[181, 162, 197], [191, 196,  40], [  7, 243, 230]],
 [[ 45,   6,  48], [173, 242, 125], [175,  90,  63]]]
 
格式化输出:CSV风格
 91,   2,  79, 179,  52, 205, 236,   8, 181
239,  26, 248, 207, 218,  45, 183, 158, 101
102,  18, 118,  68, 210, 139, 198, 207, 211
181, 162, 197, 191, 196,  40,   7, 243, 230
 45,   6,  48, 173, 242, 125, 175,  90,  63
 
格式化输出:NumPy风格
array([[[ 91,   2,  79], [179,  52, 205], [236,   8, 181]],
       [[239,  26, 248], [207, 218,  45], [183, 158, 101]],
       [[102,  18, 118], [ 68, 210, 139], [198, 207, 211]],
       [[181, 162, 197], [191, 196,  40], [  7, 243, 230]],
       [[ 45,   6,  48], [173, 242, 125], [175,  90,  63]]], dtype='uint8')
 
格式化输出:c风格
{ 91,   2,  79, 179,  52, 205, 236,   8, 181,
 239,  26, 248, 207, 218,  45, 183, 158, 101,
 102,  18, 118,  68, 210, 139, 198, 207, 211,
 181, 162, 197, 191, 196,  40,   7, 243, 230,
  45,   6,  48, 173, 242, 125, 175,  90,  63}
 
格式化输出一行:Python风格
[[[ 91,   2,  79], [179,  52, 205], [236,   8, 181]]]
 
格式化输出一列:Python风格
[[ 91,   2,  79],
 [239,  26, 248],
 [102,  18, 118],
 [181, 162, 197],
 [ 45,   6,  48]]
 
格式化输出ROI 矩形:Python风格
[[[ 91,   2,  79], [179,  52, 205]],
 [[239,  26, 248], [207, 218,  45]]]
 
格式化输出ROI Range:Python风格
[[[ 91,   2,  79], [179,  52, 205]],
 [[239,  26, 248], [207, 218,  45]]]
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值