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!