OpenCV之mixChannels()函數使用說明


step 1:  函數功能說明

      mixChannels主要就是把輸入的矩陣(或矩陣數組)的某些通道拆分復制給對應的輸出矩陣(或矩陣數組)的某些通道中,其中的對應關系就由fromTo參數制定.

step 2:  函數原型講解

      C++:   void  mixChannels (const Mat*  src , int  nsrc , Mat*  dst , int  ndst , const int*  fromTo , size_t  npairs );

      src– Input array or vector of matrices. All the matrices must have the same size and the same depth.

          輸入矩陣,可以為一個也可以為多個,但是矩陣必須有相同的大小和深度.

      nsrcs– Number of matrices in src.

          輸入矩陣的個數。

      dst– Output array or vector of matrices. All the matrices must be allocated. Their size and depth must be the same as in src[0].

          輸出矩陣,可以為一個也可以為多個,但是所有的矩陣必須事先分配空間(如用create),大小和深度須與輸入矩陣等同.

      ndsts– Number of matrices in dst.

          輸出矩陣的個數。

      fromTo – Array of index pairs specifying which channels are copied and where. fromTo[k*2] is a 0-based index of the input channel in src. 

           fromTo[k*2+1] is an index of the output channel in dst. The continuous channel numbering is used: the first input image channels 

           are indexed from 0 to src[0].channels()-1 , the second input image channels are indexed from src[0].channels() to src[0].

           channels() + src[1].channels()-1, and so on. The same scheme is used for the output image channels. As a special case, 

           when fromTo[k*2] is negative, the corresponding output channel is filled with zero .

          設置輸入矩陣的通道對應輸出矩陣的通道,規則如下:首先用數字標記輸入矩陣的各個通道。輸入矩陣個數可能多於一個並且每個矩陣的通道可能不一樣,

          第一個輸入矩陣的通道標記范圍為:0 ~ src[0].channels()-1,第二個輸入矩陣的通道標記范圍為:src[0].channels() ~ src[0].channels()+src[1].channels()-1,

          以此類推;其次輸出矩陣也用同樣的規則標記,第一個輸出矩陣的通道標記范圍為:0 ~ dst[0].channels()-1,第二個輸入矩陣的通道標記范圍為:dst[0].channels()

          ~ dst[0].channels()+dst[1].channels()-1,以此類推;最后,數組fromTo的第一個元素即fromTo[0]應該填入輸入矩陣的某個通道標記,而fromTo的第二個元素即

          fromTo[1]應該填入輸出矩陣的某個通道標記,這樣函數就會把輸入矩陣的fromTo[0]通道里面的數據復制給輸出矩陣的fromTo[1]通道。fromTo后面的元素也是這個

          道理,總之就是一個輸入矩陣的通道標記后面必須跟着個輸出矩陣的通道標記。

      npairs– Number of index pairs in fromTo.

          即參數fromTo中的有幾組輸入輸出通道關系,其實就是參數fromTo的數組元素個數除以2.

step 3:   源碼案例


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM