0

500x500 マット オブジェクト (画像の緑色の面) があります。500x500x3 (3 はチャネル数) のゼロ Mat オブジェクトを作成しました。新しい「ゼロ」Matオブジェクトの2番目のチャネルに緑色の平面をコピーするopenCV 2.4.3関数はありますか?

ありがとう

4

2 に答える 2

0
void mixChannels(const vector<Mat>& srcv, vector<Mat>& dstv, const int* fromTo, int npairs)

この関数の詳細については、http://opencv.willowgarage.com/documentation/cpp/core_operations_on_arrays.html#mixChannelsを参照してください。

于 2013-02-08T15:44:24.413 に答える
0

プロセス 1:

int from_to[] = {0,1}
mixChannels(Green_plane,1,Created_mat,3,from_to,1);

上記の説明

プロセス 2 (少し長い..)

Mat Green_plane;//you already have this matrix as the green plane of an image

//create a 3 channeled matrix with all entries set to zero
Mat Created_mat = Mat::zeros(rows,cols,CV_8UC3);

//its a vector array of images that will contain the 3 planes of the above 3 channeled   matrix
vector<Mat> bgr_plane;

// divide the 3 channeled matrix into 3 one channeled matrix
split(Created_mat,bgr_plane);

// take the green plane, which is the middle matrix out of the 3 matrices contained in the vector array bgr_planes, and copy your already given green matrix to it
bgr_plane[1] = Green_plane.clone();

//merge the vector of one channeled matrices into a 3 channeled matrix
merge(bgr_plane,Created_mat);//EDITED

// now Created_mat has the green channel same as given green matrix you already have (Green_plane) and the rest 2 planes are still set to zero

編集...4チャンネル用..

vector<Mat> each_channel;
split(Mat_4_channel,each_channel);

//accessing each pixel of each channel
each_channel[0].at<uchar>(row,col);//1st channel
each_channel[1].at<uchar>(row,col);//2nd channel
each_channel[2].at<uchar>(row,col);//3rd channel
each_channel[3].at<uchar>(row,col);//4th channel
于 2013-02-08T16:23:33.420 に答える