Here is my code, i want to extract only the fingers and save them as a new image
import cv2
import numpy as np
from PIL import Image
def get_image():
global image
image = cv2.imread("testPalm.png", 0)
get_image()
image = cv2.GaussianBlur(image, (5, 5), 0)
ret, thresh_binary = cv2.threshold(image, 80, 255, cv2.THRESH_BINARY)
thresh_binary = cv2.erode(thresh_binary, None, iterations=2)
thresh_binary = cv2.dilate(thresh_binary, None, iterations=2)
contours, hierarchy = cv2.findContours(image=thresh_binary, mode=cv2.RETR_TREE, method=cv2.CHAIN_APPROX_SIMPLE)
mask = np.zeros(image.shape[:2], dtype=np.uint8)
min_width = 50
min_height = 50
filtered_contours = [c for c in contours if cv2.boundingRect(c)[2] > min_width and cv2.boundingRect(c)[3] > min_height]
cv2.drawContours(image, filtered_contours, -1, (255, 0, 0), 3)
cv2.imshow('All Contours', image)
cv2.waitKey(0)
cv2.destroyAllWindows()
I have tried researching open cv, i know what i want to do but not how.