Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

findNonZero is good solution if your first concern is a concise code. Otherwise, if you need performance, I would stick to your original approach and change

matrix.at<uchar>(index,0) = col;

matrix.at<uchar>(index,1) = row;

into

matrix.ptr<uchar>(index)[0] = col

matrix.ptr<uchar>(index)[1] = row