error while running watershed

1 view (last 30 days)
Audrey SCARLETT
Audrey SCARLETT on 11 Jun 2021
Edited: Image Analyst on 23 Jun 2021
My code:
im2=~im1;
%imshow(im2,[])
D=- bwdist(im2);
%imshow(D,[])
im3= watershed(D);
The error message:
Error: File: conndef.m Line: 1 Column: 1
Unexpected MATLAB operator.
Error in watershed>parse_inputs (line 158)
conn = conndef(ndims(A), 'maximal');
Error in watershed (line 140)
[A,conn] = parse_inputs(varargin{:});
Error in dicom (line 87)
im3= watershed(D);
I can't figure what the problem is.

Answers (1)

DGM
DGM on 11 Jun 2021
Edited: DGM on 11 Jun 2021
I don't know how you'd be getting that error unless there's a problem with conndef.m
Maybe it's being shadowed, so check the path:
which conndef -all
/MATLAB/toolbox/images/images/conndef.m
If you have some other file that's overloading conndef.m, you'll have to remove it from the path or reduce its precedence.
Maybe it's a bad install or corruption? You can look at the file by opening it, or just fetch the first line and see if it makes sense. The IPT version at the above path would look like this:
fid = fopen('conndef.m');
a = fgetl(fid);
fclose(fid);
a
a = 'function conn = conndef(num_dims,type)'
That's my guess.
  12 Comments
Audrey SCARLETT
Audrey SCARLETT on 14 Jun 2021
J'obtiens toujours une erreur
>> conndef -all
Error: File: conndef.m Line: 1 Column: 1
Unexpected MATLAB operator.
Image Analyst
Image Analyst on 23 Jun 2021
Edited: Image Analyst on 23 Jun 2021
You forgot the which
which -all conndef
^^^^^^^

Sign in to comment.

Products


Release

R2017b

Community Treasure Hunt

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

Start Hunting!