1、cout:输出字符串
int a=100;
cout<<"a="<<a<<endl;
//控制台输出字符串“a=”,同时紧接着输出变量a的值100
//endl是换行
//需要iostream.h支持
2、cin:输入字符串
int b;
cin>>b;
//控制台中将整形数据传到变量b中
//需要iostream.h支持
3、imread:读取图片
//Loads an image from a file. 从文件中读取图像。
Mat imread(const string& filename, int flags )
>>Parameters: 参数:
- filename – Name of file to be loaded. 文件名
- flags –
Flags specifying the color type of a loaded image:
- >0 Return a 3-channel color image 返回一个三通道的图像
- =0 Return a grayscale image 返回灰度图像
- <0 Return the loaded image as is. Note that in the current implementation the alpha channel, if any, is stripped from the output image. For example, a 4-channel RGBA image is loaded as RGB if flag>=0
>>当flags==0时,可以通过a*R+b*G+c*B=value_grey可以求出RGB的三个权重分别为:
a=76/255=0.298
b=150/255=0.588
c=29/255=0.114
所以可以算出一个像素点的灰度值为:grey=0.298*red+0.588*green+0.114*blue
其中,red ∈(0,255),green ∈(0,255),blue ∈(0,255)
4、