Effacer les filtres
Effacer les filtres

Video and image analysis of microfluidics channel with a growing bubble. Calculate the size of the bubble.

6 vues (au cours des 30 derniers jours)
Hello!
I am working with some experiments, where I focus a laser into a microchannel with some liquid. This will prompt a cavitation bubble. The experiments have been performed and the data has been captured by a high resoluton camera. I post-processed the data (.tif file) and I have a 80x384x118 double. This is a set of 118 images of 80x384 resolution, in a gray-scale.
The challenge is that I need to analyse the video and obtain what is the size of the bubble. My guess is that I should use some AI technique here (or not?), and this is what I don't know.
Below there are three images. The first one where nothing has happened yet (This is the initial condition). The second one is an arbitrary image in the middle of the process, where the bubble is growing. The third one is (not exactly) the frame where the bubble is at its largest size.
I would like to know what frame is this and the size of the bubble. I know the dimensions of the channel and the scale of the image.
I come to ask for a general advise, what techniques or functions should I use?
I hope I made myself clear.
Thank you in advance!

Réponses (2)

VINAYAK LUHA
VINAYAK LUHA le 5 Jan 2024
Hello Nicolas,
I understand that you have a video footage of an expanding bubble and seek guidance on determining the frame number and dimensions of the bubble using image processing techniques in MATLAB.
For the initial inquiry, to identify the frame number within a video, you can follow the below mentioned approach
% Establish a VideoReader object to read the video file
videoFile = 'video Path.mp4';
vidObj = VideoReader(videoFile);
% Set the starting frame number
frameNum = 0;
% Iterate over each frame in the video
while hasFrame(vidObj)
% Increase the frame number
frameNum = frameNum + 1;
% Capture the current frame
frame = readFrame(vidObj);
% Overlay the frame number as text on the frame
position = [10 10]; % (Position at the top-left corner)
text = sprintf('Frame %d', frameNum);
frameWithText = insertText(frame, position, text, 'TextColor', 'red', 'BoxOpacity', 0, 'FontSize', 80);
% Exhibit the frame with the frame number annotated
imshow(frameWithText);
% halt briefly to simulate a video playback
pause(1/vidObj.FrameRate);
end
As for the second query on determining the bubble's size, you may follow this procedure:
% Load the image
img = imread("ImagePath");
% Transform the image to grayscale
imgray = im2gray(img);
% Generate a disk-shaped structuring element with a 6-pixel radius
se = strel('disk', 6);
% Apply dilation to the grayscale image with the structuring element
imnoiseReduced = imdilate(imgray, se);
% Threshold the image to generate a binary image
thresholdValue = 128;
binaryImage = imnoiseReduced > thresholdValue;
% Exclude small objects (noise) from the binary image
L = bwareaopen(binaryImage, 50);
% Present the binary image
imshow(L)
% Convert the binary image to an RGB image using a 'jet' colormap
RGB = label2rgb(L, 'jet', 'k', 'shuffle');
% Show the RGB image
imshow(RGB);
% Identify connected components in the binary image
CC = bwconncomp(L);
% Compute properties of image regions (blobs)
stats = regionprops(CC, 'Area', 'Centroid');
% Organize the areas in descending order and obtain the indices
[sortedAreas, sortIndexes] = sort([stats.Area], 'descend');
% Select the index of the second largest blob, assuming the largest is the background
largestIndex = sortIndexes(2);
% Maintain the current figure
hold on
% Caption the figure with the area of the second largest blob
title("Area of the Bubble " + num2str(stats(largestIndex).Area) + " pixels");
% Determine the centroid of the second largest blob
k = largestIndex;
centroid = stats(k).Centroid;
% Mark the centroid on the figure
plot(centroid(1), centroid(2), 'r+', 'MarkerSize', 10, 'LineWidth', 2);
Results
You may amalgamate the two approaches as needed for your application.
Here are some documentation links for the functions utilized for your reference:
I hope this assists you in understanding how to proceed.
Best regards,
Vinayak Luha

Image Analyst
Image Analyst le 5 Jan 2024
After getting the binary image "L" you should have removed the background and then extracted the largest blob (assuming the bubble will be the largest blob).
L = imclearborder(L); % Remove surrounding background.
L = bwareafilt(L, 1); % Extract largest blob only.

Produits


Version

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by