直接上源码:
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文章来源:https://www.toymoban.com/news/detail-403406.html
==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}
文章来源地址https://www.toymoban.com/news/detail-403406.html
到了这里,关于C++如何打印输出OpenCV的Mat对象的像素数据?的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!