how can use imfill for an image to give me a same result every time?

Hi I want to imfill an image.I want to use imfill to give me a Same result every time
but when I use imfill it wants me to select some points on this image and it Causes Different result.
Is there any way for this to give me a same result every time?

 Accepted Answer

See the imfill documentation for more syntaxes that don't require interactive input,
BW2 = imfill(BW)
[BW2,locations] = imfill(BW)
BW2 = imfill(BW,locations)
BW2 = imfill(BW,'holes')
I2 = imfill(I)
BW2 = imfill(BW,locations,conn)

5 Comments

hi thanks Matt
I use BW2 = imfill(BW,'holes');
It gives me what I want but it gives me this error:
Error using handle.handle/get Invalid or deleted object.
Error in getcurpt (line 14) pt = get(axHandle, 'CurrentPoint');
Error in getpts>FirstButtonDown (line 220) [x,y] = getcurpt(GETPTS_AX);
Error in getpts (line 37) feval(varargin{:});
Error while evaluating figure WindowButtonDownFcn
The error messages don't mention imfill anywhere. Wherever the error is coming from, it's in a different part of your code.
Did you change the "current folder" in MATLAB after you launched your GUIDE app?
yes Image Analyst
when I put my image in the folder that my code saved I did not any error after run my code. thanks Matt
thanks Image Analyst
That doesn't make sense. There is an image on disk, and then a bunch of images in memory. For you to have even gotten to a point in your code where you've created a BW variable, you must have already successfully read in your image from the file in your folder into a variable in your program. Then you thresholded it to get BW - BW is in your program memory, not in the folder. So that could not have been the problem.

Sign in to comment.

More Answers (0)

Tags

No tags entered yet.

Asked:

on 5 Sep 2014

Commented:

on 5 Sep 2014

Community Treasure Hunt

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

Start Hunting!