I am trying to measure air bubble/slug size in a tube having water and air bubbles. The liquid(water) is along the tube walls while bubbles (smaller or a bigger slug depending on the velocity and air amount) are in the center. I have to process 1000-10000 images to find the ratio of pixels(area) of bubbles/total pixels(area).
I have tried entropy mask ( https://towardsdatascience.com/image-processing-with-python-working-with-entropy-b05e9c84fc36#:~:text=Entropy%20masking%20is%20a%20useful,well%20to%20Natural%20Language%20Processing).)
but it seems not accurate.
Entropy mask result
I have also tried edge detection method
image = cv2.imread('test.tif')
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
blurred = cv2.GaussianBlur(gray, (3, 3), 1)
blurred = cv2.medianBlur(gray,1)
blurred = cv2.bilateralFilter(gray,1,50,50)
edges = cv2.Canny(blurred, 10, 150)
contours, hierarchy = cv2.findContours(edges, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_TC89_KCOS)
output = image.copy()
cv2.drawContours(output,contours, -1, (0, 253, 0), 2)
plt.figure(figsize=(10, 10))
plt.subplot(1, 3, 1)
plt.title('Original Image')
plt.imshow(cv2.cvtColor(image, cv2.COLOR_BGR2RGB))
plt.subplot(1, 3, 2)
plt.title('Edge Detection')
plt.imshow(edges, cmap='gray')
plt.subplot(1, 3, 3)
plt.title('Detected Bubble')
plt.imshow(cv2.cvtColor(output, cv2.COLOR_BGR2RGB))
plt.show()
Edge detection result
Sample image
I tried:
Entropy mask
Edge detection.
ImageJ to enhance contrast, vary the threshold etc.
I am looking for another method to clearly detect the interface between liquid layer(along the wall of tube) and bubble slug in the core of the tube.
Thanks.