C++如何打印输出OpenCV的Mat对象的像素数据?

C++如何打印输出OpenCV的Mat对象的像素数据?,第1张

直接上源码:

cv::Mat src = imread("d:\findCircles1111.bmp", IMREAD_GRAYSCALE);
std::cout << "==默认风格==\n" << cv::format(src, cv::Formatter::FMT_DEFAULT) << std::endl;
std::cout << "==Matlab风格==\n" << cv::format(src, cv::Formatter::FMT_MATLAB) << std::endl;
std::cout << "==CSV风格==\n" << cv::format(src, cv::Formatter::FMT_CSV) << std::endl;
std::cout << "==Python风格==\n" << cv::format(src, cv::Formatter::FMT_PYTHON) << std::endl;
std::cout << "==Numpy风格==\n" << cv::format(src, cv::Formatter::FMT_NUMPY) << std::endl;
std::cout << "==C风格==\n" << cv::format(src, cv::Formatter::FMT_C) << std::endl;

==默认风格==
[111, 111, 166, 192, 251, 255, 255, 255, 255, 255;
 111,  83,  93,  83, 102,  85, 255, 251, 255, 255;
 111,  83, 111, 102, 111, 140, 255, 255, 255, 255;
 111,  83, 111,  83, 111, 140, 255, 255, 255, 255;
  83,  83, 111,  83, 111, 175, 255, 255, 255, 255;
  83,  74,  93,  83, 111, 175, 255, 251, 255, 255;
 192, 166, 111,  83,  76, 166, 255, 251, 255, 255;
 255, 255, 255, 255, 251, 251, 251, 208, 255, 255;
 192, 208, 251, 251, 251, 255, 251, 251, 255, 255;
 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]
==Matlab风格==
(:, :, 1) =
111, 111, 166, 192, 251, 255, 255, 255, 255, 255;
111,  83,  93,  83, 102,  85, 255, 251, 255, 255;
111,  83, 111, 102, 111, 140, 255, 255, 255, 255;
111,  83, 111,  83, 111, 140, 255, 255, 255, 255;
 83,  83, 111,  83, 111, 175, 255, 255, 255, 255;
 83,  74,  93,  83, 111, 175, 255, 251, 255, 255;
192, 166, 111,  83,  76, 166, 255, 251, 255, 255;
255, 255, 255, 255, 251, 251, 251, 208, 255, 255;
192, 208, 251, 251, 251, 255, 251, 251, 255, 255;
255, 255, 255, 255, 255, 255, 255, 255, 255, 255
==CSV风格==
111, 111, 166, 192, 251, 255, 255, 255, 255, 255
111,  83,  93,  83, 102,  85, 255, 251, 255, 255
111,  83, 111, 102, 111, 140, 255, 255, 255, 255
111,  83, 111,  83, 111, 140, 255, 255, 255, 255
 83,  83, 111,  83, 111, 175, 255, 255, 255, 255
 83,  74,  93,  83, 111, 175, 255, 251, 255, 255
192, 166, 111,  83,  76, 166, 255, 251, 255, 255
255, 255, 255, 255, 251, 251, 251, 208, 255, 255
192, 208, 251, 251, 251, 255, 251, 251, 255, 255
255, 255, 255, 255, 255, 255, 255, 255, 255, 255

==Python风格==
[[111, 111, 166, 192, 251, 255, 255, 255, 255, 255],
 [111,  83,  93,  83, 102,  85, 255, 251, 255, 255],
 [111,  83, 111, 102, 111, 140, 255, 255, 255, 255],
 [111,  83, 111,  83, 111, 140, 255, 255, 255, 255],
 [ 83,  83, 111,  83, 111, 175, 255, 255, 255, 255],
 [ 83,  74,  93,  83, 111, 175, 255, 251, 255, 255],
 [192, 166, 111,  83,  76, 166, 255, 251, 255, 255],
 [255, 255, 255, 255, 251, 251, 251, 208, 255, 255],
 [192, 208, 251, 251, 251, 255, 251, 251, 255, 255],
 [255, 255, 255, 255, 255, 255, 255, 255, 255, 255]]
==Numpy风格==
array([[111, 111, 166, 192, 251, 255, 255, 255, 255, 255],
       [111,  83,  93,  83, 102,  85, 255, 251, 255, 255],
       [111,  83, 111, 102, 111, 140, 255, 255, 255, 255],
       [111,  83, 111,  83, 111, 140, 255, 255, 255, 255],
       [ 83,  83, 111,  83, 111, 175, 255, 255, 255, 255],
       [ 83,  74,  93,  83, 111, 175, 255, 251, 255, 255],
       [192, 166, 111,  83,  76, 166, 255, 251, 255, 255],
       [255, 255, 255, 255, 251, 251, 251, 208, 255, 255],
       [192, 208, 251, 251, 251, 255, 251, 251, 255, 255],
       [255, 255, 255, 255, 255, 255, 255, 255, 255, 255]], dtype='uint8')
==C风格==
{111, 111, 166, 192, 251, 255, 255, 255, 255, 255,
 111,  83,  93,  83, 102,  85, 255, 251, 255, 255,
 111,  83, 111, 102, 111, 140, 255, 255, 255, 255,
 111,  83, 111,  83, 111, 140, 255, 255, 255, 255,
  83,  83, 111,  83, 111, 175, 255, 255, 255, 255,
  83,  74,  93,  83, 111, 175, 255, 251, 255, 255,
 192, 166, 111,  83,  76, 166, 255, 251, 255, 255,
 255, 255, 255, 255, 251, 251, 251, 208, 255, 255,
 192, 208, 251, 251, 251, 255, 251, 251, 255, 255,
 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}
 

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/676466.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-04-19
下一篇 2022-04-19

发表评论

登录后才能评论

评论列表(0条)

保存