How to get the area of the bubble in the image using MATLAB?

送分小仙女□ 提交于 2019-12-23 05:08:04

问题


Here are some images taken from experiments which show a bubble caused by spheres moving in liquid.

Now I want to get the area of the bubble from every image using Matlab. The first thing come to my mind is edge detection. So I tried using the following code:

A = imread('D:\1.jpg');
BW1 = edge(A,'sobel');
figure, imshow(BW1)

to get the cavity edge of the picture which was then cropped manually, as the picture show, the result (below) doesn't satisfy requirements. Also, I still don't know how to get the area of the bubble.

So, can someone tell me what should I do?


回答1:


I think you should use background subtraction and try a simple segmentation. You could use regionprops to get the area of the bubble:

https://www.mathworks.com/help/images/ref/regionprops.html

I feel like it should work pretty well. If you have a hard time obtaining a clean segmentation you could probably improve the experimental setup to increase the contrast of the bubble with respect to the background by choosing a background as dark as possible and using some lateral illumination to leverage the diffusion of the light by the bubble.

Finally the segmentation should be performed in a region of interest (ROI) since you know the bubble is confined within the tank




回答2:


As for the issue of getting an accurate cavity edges, the computer vision system toolbox has the vision.ForegroundDetector object, which implements a variant of Stauffer and Grimson's GMM background subtraction. The implementation is very fast, leveraging multiple cores. Check out this example of how to use background subtraction.

As for the issue of finding the area of the bubble, use the bwarea command. https://www.mathworks.com/help/images/ref/bwarea.html, it will sum up all the white pixels in the image.




回答3:


I believe background subtraction is the most efficient method to calculate this bubble area. Note that you may need to use opening and closing techniques afterwards to filter other regions see (imopen imclose) at: https://uk.mathworks.com/help/images/ref/imopen.html , and afterwards, you can apply bwarea to calculate area. You could also use impixelinfo command to compare intensity level of bubbles and other areas, and therefore, threshold image to extract bubbles. It works only when you have same threshold level for all images. Further, it is possible to combine all these techniques which is completely depended on your images to achieve better results.

Other shape-based techniques also can be used to extract bubble region area.



来源:https://stackoverflow.com/questions/47888636/how-to-get-the-area-of-the-bubble-in-the-image-using-matlab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!