日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

OpenCV Mat数据类型像素操作

發(fā)布時(shí)間:2023/12/4 编程问答 22 豆豆
生活随笔 收集整理的這篇文章主要介紹了 OpenCV Mat数据类型像素操作 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

?轉(zhuǎn)自:http://blog.csdn.net/skeeee/article/details/13297457?

OpenCV圖像像素操作及效率分析

? ? ? ? 在計(jì)算機(jī)視覺應(yīng)用中,對(duì)于圖像內(nèi)容的讀取分析是第一步,所以學(xué)習(xí)高效的處理圖像是很有用的。一個(gè)圖像有可能包含數(shù)以萬計(jì)的像素,從根本上說圖像就是一系列像素值,所以O(shè)penCV使用數(shù)據(jù)結(jié)構(gòu)cv::Mat來表示圖像。矩陣中每一個(gè)元素都代表一個(gè)像素,對(duì)于灰度圖像,像素用8位無符號(hào)數(shù),0表示黑色,255表示白色。對(duì)于彩色像素而言,每個(gè)像素需要三位這樣的8位無符號(hào)數(shù)來表示,即三個(gè)通道(R,G,B),矩陣則依次存儲(chǔ)一個(gè)像素的三個(gè)通道的值,然后再存儲(chǔ)下一個(gè)像素點(diǎn)。

? ? ? ?cv::Mat中,成員變量cols代表圖像的寬度(圖像的列數(shù)),成員變量rows代表圖像的高度(圖像的行數(shù)),step代表以字節(jié)為單位的圖像的有效寬度,elemSize返回像素的大小,像素的大小 = 顏色大小(字節(jié))*通道數(shù),比如三通道short型矩陣(CV_16SC3)的大小為2*3 = 6,像素的channels方法返回圖像的通道數(shù),total函數(shù)返回圖像的像素?cái)?shù)。

? ? ? ?閑話少說直接介紹幾種讀取方式:

? ? ? ?RGB圖像的顏色數(shù)目是256*256*256,本文對(duì)圖像進(jìn)行量化,縮減顏色數(shù)目到256的1/8(即32*32*32)為目標(biāo),分別利用一下幾種方法實(shí)現(xiàn),比較幾種方法的安全和效率。

? ? ? ?1.ptr遍歷圖像

? ? ? ?cv::Mat中提供ptr函數(shù)訪問任意一行像素的首地址,特別方便圖像的一行一行的橫向訪問,如果需要一列一列的縱向訪問圖像,就稍微麻煩一點(diǎn)。但是ptr訪問效率比較高,程序也比較安全,有越界判斷。

