一些(不连续的)索引存储在 vector vec
中。给定Mat
类型data
,如何仅使用在vec
vector 中指定索引的列创建数据子集?
对于行,我可以指定Range::all()
;但我无法为此子集指定列范围。
std::vector<int> vec = {1, 4, 7, 13, 21, 51, 87};
cv::Mat data, subData;
subData= data(Range::all(), colRange); //Not sure, what to write in place of colRange
最佳答案
按照三木的建议,我做了以下工作:
for (int index = 0; index < vec.size(); index++)
data.col(vec[index]).copyTo(subData.col(index)); //loop over the vector, copy the data from vec[index] column to subData[index]