import cv2
import numpy as np
image=cv2.imread("RB.png")
b,g,r=cv2.split(image)
x=b-r
a,i=cv2.threshold(x,170,255,cv2.THRESH_BINARY)
kernel=np.ones((3,3),np.uint8)
kernel2=np.ones((7,7),np.uint8)
erode=cv2.erode(i,kernel)
dilate=cv2.dilate(erode,kernel2)
contours,fl=cv2.findContours(dilate,cv2.RETR_CCOMP,cv2.ADAPTIVE_THRESH_GAUSSIAN_C)
# picture=cv2.drawContours(image,contours,-1,(80,255,70),3)
# cv2.imshow("dilate",dilate)
# cv2.imshow("erode",erode)
# cv2.imshow("picture",picture)
# cv2.imshow("a",picture)
area=cv2.contourArea(contours[0])
print(fl)
print(area)
print(cv2.contourArea(contours[1]))
print(cv2.contourArea(contours[2]))
print(cv2.contourArea(contours[3]))
for i in range(len(contours)):
if cv2.contourArea(contours[i])<3000:
sd=cv2.drawContours(image,contours,i,(0,255,0),3)
cv2.imshow("contours",sd)
cv2.waitKey(0)
cv2.destroyAllWindows()