Detecting Contour of bubble

2 views (last 30 days)
I am doing image processing on pictures of a droplet. However on quite a few images, the contour of the droplet is not detected when I try to read the image from left to right. I want all the white boundary to be detected from left to right. I have attached the necessary images too. Kindly help me out in this regard.
Image Analyst
Image Analyst on 27 Nov 2021
No images are attached. I'm attaching one I got from KSSV.
I have no idea what you mean. What/where is the "contour"?
What do you mean by "I want all the white boundary to be detected from left to right."? To get boundaries (perimeter of white region) you can use bwperim() or bwboundaries().

Sign in to comment.

Accepted Answer

Image Analyst
Image Analyst on 29 Nov 2021
Again, not sure what you want since the description is not precise, but here are some options:
grayImage = imread('Vaishnavi.png');
binaryImage = grayImage(:, :, 1) > 128; % Binarize
% Method 1
perimImage = bwperim(binaryImage); % Get perimeter
rgbImage = imoverlay(binaryImage, perimImage, 'r'); % Show perimeter in the overlay.
% Alternatively you can use Method 2
boundaries = bwboundaries(binaryImage); % Get a list of (x,y) coordinates of the perimeter.
x = boundaries{1}(:, 2);
y = boundaries{1}(:, 1);
hold on;
plot(x, y, 'r-', 'LineWidth', 3)
Yes, it is the tail that shoots upwards.
I will definitely look into the methods you suggested.

Sign in to comment.

More Answers (2)

KSSV on 27 Nov 2021
I = imread('') ;
% Remove boundary/ crop
I = I(10:end-10,10:end-10,:) ;
I1 = imbinarize(rgb2gray(I)) ;
% option 1
c = contour(I1) ;
% option 2
[y,x] = find(I1) ;
idx = boundary(x,y) ;

yanqi liu
yanqi liu on 29 Nov 2021
clc; clear all; close all;
I = imread('') ;
I = imcrop(I, [20 20 size(I,2)-40 size(I,1)-40]);
I1 = imbinarize(rgb2gray(I)) ;
figure; imshow(I1,[]); hold on;
[M,c] = contour(bwperim(I1)) ;
% set line
set(c, 'Color', 'r')
set(c, 'Color', 'r', 'LineWidth', 2)
% all the white boundary to be detected from left to right
be = bwperim(I1); [r,c] = find(be);
[~,ind] = min(c);
contour2 = bwtraceboundary(be,[r(ind) c(ind)],'W');
figure; imshow(I1,[]); hold on;
  1 Comment
Image Analyst
Image Analyst on 29 Nov 2021
Like I said, you can use bwboundaries(). It's advantage is that you do not need to specify a starting point like you do with bwtraceboundary().

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!