1 | initial version |
there might be no (vectorized) counterpart for what you're doing in the c++ api, but assuming a vector<Point>
you could easily iterate over the contours:
Mat pixels; // initially empty
for (size_t i=0; i<contour.size(); i++) {
Vec3b p = img.at<Vec3b>(contour[i]); // bgr
//uchar p = img.at<uchar>(contour[i]); // grayscale
pixels.push_back(p);
}
leaving you with a Mat with contour.size() rows and a single column
2 | No.2 Revision |
there might be no (vectorized) counterpart for what you're doing in the c++ api, but assuming your contour is a vector<Point>
you could easily iterate over the contours:it:
Mat pixels; // initially empty
for (size_t i=0; i<contour.size(); i++) {
Vec3b p = img.at<Vec3b>(contour[i]); // bgr
//uchar p = img.at<uchar>(contour[i]); // grayscale
pixels.push_back(p);
}
leaving you with a Mat with contour.size() rows and a single column
3 | No.3 Revision |
there might be no (vectorized) counterpart for what you're doing in the c++ api, but assuming your contour is a vector<Point>
you could easily iterate over it:
Mat pixels; // initially empty
for (size_t i=0; i<contour.size(); i++) {
Vec3b p = img.at<Vec3b>(contour[i]); // bgr
bgr image
//uchar p = img.at<uchar>(contour[i]); // grayscale
grayscale version
pixels.push_back(p);
}
leaving you with a Mat with contour.size() rows and a single column