[cpp]?view plain?copy ?
  • int?nl=?image.rows;?//行數(shù)??
  • int?nc=?image.cols?*?image.channels();?//?每行的元素個(gè)數(shù),每行的像素?cái)?shù)*顏色通道數(shù)(RGB?=?3)??
  • ??????????
  • for?(int?j=0;?j<nl;?j++)?{??
  • ????uchar*?data=?image.ptr<uchar>(j);??
  • ????for?(int?i=0;?i<nc;?i++)?{???
  • ??????//?process?each?pixel?---------------------????????????????
  • ?????????data[i]=?data[i]/div*div?+?div/2;??
  • ??????//?end?of?pixel?processing?----------------??
  • ????}?//?end?of?line?????????????????????
  • }??
  • ? ?? 也可以使用:

    [cpp]?view plain?copy ?
  • ????for?(int?j=0;?j<nl;?j++)?{??
  • ?uchar*?data=?image.ptr<uchar>(j);??
  • ????????for?(int?i=0;?i<nc;?i++)?{??
  • ??????????//?process?each?pixel?---------------------?????????????????
  • *data++=?*data/div*div?+?div/2;??
  • ??????????//?end?of?pixel?processing?----------------??
  • ??????????}?//?end?of?line?????????????????????
  • ????}??
  • ? ?

    2.使用迭代器遍歷圖像

    ? ? ?cv::Mat 同樣有標(biāo)準(zhǔn)模板庫(STL),可以使用迭代器訪問數(shù)據(jù)。

    ? ? ?用迭代器來遍歷圖像像素,可簡化過程降低出錯(cuò)的機(jī)會(huì),比較安全,不過效率較低;如果想避免修改輸入圖像實(shí)例cv::Mat,可采用const_iterator。iterator有兩種調(diào)用方法,cv::MatIterator_<cv::Vec3b> it;cv::Mat_<cv::Vec3b>::iterator it;中間cv::Vec3b是因?yàn)閳D像是彩色圖像,3通道,cv::Vec3b可以代表一個(gè)像素。

    [cpp]?view plain?copy ?
  • //?get?iterators??
  • ??????cv::Mat_<cv::Vec3b>::iterator?it=?image.begin<cv::Vec3b>();??
  • ??????cv::Mat_<cv::Vec3b>::iterator?itend=?image.end<cv::Vec3b>();??
  • ??
  • ??????for?(?;?it!=?itend;?++it)?{??
  • ??????????
  • ????????//?process?each?pixel?---------------------??
  • ??
  • ????????(*it)[0]=?(*it)[0]/div*div?+?div/2;??
  • ????????(*it)[1]=?(*it)[1]/div*div?+?div/2;??
  • ????????(*it)[2]=?(*it)[2]/div*div?+?div/2;??
  • ??
  • ????????//?end?of?pixel?processing?----------------??
  • ??????}??
  • ?3.at方法遍歷

    ? ? ? cv::Mat也是向量,可以使at方法取值,使用調(diào)用方法image.at<cv::Vec3b>(j,i),at方法方便,直接給i,j賦值就可以隨意訪問圖像中任何一個(gè)像素,其中j表示第j行,i表示該行第i個(gè)像素。但是at方法效率是這3中訪問方法中最慢的一個(gè),所以如果遍歷圖像或者訪問像素比較多時(shí),建議不要使用這個(gè)方法,畢竟程序的效率還是比程序的可讀性要重要的。下面是完整的調(diào)用方法,其運(yùn)行時(shí)間在下面會(huì)介紹。

    [cpp]?view plain?copy ?
  • int?nl=?image.rows;?//?number?of?lines??
  • int?nc=?image.cols;?//?number?of?columns??
  • ?????????????
  • ???for?(int?j=0;?j<nl;?j++)?{??
  • ???????for?(int?i=0;?i<nc;?i++)?{??
  • ??
  • ?????????//?process?each?pixel?---------------------??
  • ????????????????
  • ???????????????image.at<cv::Vec3b>(j,i)[0]=????image.at<cv::Vec3b>(j,i)[0]/div*div?+?div/2;??
  • ???????????????image.at<cv::Vec3b>(j,i)[1]=????image.at<cv::Vec3b>(j,i)[1]/div*div?+?div/2;??
  • ???????????????image.at<cv::Vec3b>(j,i)[2]=????image.at<cv::Vec3b>(j,i)[2]/div*div?+?div/2;??
  • ??
  • ?????????//?end?of?pixel?processing?----------------??
  • ??
  • ?????????}?//?end?of?line?????????????????????
  • ???}??
  • [cpp]?view plain?copy ?
  • ??
  • ??4.row(i),col(i)

    ? ? ? ?cv::Mat提供image.row(i),和image.col(j)對(duì)圖像整行和整列進(jìn)行處理,處理比較方便,因?yàn)楹苌儆龅?#xff0c;所以就沒有進(jìn)行效率比較

    ? 程序代碼如下(三通道):

    [cpp]?view plain?copy ?
  • result.row(0).setTo(cv::Scalar(0,0,0));//將第一行數(shù)據(jù)設(shè)為零??
  • ????result.row(result.rows-1).setTo(cv::Scalar(0,0,0));//將最后一行數(shù)據(jù)設(shè)置為零??
  • ????result.col(0).setTo(cv::Scalar(0,0,0));//將第一列數(shù)據(jù)設(shè)為零??
  • ????result.col(result.cols-1).setTo(cv::Scalar(0,0,0));//將最后一列數(shù)據(jù)設(shè)為零??
  • 5.高效率圖像遍歷循環(huán)

    ? ? ? ?對(duì)于迭代的for循環(huán),外面一層的循環(huán)次數(shù)越少速度越快,同樣是cols*rows*channels()次循環(huán),使用nc = cols,nl = rows*channels(),與使用nc = cols*rows*channels,nl = 1,以及nc = cols,nl = rows,for函數(shù)最里層運(yùn)行三次顏色的處理。這三種方法最快的是第二種,第三種其次,最慢的是第一種. ?

    [cpp]?view plain?copy ?
  • int?nl=?image.rows;?//?number?of?lines??
  • int?nc=?image.cols?*?image.channels();?//?total?number?of?elements?per?line??
  • ??
  • if?(image.isContinuous())??{??
  • ?//?then?no?padded?pixels??
  • ?nc=?nc*nl;???
  • ?nl=?1;??//?it?is?now?a?1D?array??
  • ?}??
  • ??
  • int?n=?static_cast<int>(log(static_cast<double>(div))/log(2.0));??
  • //?mask?used?to?round?the?pixel?value??
  • uchar?mask=?0xFF<<n;?//?e.g.?for?div=16,?mask=?0xF0??
  • ?????????????
  • ???for?(int?j=0;?j<nl;?j++)?{??
  • ??
  • ?uchar*?data=?image.ptr<uchar>(j);??
  • ??
  • ???????for?(int?i=0;?i<nc;?i++)?{??
  • ??
  • ?????????//?process?each?pixel?---------------------??
  • ????????????????
  • ?????????*data++=?*data&mask?+?div/2;??
  • ??
  • ?????????//?end?of?pixel?processing?----------------??
  • ??
  • ?????????}?//?end?of?line?????????????????????
  • ???}??
  • ???6.位運(yùn)算代替乘法和除法

    [cpp]?view plain?copy ?
  • ???????int?nl=?image.rows;?//?number?of?lines??
  • int?nc=?image.cols?*?image.channels();?//?total?number?of?elements?per?line??
  • int?n=?static_cast<int>(log(static_cast<double>(div))/log(2.0));??
  • //?mask?used?to?round?the?pixel?value??
  • uchar?mask=?0xFF<<n;?//?e.g.?for?div=16,?mask=?0xF0??
  • ?????????????
  • ???for?(int?j=0;?j<nl;?j++)?{??
  • ??
  • ?uchar*?data=?image.ptr<uchar>(j);??
  • ??
  • ???????for?(int?i=0;?i<nc;?i++)?{??
  • ??
  • ?????????//?process?each?pixel?---------------------??
  • ????????????????
  • ?????????*data++=?*data&mask?+?div/2;??
  • ??
  • ?????????//?end?of?pixel?processing?----------------??
  • ??
  • ?????????}?//?end?of?line?????????????????????
  • ???}??

  • 運(yùn)行時(shí)間比較,以測(cè)試圖片為例,(Debug模式下的時(shí)間)

    ? ?ptr函數(shù)的兩種方法的時(shí)間:
    ? ? ? ? ? ? ? ? using .ptr and [] = 3.50202ms
    ? ? ? ? ? ? ? ? using .ptr and * ++ = 3.26124ms
    ? ?迭代器方法:
    ? ? ? ? ? ? ? using Mat_ iterator = 143.06ms
    ? ?at方法的運(yùn)行時(shí)間:
    ? ? ? ? ? ? ?using at = 252.779ms
    ? ?高效率迭代方法:
    ? ? ? ? ? ? using .ptr and * ++ and bitwise (continuous) = 2.68335ms
    ? ?位運(yùn)算方法:

    ? ? ? ? ? ? using .ptr and * ++ and bitwise =2.59823ms


    還有一些比較的函數(shù)方法,現(xiàn)在只給出運(yùn)行時(shí)間:
    ? ? ? ? ?using .ptr and * ++ and modulo =3.78029ms
    ? ? ? ? ?using .ptr and * ++ and bitwise =2.59823ms
    ? ? ? ? ?using direct pointer arithmetic =2.57317ms
    ? ? ? ? ?using .ptr and * ++ and bitwise with image.cols * image.channels() =22.864ms
    ? ? ? ? ?using Mat_ iterator and bitwise =139.92ms
    ? ? ? ? ?using MatIterator_ =185.996ms
    ? ? ? ? using .ptr and * ++ and bitwise (continuous+channels) =2.11271ms
    ? ? ? ? ?using input/output images =2.97717ms
    ? ? ? ? ?using overloaded operators =2.7237ms


    源圖像:


    量化處理結(jié)果 image1:


    量化處理后的結(jié)果 image2:

    附:OpenCV數(shù)據(jù)類型列表?

    class ? cv::_InputArray
    ? This is the proxy class for passing read-only input arrays into OpenCV functions.?More...
    ?
    class ? cv::_InputOutputArray
    ?
    class ? cv::_OutputArray
    ? This type is very similar to InputArray except that it is used for input/output and output function parameters.?More...
    ?
    class ? cv::Algorithm
    ? This is a base class for all more or less complex algorithms in OpenCV.?More...
    ?
    class ? cv::Complex< _Tp >
    ? A complex number class.?More...
    ?
    class ? cv::DataDepth< _Tp >
    ? A helper class for?cv::DataType.?More...
    ?
    class ? cv::DataType< _Tp >
    ? Template "trait" class for OpenCV primitive data types.?More...
    ?
    class ? cv::DMatch
    ? Class for matching keypoint descriptors.?More...
    ?
    class ? cv::Formatted
    ?
    class ? cv::Formatter
    ?
    class ? cv::KeyPoint
    ? Data structure for salient point detectors.?More...
    ?
    class ? cv::Mat
    ? n-dimensional dense array class?More...
    ?
    class ? cv::Mat_< _Tp >
    ? Template matrix class derived from?Mat.?More...
    ?
    class ? cv::MatAllocator
    ? Custom array allocator.?More...
    ?
    class ? cv::MatCommaInitializer_< _Tp >
    ? Comma-separated Matrix Initializer.?More...
    ?
    class ? cv::MatConstIterator
    ?
    class ? cv::MatConstIterator_< _Tp >
    ? Matrix read-only iterator.?More...
    ?
    class ? cv::MatExpr
    ? Matrix expression representation.?More...
    ?
    class ? cv::MatIterator_< _Tp >
    ? Matrix read-write iterator.?More...
    ?
    class ? cv::MatOp
    ?
    struct ? cv::MatSize
    ?
    struct ? cv::MatStep
    ?
    class ? cv::Matx< _Tp, m, n >
    ? Template class for small matrices whose type and size are known at compilation time.?More...
    ?
    class ? cv::MatxCommaInitializer< _Tp, m, n >
    ? Comma-separated Matrix Initializer.?More...
    ?
    class ? cv::NAryMatIterator
    ? n-ary multi-dimensional array iterator.?More...
    ?
    struct ? cv::Param
    ?
    struct ? cv::ParamType< _Tp >
    ?
    struct ? cv::ParamType< Algorithm >
    ?
    struct ? cv::ParamType< bool >
    ?
    struct ? cv::ParamType< double >
    ?
    struct ? cv::ParamType< float >
    ?
    struct ? cv::ParamType< Mat >
    ?
    struct ? cv::ParamType< std::vector< Mat > >
    ?
    struct ? cv::ParamType< String >
    ?
    struct ? cv::ParamType< uchar >
    ?
    struct ? cv::ParamType< uint64 >
    ?
    struct ? cv::ParamType< unsigned >
    ?
    class ? cv::Point3_< _Tp >
    ? Template class for 3D points specified by its coordinates?x,?y?and?z.?More...
    ?
    class ? cv::Point_< _Tp >
    ? Template class for 2D points specified by its coordinates?x?and?y.?More...
    ?
    struct ? cv::Ptr< T >
    ? Template class for smart pointers with shared ownership.?More...
    ?
    class ? cv::Range
    ? Template class specifying a continuous subsequence (slice) of a sequence.?More...
    ?
    class ? cv::Rect_< _Tp >
    ? Template class for 2D rectangles.?More...
    ?
    class ? cv::RotatedRect
    ? The class represents rotated (i.e. not up-right) rectangles on a plane.?More...
    ?
    class ? cv::Scalar_< _Tp >
    ? Template class for a 4-element vector derived from?Vec.?More...
    ?
    class ? cv::Size_< _Tp >
    ? Template class for specifying the size of an image or rectangle.?More...
    ?
    class ? cv::SparseMat
    ? The class?SparseMat?represents multi-dimensional sparse numerical arrays.?More...
    ?
    class ? cv::SparseMat_< _Tp >
    ? Template sparse n-dimensional array class derived from?SparseMat.?More...
    ?
    class ? cv::SparseMatConstIterator
    ? Read-Only Sparse Matrix Iterator.?More...
    ?
    class ? cv::SparseMatConstIterator_< _Tp >
    ? Template Read-Only Sparse Matrix Iterator Class.?More...
    ?
    class ? cv::SparseMatIterator
    ? Read-write Sparse Matrix Iterator.?More...
    ?
    class ? cv::SparseMatIterator_< _Tp >
    ? Template Read-Write Sparse Matrix Iterator Class.?More...
    ?
    class ? cv::String
    ?
    class ? cv::TermCriteria
    ? The class defining termination criteria for iterative algorithms.?More...
    ?
    class ? cv::TypeDepth< _depth >
    ?
    class ? cv::TypeDepth< CV_16S >
    ?
    class ? cv::TypeDepth< CV_16U >
    ?
    class ? cv::TypeDepth< CV_32F >
    ?
    class ? cv::TypeDepth< CV_32S >
    ?
    class ? cv::TypeDepth< CV_64F >
    ?
    class ? cv::TypeDepth< CV_8S >
    ?
    class ? cv::TypeDepth< CV_8U >
    ?
    class ? cv::UMat
    ?
    struct ? cv::UMatData
    ?
    struct ? cv::UMatDataAutoLock
    ?
    class ? cv::Vec< _Tp, cn >
    ? Template class for short numerical vectors, a partial case of?Matx.?More...
    ?
    class ? cv::VecCommaInitializer< _Tp, m >
    ? Comma-separated?Vec?Initializer.?More...
    ?

    Typedefs

    typedef?Complex< double >? cv::Complexd
    ?
    typedef?Complex< float >? cv::Complexf
    ?
    typedef const?_InputArray?&? cv::InputArray
    ?
    typedef?InputArray? cv::InputArrayOfArrays
    ?
    typedef const?_InputOutputArray?&? cv::InputOutputArray
    ?
    typedef?InputOutputArray? cv::InputOutputArrayOfArrays
    ?
    typedef?Mat_<?uchar?>? cv::Mat1b
    ?
    typedef?Mat_< double >? cv::Mat1d
    ?
    typedef?Mat_< float >? cv::Mat1f
    ?
    typedef?Mat_< int >? cv::Mat1i
    ?
    typedef?Mat_< short >? cv::Mat1s
    ?
    typedef?Mat_<?ushort?>? cv::Mat1w
    ?
    typedef?Mat_<?Vec2b?>? cv::Mat2b
    ?
    typedef?Mat_<?Vec2d?>? cv::Mat2d
    ?
    typedef?Mat_<?Vec2f?>? cv::Mat2f
    ?
    typedef?Mat_<?Vec2i?>? cv::Mat2i
    ?
    typedef?Mat_<?Vec2s?>? cv::Mat2s
    ?
    typedef?Mat_<?Vec2w?>? cv::Mat2w
    ?
    typedef?Mat_<?Vec3b?>? cv::Mat3b
    ?
    typedef?Mat_<?Vec3d?>? cv::Mat3d
    ?
    typedef?Mat_<?Vec3f?>? cv::Mat3f
    ?
    typedef?Mat_<?Vec3i?>? cv::Mat3i
    ?
    typedef?Mat_<?Vec3s?>? cv::Mat3s
    ?
    typedef?Mat_<?Vec3w?>? cv::Mat3w
    ?
    typedef?Mat_<?Vec4b?>? cv::Mat4b
    ?
    typedef?Mat_<?Vec4d?>? cv::Mat4d
    ?
    typedef?Mat_<?Vec4f?>? cv::Mat4f
    ?
    typedef?Mat_<?Vec4i?>? cv::Mat4i
    ?
    typedef?Mat_<?Vec4s?>? cv::Mat4s
    ?
    typedef?Mat_<?Vec4w?>? cv::Mat4w
    ?
    typedef?Matx< double, 1, 2 >? cv::Matx12d
    ?
    typedef?Matx< float, 1, 2 >? cv::Matx12f
    ?
    typedef?Matx< double, 1, 3 >? cv::Matx13d
    ?
    typedef?Matx< float, 1, 3 >? cv::Matx13f
    ?
    typedef?Matx< double, 1, 4 >? cv::Matx14d
    ?
    typedef?Matx< float, 1, 4 >? cv::Matx14f
    ?
    typedef?Matx< double, 1, 6 >? cv::Matx16d
    ?
    typedef?Matx< float, 1, 6 >? cv::Matx16f
    ?
    typedef?Matx< double, 2, 1 >? cv::Matx21d
    ?
    typedef?Matx< float, 2, 1 >? cv::Matx21f
    ?
    typedef?Matx< double, 2, 2 >? cv::Matx22d
    ?
    typedef?Matx< float, 2, 2 >? cv::Matx22f
    ?
    typedef?Matx< double, 2, 3 >? cv::Matx23d
    ?
    typedef?Matx< float, 2, 3 >? cv::Matx23f
    ?
    typedef?Matx< double, 3, 1 >? cv::Matx31d
    ?
    typedef?Matx< float, 3, 1 >? cv::Matx31f
    ?
    typedef?Matx< double, 3, 2 >? cv::Matx32d
    ?
    typedef?Matx< float, 3, 2 >? cv::Matx32f
    ?
    typedef?Matx< double, 3, 3 >? cv::Matx33d
    ?
    typedef?Matx< float, 3, 3 >? cv::Matx33f
    ?
    typedef?Matx< double, 3, 4 >? cv::Matx34d
    ?
    typedef?Matx< float, 3, 4 >? cv::Matx34f
    ?
    typedef?Matx< double, 4, 1 >? cv::Matx41d
    ?
    typedef?Matx< float, 4, 1 >? cv::Matx41f
    ?
    typedef?Matx< double, 4, 3 >? cv::Matx43d
    ?
    typedef?Matx< float, 4, 3 >? cv::Matx43f
    ?
    typedef?Matx< double, 4, 4 >? cv::Matx44d
    ?
    typedef?Matx< float, 4, 4 >? cv::Matx44f
    ?
    typedef?Matx< double, 6, 1 >? cv::Matx61d
    ?
    typedef?Matx< float, 6, 1 >? cv::Matx61f
    ?
    typedef?Matx< double, 6, 6 >? cv::Matx66d
    ?
    typedef?Matx< float, 6, 6 >? cv::Matx66f
    ?
    typedef const?_OutputArray?&? cv::OutputArray
    ?
    typedef?OutputArray? cv::OutputArrayOfArrays
    ?
    typedef?Point2i? cv::Point
    ?
    typedef?Point_< double >? cv::Point2d
    ?
    typedef?Point_< float >? cv::Point2f
    ?
    typedef?Point_< int >? cv::Point2i
    ?
    typedef?Point3_< double >? cv::Point3d
    ?
    typedef?Point3_< float >? cv::Point3f
    ?
    typedef?Point3_< int >? cv::Point3i
    ?
    typedef?Rect2i? cv::Rect
    ?
    typedef?Rect_< double >? cv::Rect2d
    ?
    typedef?Rect_< float >? cv::Rect2f
    ?
    typedef?Rect_< int >? cv::Rect2i
    ?
    typedef?Scalar_< double >? cv::Scalar
    ?
    typedef?Size2i? cv::Size
    ?
    typedef?Size_< double >? cv::Size2d
    ?
    typedef?Size_< float >? cv::Size2f
    ?
    typedef?Size_< int >? cv::Size2i
    ?

    Enumerations

    enum ? {?
    ??cv::ACCESS_READ?=1<<24,?
    ??cv::ACCESS_WRITE?=1<<25,?
    ??cv::ACCESS_RW?=3<<24,?
    ??cv::ACCESS_MASK?=ACCESS_RW,?
    ??cv::ACCESS_FAST?=1<<26?
    }
    ?
    enum ? cv::UMatUsageFlags?{?
    ??cv::USAGE_DEFAULT?= 0,?
    ??cv::USAGE_ALLOCATE_HOST_MEMORY?= 1 << 0,?
    ??cv::USAGE_ALLOCATE_DEVICE_MEMORY?= 1 << 1,?
    ??cv::USAGE_ALLOCATE_SHARED_MEMORY?= 1 << 2,?
    ??cv::__UMAT_USAGE_FLAGS_32BIT?= 0x7fffffff?
    }
    ? Usage flags for allocator.?More...
    ?

    Functions

    template<typename _Tp , int m>
    static double? cv::determinant?(const?Matx< _Tp, m, m > &a)
    ?
    template<typename T >
    Ptr< T >? cv::makePtr?()
    ?
    template<typename T , typename A1 >
    Ptr< T >? cv::makePtr?(const A1 &a1)
    ?
    template<typename T , typename A1 , typename A2 >
    Ptr< T >? cv::makePtr?(const A1 &a1, const A2 &a2)
    ?
    template<typename T , typename A1 , typename A2 , typename A3 >
    Ptr< T >? cv::makePtr?(const A1 &a1, const A2 &a2, const A3 &a3)
    ?
    template<typename T , typename A1 , typename A2 , typename A3 , typename A4 >
    Ptr< T >? cv::makePtr?(const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4)
    ?
    template<typename T , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 >
    Ptr< T >? cv::makePtr?(const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5)
    ?
    template<typename T , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 >
    Ptr< T >? cv::makePtr?(const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6)
    ?
    template<typename T , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7 >
    Ptr< T >? cv::makePtr?(const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7)
    ?
    template<typename T , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7 , typename A8 >
    Ptr< T >? cv::makePtr?(const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7, const A8 &a8)
    ?
    template<typename T , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7 , typename A8 , typename A9 >
    Ptr< T >? cv::makePtr?(const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7, const A8 &a8, const A9 &a9)
    ?
    template<typename T , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7 , typename A8 , typename A9 , typename A10 >
    Ptr< T >? cv::makePtr?(const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7, const A8 &a8, const A9 &a9, const A10 &a10)
    ?
    InputOutputArray? cv::noArray?()
    ?
    template<typename _Tp , int m, int n>
    static double? cv::norm?(const?Matx< _Tp, m, n > &M)
    ?
    template<typename _Tp , int m, int n>
    static double? cv::norm?(const?Matx< _Tp, m, n > &M, int normType)
    ?
    template<typename _Tp , int cn>
    static?Vec< _Tp, cn >? cv::normalize?(const?Vec< _Tp, cn > &v)
    ?
    template<typename T >
    bool? cv::operator !=?(const?Ptr< T > &ptr1, const?Ptr< T > &ptr2)
    ?
    static?String?&? cv::operator<<?(String?&out,?Ptr<?Formatted?> fmtd)
    ?
    static?String?&? cv::operator<<?(String?&out, const?Mat?&mtx)
    ?
    template<typename T >
    bool? cv::operator==?(const?Ptr< T > &ptr1, const?Ptr< T > &ptr2)
    ?
    template<typename T >
    void? cv::swap?(Ptr< T > &ptr1,?Ptr< T > &ptr2)
    ?
    template<typename _Tp , int m, int n>
    static double? cv::trace?(const?Matx< _Tp, m, n > &a)
    ?

    Shorter aliases for the most popular specializations of Vec<T,n>

    typedef?Vec<?uchar, 2 >? cv::Vec2b
    ?
    typedef?Vec<?uchar, 3 >? cv::Vec3b
    ?
    typedef?Vec<?uchar, 4 >? cv::Vec4b
    ?
    typedef?Vec< short, 2 >? cv::Vec2s
    ?
    typedef?Vec< short, 3 >? cv::Vec3s
    ?
    typedef?Vec< short, 4 >? cv::Vec4s
    ?
    typedef?Vec<?ushort, 2 >? cv::Vec2w
    ?
    typedef?Vec<?ushort, 3 >? cv::Vec3w
    ?
    typedef?Vec<?ushort, 4 >? cv::Vec4w
    ?
    typedef?Vec< int, 2 >? cv::Vec2i
    ?
    typedef?Vec< int, 3 >? cv::Vec3i
    ?
    typedef?Vec< int, 4 >? cv::Vec4i
    ?
    typedef?Vec< int, 6 >? cv::Vec6i
    ?
    typedef?Vec< int, 8 >? cv::Vec8i
    ?
    typedef?Vec< float, 2 >? cv::Vec2f
    ?
    typedef?Vec< float, 3 >? cv::Vec3f
    ?
    typedef?Vec< float, 4 >? cv::Vec4f
    ?
    typedef?Vec< float, 6 >? cv::Vec6f
    ?
    typedef?Vec< double, 2 >? cv::Vec2d
    ?
    typedef?Vec< double, 3 >? cv::Vec3d
    ?
    typedef?Vec< double, 4 >? cv::Vec4d
    ?
    typedef?Vec< double, 6 >? cv::Vec6d
    http://docs.opencv.org/trunk/dc/d84/group__core__basic.html

    總結(jié)

    以上是生活随笔為你收集整理的OpenCV Mat数据类型像素操作的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。