Mat deposit using OpenCV image, there is a special image format.
Naming Rules
Generic parameter names of the form:
Bits of the number of elements CV_ {} {} element type channels} C {
For example, the most common CV_8UC3 in:
- 8U:8bit unsigned ;
- C3: channel number 3.
therefore,
- CV_8UC3 would be represented as 3-channel Unsigned 8bits matrix format, that is, we often say BGR3 channel .
There are similar: CV_8UC1, CV_8UC2, CV_8UC3 and so on. - Some image storage format is 32 a float , the corresponding image format: CV_32FC1, CV_32FC2, CV_32FC3 the like;
- If the picture format is stored in 64-bit Double , the corresponding image format: CV_64FC1, CV_64FC2, CV_64FC3 like.
int value mappings
Data types may also be a different matrix element of the int value instead, the corresponding relationship is as follows:
Number of channels | C1 | C2 | C3 | C4 |
---|---|---|---|---|
CV_8U | 0 | 8 | 16 | 24 |
CV_8S | 1 | 9 | 17 | 25 |
CV_16U | 2 | 10 | 18 | 26 |
CV_16S | 3 | 11 | 19 | 27 |
CV_32S | 4 | 12 | 20 | 28 |
CV_32F | 5 | 13 | 21 | 29 |
CV_64F | 6 | 14 | 22 | 30 |
7
The reason is skipped, because the numbers reserved for user-defined:
#define CV_USRTYPE1 7
Ranges
Numerical | Specific types | Ranges |
---|---|---|
CV_8U | 8-bit unsigned integer | 0 ~ 255 |
CV_8S | 8 signed integer | -128 ~ 127 |
CV_16U | 16-bit unsigned integer | 0 ~ 65535 |
CV_16S | 16-bit signed integer | -32768 ~ 32767 |
CV_32S | 32-bit signed integer | -2147483648 ~ 2147483647 |
CV_32F | 32-bit floating point | -FLT_MAX ~ FLT_MAX,INF,NAN |
CV_64F | 64-bit floating point | -DBL_MAX ~ DBL_MAX,INF,NAN |
The type of data being accessed at
Because at acceptable method it is uchar such data type, not CV_8U.
If the access method to be used at the data element, the number of channels in the case of a known type and data of each channel assigned to the data type at the method shown in the following table:
C1 | C2 | C3 | C4 | C6 | |
---|---|---|---|---|---|
flying | flying | cv :: Vec2b | cv :: Vec3b | cv :: Vec4b | |
short | short | cv :: Vec2s | cv :: Vec3s | cv::Vec4s | |
int | int | cv :: Vec2i | cv :: Vec3i | cv :: Vec4i | |
float | float | cv :: Vec2f | cv :: Vec3f | cv :: Vec4f | cv :: Vec6f |
double | double | cv :: Vec2d | cv :: Vec3d | cv :: Vec4d | cv :: Vec6d |
among them,
- Vec2b: Vec2b represent each object may be stored in two char (char) data
- Vec3b: Vec3b representing each object can be stored 3 char (character) data, such as using such objects, to store RGB image
- Vec4b: Vec4b representing each object, character data can be stored in four can be used to store such a class object RGB + Alpha FIG passage -4
Corresponding Vec class is defined as follows:
template<typename _Tp, int n> class Vec : public Matx<_Tp, n, 1> {...};
typedef Vec<uchar, 2> Vec2b;
typedef Vec<uchar, 3> Vec3b;
typedef Vec<uchar, 4> Vec4b;
typedef Vec<short, 2> Vec2s;
typedef Vec<short, 3> Vec3s;
typedef Vec<short, 4> Vec4s;
typedef Vec<int, 2> Vec2i;
typedef Vec<int, 3> Vec3i;
typedef Vec<int, 4> Vec4i;
typedef Vec<float, 2> Vec2f;
typedef Vec<float, 3> Vec3f;
typedef Vec<float, 4> Vec4f;
typedef Vec<float, 6> Vec6f;
typedef Vec<double, 2> Vec2d;
typedef Vec<double, 3> Vec3d;
typedef Vec<double, 4> Vec4d;
typedef Vec<double, 6> Vec6d;
references
[. 1] Interface
[2] the LIST. OF MAT the TYPE OPENCV the IN
[. 3] CV_8UC1, CV_8UC2, meaning CV_8UC3 Vec2b Vec3b Vec4b
[4] to determine the data type of matrix elements OpenCV