How to fill inside of the object?

29 visualizaciones (últimos 30 días)
fred grahambel
fred grahambel el 6 de Jul. de 2015
Comentada: Jórdan Venâncio Leite el 11 de Mzo. de 2020
Hello every one,
I have one hand image(binary), which after doing segmentation i got the image with edges and now i want to fill inside of the hand which can see in the second following image.
I used imfill but it didnt change anything.
I will appreciate if anyone can help me to do it.
thanks

Respuesta aceptada

Image Analyst
Image Analyst el 6 de Jul. de 2015
You need to draw a line across the bottom to close off the arm before you fill it.
% Make tempoprary line.
binaryImage(end, :) = true;
% arm is sealed off. Now we can fill.
binaryImage = imfill(binaryImage, 'holes');
% Erase temporary line.
binaryImage(end,:) = false;
  6 comentarios
Image Analyst
Image Analyst el 9 de Jul. de 2015
You must have an old version of MATLAB where bwareafilt() had not been introduced yet. See my attached demo where you can use your version and use my function ExtractLargestNBlobs.
To smooth the boundary you can use imclose() or activecontour() (demo attached).
Image Analyst
Image Analyst el 10 de Jul. de 2015
Not sure what you did but it works just great with my ExtractNLargestBlobs() function. No problems whatsoever. Working code is attached.

Iniciar sesión para comentar.

Más respuestas (1)

Jórdan Venâncio Leite
Jórdan Venâncio Leite el 28 de Feb. de 2020
Hello ImageAnalyst! how to draw a line across the top of a figure as you did with the bottom side?
  4 comentarios
Image Analyst
Image Analyst el 4 de Mzo. de 2020
Editada: Image Analyst el 4 de Mzo. de 2020
Sometimes you need to save the line, then do your fill or whatever, then set it back:
% Save existing line:
originalLine = binaryImage(1, :);
% Make temporary line along the top of the image.
binaryImage(1, :) = true; % Set all of row 1 to true/white/1
% Now do some processing, such as imfill() or whatever...
% Finally restore original line:
binaryImage(1, :) = originalLine;
Jórdan Venâncio Leite
Jórdan Venâncio Leite el 11 de Mzo. de 2020
You're the guy!

Iniciar sesión para comentar.

Categorías

Más información sobre Image Processing and Computer Vision en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by