Often, I share this project as one of my more difficult, yet rewarding experiences in my undergrad. This was given to me as an end-of-semester project for my ME102A class, measurement systems. Given three videos of bubbles in cavitation flow with different background and resolution levels, I needed to code in Matlab a robust program that detected the bubble sizes, and time allowing, the average velocity as extra credit. In terms of performance, we needed to be reasonably accurate for one video, and demonstrate workability for the other two videos.
Note: This was within a lab group, but with a pre-arranged set up, we worked out an agreement where I did much of the bulk coding and preparation for this report in return for missing a lab.
Sample 1
Sample 2
Sample 3
Our lab group was assigned to focus on Sample 1 as our priority. Beginning this project, I was completely lost as to how to even start. I felt that my coding skills weren't up to par and it seemed like a looming challenge. I chose to start by breaking the overall task into major steps: Bubble identification, bubble tracking, and from that velocimetry.
For the identification, I decided to define this problem by asking how humans decide if an outline is a bubble. Looking at Sample 1, it's clear that some bubbles are in-focus while others are hazy and lost in the background. I decided to constrain this project to only bubbles that could be reasonably distinguished. To translate this into code, I reasoned that humans decide things are in-focus based on the definition of the border. This meant that when the image was translated into pixel values, an in-focus edge had a higher magnitude delta in adjacent pixel values. Using this approach, I could define bubble outlines reasonably well, shown below.
Frame 2 Image
Frame 2 In-Focus Edge Detection
Another challenge that presented itself was the fact that bubbles in flow aren't spherical, but rather oblong and bean shaped. To address this, I used an ellipse to approximate the size of the bubbles. From the edge detection in the previous step, I then went from edge to edge and defined a bubble using a cross. To verify this method, I overlaid the crosses on the original image. The results proved successful. The crosses were an approximation, but the difference proved to be minimal. Here the white box delineates the interrogation volume that was analyzed at each time frame. Using the two axes of the crosses and the equation for ellipses, areas could be calculated in terms of pixels then translated to microns using the given resolution.
Sample 1, Frame 2 with Bubbles Identified
The next step of bubble tracking for a size histogram involved the challenge of not double counting the same bubble from frame to frame. Here, an assumption was made that the mean flow of the bubbles were approximately the same, meaning that a sample of frames could be analyzed to generate a representative histogram. This was vetted by visually checking bubbles and following them frame to frame. It was noted that it took about 20 frames for a bubble to enter and exit the interrogation zone. By selecting choice frames, histograms were generated for the three samples. All three had the expected characteristic of being skewed right due to the natural preference for smaller bubbles.
For the extra step of velocimetry, the frames count for bubbles to enter and exit came in handy. Using that as a measurement and the time scale as well as the resolution, the speed of the bubbles could be calculated.
Overall, this was one of my favorite project because it showed that even seemingly insurmountable challenges could be overcome by breaking them down into smaller parts. In addition, it proved to be a pivotal point for my education as I was no longer afraid of coding. I was previously very hesitant to code because of lack of confidence. This project threw me into the deep end, but fortunately, I was able to persevere by asking for pointers from my instructors as well as simple hours put in. By investing time and energy, I saw that I was able to translate a physical phenomena of vision and discernment into code and seeing this process was a huge confidence booster. This confidence later came in handy for my senior project that required coding, which I was able to do, even in a language that I had very little experience in.
For the full report: