here's my code
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
labelNum, labelImg, contours, GoCs = cv2.connectedComponentsWithStats(gray)
for c in contours:
x,y,w,h,size = c
if size <= 100:
cv2.drawContours(image, [c], 0, 0)