getting area points inside contour
Hello,
is it possible not only to get the area inside a contour but also the corresponding points of the area?
EDIT -- Answer to my original problem (see below):
def getContourStat(contour,image):
mask = np.zeros(image.shape,dtype="uint8")
cv2.drawContours(mask, [contour], -1, 255, -1)
mean,stddev = cv2.meanStdDev(image,mask=mask)
return mean, stddev
Even if I dont get the points itself, I get the statistics I need. Nevertheless I think it's quite inefficient for many contours.
Do you refer to the pixels within the area?
Yes. cv2.contourArea() only delivers the size of the area, i.e. number of pixels, but not the pixels itself. If I want to do some processing of the area, I need the pixels with its positions, colors or graylevels.
Then do the thing petititi proposes in his answer. Depending on your speed, you could implement some kind of BFS/DFS to find the points in your contour (starting from its center) so that you don't have to check all pixels in the new image.
I'm working with Python, so speed is not available for me and I need to use pure OpenCV and numpy implementations.