There is a set of pixels that fall within the boundary of the path. There is another set of pixels that are black. You want to find the intersection of these two sets, that is, a lot of pixels that are both inside the border and black.
To do this, I would:
Draw the outline as a filled shape, white on black (in its own way) so that it is a mask. You can use cv::drawContours or cv::fillPoly .
Filter the black pixels from the image as another mask. You can use cv::threshold with THRESH_BINARY_INV and a threshold value of zero.
Find the intersecting set using bitwise_and or just the & operator, for example matResult = mat1 & mat2;
The result is a matrix of the same size as your image, with non-zero values ββonly for pixels that satisfy your criteria for being inside the outline and black in the image. You can get individual coordinates by looping this matrix and checking non-zero values.
source share