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.

Antworten (1)

DGM
DGM am 11 Jun. 2021
Bearbeitet: DGM am 11 Jun. 2021

1 Stimme

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 Kommentare

Audrey SCARLETT
Audrey SCARLETT am 11 Jun. 2021
Votre code ne compile pas. J'ai supprime le second fichier et toujours rien
Audrey SCARLETT
Audrey SCARLETT am 11 Jun. 2021
Not enough input arguments.
Error in run (line 28)
if isempty(scriptname)
Error in dicom (line 85)
run
DGM
DGM am 11 Jun. 2021
Bearbeitet: DGM am 11 Jun. 2021
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
Audrey SCARLETT am 11 Jun. 2021
fid = fopen('conndef.m');
a = fgetl(fid);
fclose(fid);
im2=~im1;
%imshow(im2,[])
D=- bwdist(im2);
%imshow(D,[])
im3= watershed(D);
Audrey SCARLETT
Audrey SCARLETT am 11 Jun. 2021
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 89)
im3= watershed(D);
DGM
DGM am 11 Jun. 2021
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
Audrey SCARLETT am 14 Jun. 2021
J'ai teste le code:
fid=fopen('conndef.m');
a=fgetl(fid);
fclose(fid);
et j'ai fid=3 et a= 1*1256 char
Je suppose que j'ai 3 fichiers conndef.m mais comment les voir?
DGM
DGM am 14 Jun. 2021
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
Audrey SCARLETT am 14 Jun. 2021
J'ai essaye conndef -all sans resultat. Etrange!
fid=fopen('conndef.m');
a=fgetl(fid);
fclose(fid);
conndef -all
L'erreur:
>> newfile
Error: File: conndef.m Line: 1 Column: 1
Unexpected MATLAB operator.
Error in newfile (line 4)
conndef -all;
DGM
DGM am 14 Jun. 2021
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
Audrey SCARLETT am 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 am 23 Jun. 2021
Bearbeitet: Image Analyst am 23 Jun. 2021
You forgot the which
which -all conndef
^^^^^^^

Melden Sie sich an, um zu kommentieren.

Produkte

Version

R2017b

Gefragt:

am 11 Jun. 2021

Bearbeitet:

am 23 Jun. 2021

Community Treasure Hunt

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

Start Hunting!

Translated by