How to fill inside of the object?

조회 수: 20 (최근 30일)
fred grahambel
fred grahambel 2015년 7월 6일
댓글: Jórdan Venâncio Leite 2020년 3월 11일
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
  댓글 수: 1
Rena Berman
Rena Berman 2017년 1월 24일
(Answers dev) Restored question.

댓글을 달려면 로그인하십시오.

채택된 답변

Image Analyst
Image Analyst 2015년 7월 6일
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
Image Analyst
Image Analyst 2015년 7월 9일
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 2015년 7월 10일
Not sure what you did but it works just great with my ExtractNLargestBlobs() function. No problems whatsoever. Working code is attached.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Jórdan Venâncio Leite
Jórdan Venâncio Leite 2020년 2월 28일
Hello ImageAnalyst! how to draw a line across the top of a figure as you did with the bottom side?
  댓글 수: 4
Image Analyst
Image Analyst 2020년 3월 4일
편집: Image Analyst 2020년 3월 4일
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 2020년 3월 11일
You're the guy!

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

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

Start Hunting!

Translated by