- 컴퓨터 비전 시리즈는 한동대학교 황성수 교수님의 컴퓨터비전 강의를 공부하며 정리한 내용입니다.
• Mat (int rows, int cols, int type)
• Mat (Size size, int type)
• Mat (const Mat & m)
• Mat (Size size, int type, const Scalar& s)
Mat mtx(3, 3, CV_32F);
// make a 3x3 floating-point matrix
Mat mtx(10, 1, CV_64FC2);
// make a 10x1 2-channel floating-point matrix
(10-element complex vector)
Mat img(1080, 1920, CV_8UC3);
// make a 3-channel (color) image of 1920 columns and 1080 rows.
Mat img(Size(1920, 1080), CV_8UC3);
// make a 3-channel (color) image of 1920 columns and 1080 rows.
int main() {
Mat m1 = (Mat_ < double >(3, 3)
<< 1, 2, 3, 4, 5, 6, 7, 8, 9);
Mat m_shallow = m1;
Mat m_deep = m1.clone();
cout << "m1 =\n" << m1 << endl << endl;
cout << "m_shallow =\n" << m_shallow << endl << endl; cout << "m_deep =\n" << m_deep << endl << endl;
// Update m1
m1.at < double >(0, 0) = 100;
cout << "m1 =\n" << m1 << endl << endl;
cout << "m_shallow =\n" << m_shallow << endl << endl; cout << "m_deep =\n" << m_deep << endl << endl;
waitKey(0);
}
Mat convertTo(OutputArray m, int rtype, double alpha=1, double beta=0)
Mat setTo(InputArray value, InputArray mask=noArray())
void convertScaleAbs(InputArray src, OutputArray dst, double alpha=1, double beta=0)
• CV_8U: 8-bit unsigned integer: uchar ( 0~255 )
• CV_8S: 8-bit signed integer: schar ( -128~127 )
• CV_16U: 16-bit unsigned integer: ushort ( 0~65535 )
• CV_16S: 16-bit signed integer: short ( -32768~32767 )
• CV_32S: 32-bit signed integer: int ( -2147483648~2147483647 )
• CV_32F: 32-bit floating-point number: float ( -FLT_MAX~FLT_MAX, INF, NAN )
• CV_64F: 64-bit floating-point number: double (-DBL_MAX~ DBL_MAX, INF, NAN )
• Multi-channel array:
CV_8UC3, CV_8U(3), CV_64FC4, CV_64FC(4)