创建opencv Matrix时候的type

opencv matrix type:
CV_[The number of bits per item][Signed or Unsigned][Type Prefix]C[The channel
number]
CV_{U|S|F}C(<number_of_channels>)

M1 with one channel =
[255, 255;
255, 255]

M2 with two channel =
[0, 255, 0, 255;
0, 255, 0, 255]

M3 with three channel =
[0, 0, 255, 0, 0, 255;
0, 0, 255, 0, 0, 255]

#include "opencv/cv.h"
#include <iostream>

using namespace std;
using namespace cv;

int main(char* args) {
  Mat M1(2,2, CV_8UC1, 255);
  Mat M2(2,2, CV_8UC2, Scalar(0,255));
  Mat M3(2,2, CV_8UC3, Scalar(0,0,255));

  cout << "M1 with one channel = "<< endl << " "  << M1 << endl << endl;
  cout << "M2 with two channel = "<< endl << " "  << M2 << endl << endl;
  cout << "M3 with three channel = "<< endl << " "  << M3 << endl << endl;

  M1.create(4,4, CV_8UC(2));
  cout << "M1 = "<< endl << " "  << M1 << endl << endl;

  Scalar s1(1);
  Scalar s2(1, 2);
  Scalar s3(1, 2, 3);
  Scalar s4(1, 2, 3, 4);
  Scalar s5(1, 2, 3, 5);
//  Scalar s(1, 2, 3, 5, 6, 7, 8, 9);
  cout << "scalar s1 "<< endl << " "  << s1 << endl << endl;
  cout << "scalar s2 "<< endl << " "  << s2 << endl << endl;
  cout << "scalar s3 "<< endl << " "  << s3 << endl << endl;
  cout << "scalar s4 "<< endl << " "  << s4 << endl << endl;
  cout << "scalar s5 "<< endl << " "  << s5 << endl << endl;
//  cout << "scalar s5 "<< endl << " "  << s << endl << endl;

}

http://stackoverflow.com/questions/8377091/what-are-the-differences-between-
cv-8u-and-cv-32f-and-what-should-i-worry-about

http://docs.opencv.org/java/org/opencv/core/CvType.html

注释: 只有二位的matrix可以打印,多维的话,你自己需要写输出方法