guyts
guyts

Reputation: 949

MATLAB's function imfill() causes error

I have a binary image (720x1280 logical) that has some holes in it, so I'm using imfill to fill it up, however the action fails and I get the following error:

Undefined function or variable 'eml_assert_all_constant'.
Error in iptcheckconn (line 8)
eml_assert_all_constant(varargin{:});
Error in imreconstruct>parseInputs (line 136)
    iptcheckconn(varargin{3},mfilename,'CONN',3);
Error in imreconstruct (line 74)
[marker,mask,conn] = parseInputs(varargin{:});
Error in imfill (line 141)
    I2 = imreconstruct(marker, mask, conn);

I've checked other resources, and they suggested that the files imreconstruct and iptcheckconn might not exist, but they do. Any ideas on how to solve?

Upvotes: 2

Views: 423

Answers (1)

gnovice
gnovice

Reputation: 125854

As shown in the comments, using which shows you the location of the file iptcheckconn that gets called. The -all option shows you that there are two versions, showing up in these folders for you in R2016a:

C:\Program Files\MATLAB\R2016a\toolbox\images\images\eml
C:\Program Files\MATLAB\R2016a\toolbox\images\iptutils

For me, in R2016b, I only see one showing up in the iptutils folder. Your problem appears to be that you have some subfolders in the Image Processing Toolbox that have been added to your MATLAB path even though they normally shouldn't be. The eml folder does not appear on my MATLAB path, and I don't think it's normally supposed to. I've seen issues like this sometimes appear during installation.

The version of iptcheckconn in the first folder is shadowing the version you really want to use in the second folder. You'll want to remove the first folder from the path so MATLAB uses the correct one. Alternatively, you could also leave that folder on the path but just move it down on the path list so it shows up after the second folder. From the documentation:

When files with the same name appear in multiple folders on the search path, MATLAB uses the one found in the folder nearest to the top of the search path.

Upvotes: 2

Related Questions