@@ -2063,7 +2063,7 @@ class CV_EXPORTS Mat
2063
2063
2064
2064
/* * @brief Template matrix class derived from Mat
2065
2065
2066
- @code
2066
+ @code{.cpp}
2067
2067
template<typename _Tp> class Mat_ : public Mat
2068
2068
{
2069
2069
public:
@@ -2075,7 +2075,7 @@ class CV_EXPORTS Mat
2075
2075
The class `Mat_<_Tp>` is a *thin* template wrapper on top of the Mat class. It does not have any
2076
2076
extra data fields. Nor this class nor Mat has any virtual methods. Thus, references or pointers to
2077
2077
these two classes can be freely but carefully converted one to another. For example:
2078
- @code
2078
+ @code{.cpp}
2079
2079
// create a 100x100 8-bit matrix
2080
2080
Mat M(100,100,CV_8U);
2081
2081
// this will be compiled fine. no any data conversion will be done.
@@ -2087,7 +2087,7 @@ While Mat is sufficient in most cases, Mat_ can be more convenient if you use a
2087
2087
access operations and if you know matrix type at the compilation time. Note that
2088
2088
`Mat::at(int y,int x)` and `Mat_::operator()(int y,int x)` do absolutely the same
2089
2089
and run at the same speed, but the latter is certainly shorter:
2090
- @code
2090
+ @code{.cpp}
2091
2091
Mat_<double> M(20,20);
2092
2092
for(int i = 0; i < M.rows; i++)
2093
2093
for(int j = 0; j < M.cols; j++)
@@ -2097,7 +2097,7 @@ and run at the same speed, but the latter is certainly shorter:
2097
2097
cout << E.at<double>(0,0)/E.at<double>(M.rows-1,0);
2098
2098
@endcode
2099
2099
To use Mat_ for multi-channel images/matrices, pass Vec as a Mat_ parameter:
2100
- @code
2100
+ @code{.cpp}
2101
2101
// allocate a 320x240 color image and fill it with green (in RGB space)
2102
2102
Mat_<Vec3b> img(240, 320, Vec3b(0,255,0));
2103
2103
// now draw a diagonal white line
@@ -2107,6 +2107,17 @@ To use Mat_ for multi-channel images/matrices, pass Vec as a Mat_ parameter:
2107
2107
for(int i = 0; i < img.rows; i++)
2108
2108
for(int j = 0; j < img.cols; j++)
2109
2109
img(i,j)[2] ^= (uchar)(i ^ j);
2110
+ @endcode
2111
+ Mat_ is fully compatible with C++11 range-based for loop. For example such loop
2112
+ can be used to safely apply look-up table:
2113
+ @code{.cpp}
2114
+ void applyTable(Mat_<uchar>& I, const uchar* const table)
2115
+ {
2116
+ for(auto& pixel : I)
2117
+ {
2118
+ pixel = table[pixel];
2119
+ }
2120
+ }
2110
2121
@endcode
2111
2122
*/
2112
2123
template <typename _Tp> class Mat_ : public Mat
0 commit comments