[Threshold image](https://i.stack.imgur.com/VqJ4e.png)

[Mouth part](https://i.stack.imgur.com/7RnJD.png)

[Extracted teeth](https://i.stack.imgur.com/XoCwk.png)

I am trying to make extraction for the teeth part only from the cropped mouth image but the threshold and mask way miss some teeth as shown in the extracted teeth image.

I am using python in do this by getting the threshold image then find contours based on the threshold image and extract the contour detected,
by this code:

```
labels = measure.label(threshold, connectivity=2, background=0)
mask = np.zeros(threshold.shape, dtype="uint8")
for label in np.unique(labels):
    if label == 0:
        continue
    labelMask = np.zeros(threshold.shape, dtype="uint8")
    labelMask[labels == label] = 255
    numPixels = cv2.countNonZero(labelMask)
    if numPixels > 600:
        mask = cv2.add(mask, labelMask)

cv2.imshow("mask", mask)

_, contours, _ = cv2.findContours(mask,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE)
cv2.drawContours(equa, contours, -1, (0, 0, 255), 2)
cv2.imshow("thre",equa)
img_contours= cv2.findContours(mask,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE)[-2]
img_contours = sorted(img_contours, key=cv2.contourArea)

for i in img_contours:

    if cv2.contourArea(i) > 1000:

        break

mask = np.zeros(mask.shape[:2], np.uint8)
cv2.drawContours(mask, [i],-1, 255, -1)
new_img = cv2.bitwise_and(img, img, mask=mask)
cv2.imshow("Image with background removed", new_img)

```

So is there anyway to make extraction and get all teeth or fill the empty gap between the extracted teeth?