MATLAB: 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?

Best 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)