Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove column from OpenCV Mat

Tags:

c++

opencv

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?

like image 489
Bill Cheatham Avatar asked Feb 28 '12 05:02

Bill Cheatham


1 Answers

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

like image 67
Tomasz Niedabylski Avatar answered Sep 20 '22 13:09

Tomasz Niedabylski