MATLAB: How to run a code regarding regionfill() to obtain the background of an image in matlab 2014 because it is giving error that Undefined function ‘regionfill’ for input arguments of type ‘uint8’.

backgroundregionfillxyz

I am giving the code here.
grayImage = imread('brain_tumor.png');
figure,imshow(grayImage);
%h = impoly;
%position = wait(h);
mask = roipoly(grayImage);
figure, imshow(mask);
BackGround = regionfill(grayImage, mask);
figure, imshow(BackGround);
Sir, I have also attached the image herewith.

Best Answer

regionfill requires the Image Processing Toolbox, R2015a or newer.
Change your code
BackGround = regionfill(grayImage, mask);
to
BackGround = grayImage;
BackGround(mask) = 0;
with no regionfill() call.