stq054188

直接给出代码:

#include<iostream>
#include<opencv2/opencv.hpp>
 
using namespace std;
using namespace cv;
 
string Type2String(int type)
{
	string strType;
	uchar depth = type & CV_MAT_DEPTH_MASK;
	uchar chans = 1 + (type >> CV_CN_SHIFT);
	switch (depth) 
	{
		case CV_8U:  
			strType = "CV_8U"; break;
		case CV_8S:  
			strType = "CV_8S"; break;
		case CV_16U: 
			strType = "CV_16U"; break;
		case CV_16S: 
			strType = "CV_16S"; break;
		case CV_32S: 
			strType = "CV_32S"; break;
		case CV_32F: 
			strType = "CV_32F"; break;
		case CV_64F: 
			strType = "CV_64F"; break;
		default:  
			strType = "UNKNOWN_TYPE"; break;
	}
	strType += "C";
	strType += (chans + \'0\');
 
	return strType;
}
void main()
{
	Mat img = imread("1.tif", IMREAD_UNCHANGED);
	cout << img.type() << endl;
	cout << Type2String(img.type()) << endl;
}

输出结果:

 

 

 

 

  

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2021-03-30
  • 2021-12-27
  • 2021-12-16
  • 2021-05-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-16
猜你喜欢
  • 2022-12-23
  • 2021-09-07
  • 2021-10-11
  • 2022-01-22
  • 2022-03-07
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案