Sory if my English is not good
I have to detect shrimps on the photo. Some things are not shrimp was detected. Is there any way to remove it. Thank.
Result:

Code:
import cv2
import numpy as np
import matplotlib.pyplot as plt
image = cv2.imread(r'E:\1-LUANVAN_Code\image\hinhchupkhongro\13-09-2022\2022-09-13_15h23p51s.png')
copyimage = image.copy()
enhimg = cv2.detailEnhance(image, sigma_s=100, sigma_r=0.15)
grayimg = cv2.cvtColor(enhimg, cv2.COLOR_BGR2GRAY)
smoothimg = cv2.edgePreservingFilter(grayimg, flags=1, sigma_s=30, sigma_r=0.15)
thresh = cv2.adaptiveThreshold(smoothimg, 255, cv2.ADAPTIVE_THRESH_GAUSSIAN_C, cv2.THRESH_BINARY_INV, 101, 2)
contours, hierarchy = cv2.findContours(thresh, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
mask = np.zeros_like(image)
for contour in contours:
if cv2.contourArea(contour)>4000:
cv2.drawContours(mask, contour, -1, (255,255,255), 1)
x,y,w,h = cv2.boundingRect(contour)
cv2.rectangle(copyimage, (x,y), (x+w, y+h), (255,0,0), 5)
plt.figure('Opencv')
plt.subplot(2,2,1)
plt.xticks([]), plt.yticks([]), plt.title('Image')
plt.imshow(image, cmap='gray')
plt.subplot(2,2,2)
plt.xticks([]), plt.yticks([]), plt.title('Threshold')
plt.imshow(thresh, cmap='gray')
plt.subplot(2,2,3)
plt.xticks([]), plt.yticks([]), plt.title('Mask')
plt.imshow(mask, cmap='gray')
plt.subplot(2,2,4)
plt.xticks([ ]), plt.yticks([]), plt.title('Result')
plt.imshow(cv2.cvtColor(copyimage, cv2.COLOR_BGR2RGB))
plt.savefig('opencv.png')
plt.show()