5
votes

I have an OpenCV Mat, and I would like to remove the first column. Is there a nice built-in way of removing specific columns from a matrix?

1

1 Answers

7
votes

You can use Mat::col(int j) method to get first column

    Mat m;
    Mat col1 = m.col(0)

Or, you can use Mat::colRange(int startCol, int endCol) to get original matrix without the first column:

    Mat noCol1 = m.colRange(1, m.cols)

Remember that the actual data is not copied, it is shared with the original matrix. to get copy of that value, you may use Mat::clone().

More info: Opencv 2.3 docmentation