i am trying to find the outer boundary size of all drops along length of tube using python.
I am struggling to distinguish between outer and inner boundary after canny edge detection.can anyone help me please.
The image preproccessing i have used is like:
# load the image, convert it to grayscale, and blur it slightly
gray = cv2.GaussianBlur(imc, (5, 5), 0)
# perform edge detection, then perform a dilation + erosion to
# close gaps in between object edges
dilate = cv2.dilate(gray, None, iterations=1)
#cv2.imshow('dilated',dilate)
erode = cv2.erode(dilate, None, iterations=1)
#cv2.imshow('eroded',erode)
edged = cv2.Canny(erode,230,230)
#cv2.imshow('%deroded' %count,edged)
###############################################EDGE DETECTION
# find contours in the edge map
cnts= cv2.findContours(edged.copy(),cv2.RETR_EXTERNAL,cv2.CHAIN_APPROX_SIMPLE)
cnts = imutils.grab_contours(cnts)
#plot all contours
#for k in cnts:
#cv2.drawContours(edged, [k], -1, (255, 255, 255), 2)
#cv2.imshow('%d allcontours' %count,edged)
# Sort the contours as per Area small to large
cnts=sorted(cnts,key=cv2.contourArea,reverse=True)
# sort the contours from left-to-right
(cnts, _) = contours.sort_contours(cnts)
contour_list=[]
# loop over the contours individually and find proper contours
#**************************************************************************ContourSelection
for contour in cnts:
approx=cv2.approxPolyDP(contour,0.01*cv2.arcLength(contour,False),True)
area=cv2.contourArea(contour)
#print('drop area:',area)
#print('edges',len(approx))
#print('arclen',cv2.arcLength(contour,False))
#print('next-------')
#change area parameter for detecting size of circle
#check if contour is near circle and
#if((len(approx)>5)&(area<600) & (area>2) and cv2.arcLength(contour,False)>50):mustard2.5
if((len(approx)>5)&(area<600) & (area>2) and cv2.arcLength(contour,False)>29): #for open
contours False must be there in arc length
contour_list.append(contour)
#print('selected drop area',area)
#print('selected edges',len(approx))
#print('selected contour',cv2.isContourConvex(contour))
#print('contourlength',cv2.arcLength(contour,False))
#print('next')
cnts=contour_list
# sort contours again as per area
#cnts=sorted(cnts,key=cv2.contourArea,reverse=True)
#substitute blank contour if no contour found in image
if len(cnts)==0:
cnts.append(np.array([[[0,0]],[[0,0]],[[0,0]]]))
This code gives me inner edges easily but i want outer edges.
You can see droplet boundary is sufficiently thick and varies from case to case.
I have to process 4000 images in a sequence.please guide me.
i am unable to distinguish between droplet boundary and tube boundary.
How to eliminate inner edges and filter outer edges only?
above one is near expected output.


