繁体   English   中英

如何使用 C++ 在 openCV 中显示图像元数据?

[英]How to display image metadata in openCV using c++?

我想选择一个图像并使用 opencv 和 c++ 显示其元数据,例如高度、宽度、rgb 值、格式等。 我怎样才能做到这一点?

方法一:

如果您想使用代码了解图像的高度、宽度和 rgb 值,您可以使用:

Mat img = imread("image.jpg");
cout<< "Width:" << img.cols << "Height:" << img.rows << endl; // width and height
cout<< img.at<cv::Vec3b>(i,j)[0] << endl; // This code gives you the pixel value of a chosen coordinate.
//i and j are your coordinates. and 0 represents the first layer of BGR 
//values. You can change it with 1 or 2 to learn the other layer values

方法二:

如果你想使用屏幕学习你想要的值,你可以简单地使用 opencv 的“imshow”功能。 从屏幕上您可以找到宽度和高度。 您还可以使用鼠标了解任意点的 rgb 值。 (您可以用鼠标缩放任何点)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM