error while running watershed
显示 更早的评论
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.
回答(1 个)
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
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
That's my guess.
12 个评论
Audrey SCARLETT
2021-6-11
Audrey SCARLETT
2021-6-11
which conndef -all
Should definitely return something. Your original error verifies that there is a function called conndef on the path.
The error in the above comment isn't related to either your original posted code or my posted code. It's just plain invalid usage of run(). You need to specify the file when using run(). See help run
Audrey SCARLETT
2021-6-11
Audrey SCARLETT
2021-6-11
DGM
2021-6-11
This is basic troubleshooting. These steps I'm suggesting aren't going to instantly fix your script, so don't try to just paste them into it. You just need to run them and observe the output.
Pasting them into the console should suffice. My answer shows what should be printed when the code is run in the console. The first line should give the paths to all files called conndef. The second should return line 1 from the version of conndef with the highest precedence. That information is key to finding out why conndef isn't working.
Audrey SCARLETT
2021-6-14
DGM
2021-6-14
The number 3 returned by
fid=fopen('conndef.m');
is just a handle. It's not the number of files.
If you run
which conndef -all
it should tell you where all the files are and which one is being used.
But yes, you do appear to have a conflicting version of the file somewhere.
Audrey SCARLETT
2021-6-14
DGM
2021-6-14
The command is
which conndef -all
(case-sensitive)
Just paste it in the console and hit enter. Don't bother trying to put it into the script. Just run it by itself.
There should be at least 1 result.
Audrey SCARLETT
2021-6-14
Image Analyst
2021-6-23
编辑:Image Analyst
2021-6-23
You forgot the which
which -all conndef
^^^^^^^
类别
在 帮助中心 和 File Exchange 中查找有关 Morphological Operations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!