OpenCV显示图像type位深度输出

直接给出代码:

#include
#include
 
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;
}

OpenCV显示图像type位深度输出_第1张图片

输出结果:

 

 

 

 

  

你可能感兴趣的:(OpenCV显示图像type位深度输出)