1 | initial version |
The code is doing exactly what you asked it to, drawContours is drawing the green blob over the countour's area.
What you probably want to do instead of drawing the filled contour into srcMat, is to draw it on a mask matrix, then apply the mask matrix to srcMat to 'zero' all the cells outside the contour area.
This will zero the srcMat pixels which are outside the contour.