I am using grabcut to remove the white background from the images. Some part of the background at the edges remain. Can you please help me to remove the shadow part as well ?
Input image
Output image

Tried grabcut, contour, normal thresholding but shadow remains
img_ray = cv.cvtColor(img, cv.COLOR_BGR2GRAY)
ret, thresh = cv.threshold(img_ray, 127, 255, cv.THRESH_BINARY+cv.THRESH_OTSU)
contours, hierarchy = cv.findContours(thresh, cv.RETR_TREE, cv.CHAIN_APPROX_NONE)
cnt = contours[4]
cv.drawContours(img, [cnt], 0, (0, 255, 0), 3)
mask = np.zeros(img.shape[:2], np.uint8)
bgdmodel = np.zeros((1, 65), np.float64)
fgdmodel = np.zeros((1, 65), np.float64)
height = img.shape[0]
width = img.shape[1]
rect = (50, 0, width, height)
cv.grabCut(img, mask, rect, bgdmodel, fgdmodel, 10, cv.GC_INIT_WITH_RECT)
mask2 = np.where((mask == 2) | (mask == 0), 0, 1).astype('uint8')
img = img * mask2[:, :, np.newaxis]
img[np.where((img == [230, 230, 230]).all(axis=2))] = [0, 0, 0]
cv.bitwise_not(img)
it should remove complete background
