1 | initial version |
Not tested, but you'll get the spirit:
cv::Mat tmp(image, cv::Range(i,i+1), cv::Range(j-one_count, j-1)).setTo(cv::Scalar::all(0));
see http://docs.opencv.org/modules/core/doc/basic_structures.html?highlight=setto#mat for more mat-operations. Note, the same could be achieved with cv::Rect, instead of cv::Range. Also note, Matlab indices start with 1, C/C++ (and others) start with 0 (so maybe the indices from above are not correct).
2 | No.2 Revision |
Not tested, but you'll get the spirit:
cv::Mat tmp(image, cv::Range(i,i+1), cv::Range(j-one_count, j-1)).setTo(cv::Scalar::all(0));
see http://docs.opencv.org/modules/core/doc/basic_structures.html?highlight=setto#mat for more mat-operations. Note, the same could be achieved with cv::Rect, instead of cv::Range. Also note, Matlab indices start with 1, C/C++ (and others) start with 0 (so maybe the indices from above are not correct).
EDIT
My solution (see above) is slightly wrong (the temporary matrix t isn't necessary), the following way works:
image(cv::Range(i,i+1), cv::Range(j-one_count, j-1)).setTo(cv::Scalar::all(0));
Example:
cv::Mat1i image = (cv::Mat1i(3,4) << 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12);
std::cout << image << std::endl;
image(cv::Range(1,2), cv::Range(1, 3)).setTo(cv::Scalar::all(0));
std::cout << image << std::endl;
Output
[1, 2, 3, 4;
5, 6, 7, 8;
9, 10, 11, 12]
[1, 2, 3, 4;
5, 0, 0, 8;
9, 10, 11, 12]