MATLAB Answers

Merge binary images and smooth the edges

5 views (last 30 days)
Davide Messina
Davide Messina on 11 May 2021
Commented: Rik on 11 May 2021
Hello,
I am trying to extract the shape of a metallic droplet from the first picture and convert it into a binary image with edges as smooth as possible. So far I have been using the following commands: im2bw (with different thresholds), imfill (to fill any holes in the droplet), and imopen to smooth the edges. However, I am far from the results I would like to obtain.
In order: (1) photo that I want to process (2-3) im2bw with two different thresholds (4) manual merge of pictures 2-3 (5) example of what I would like to achieve.
Does anyone have a suggestion on how I can proceed?

Answers (1)

Rik
Rik on 11 May 2021
I'm not getting as smooth as your example, but this should do as a first approximate.
IM=imread('https://www.mathworks.com/matlabcentral/answers/uploaded_files/614215/image.png');
BW{1}=rgb2gray(IM);
BW{2}=edge(BW{1},'canny');
BW{3}=imclose(BW{2},ones(10));
BW{4}=imfill(BW{3},'holes');
BW{5}=imopen(BW{4},ones(20));
BW{6}=~BW{5};
for n=1:6
subplot(2,3,n),imshow(BW{n}),title(sprintf('step %d',n-1))
end
  2 Comments
Rik
Rik on 11 May 2021
You could try to use it to zoom in to the relevant sections of your image. My approximation is reasonable if you want to segment the droplet, but is grossly inadequate if you are looking for the angle.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!