problem with strel function
Show older comments
Hi
I want to apply 'disk' structure on my balck and white image, however it rises an error as followe:
Undefined function or variable 'MakeDiskStrel'.
Error in main (line 25)
se =MakeDiskStrel();
my code:
I = imread('img.jpg');
gray = rgb2gray(I);
bw1 = imbinarize(gray);
bw2 = imfill(bw1,'holes');
se = strel('disk',10);
cl=imclose(bw2,se);
imshow(cl)
I am using MATLAB R2018b
12 Comments
Jon
on 6 Oct 2020
I don't see the line of code
se =MakeDiskStrel()
in the listing that you provided.
Without seeing the part of the code that is throwing the error it is difficult to give further guidance
fatemeh n
on 6 Oct 2020
Jon
on 6 Oct 2020
I'm sorry, I don't currently have an active license for the image processing toolbox, so I guess you will have to find someone who does to help you further
Walter Roberson
on 6 Oct 2020
MakeDiskStrel is a function defined at line 1028 of strel.m
fatemeh n
on 7 Oct 2020
Walter Roberson
on 7 Oct 2020
If you edit strel then what do you see at line 1028?
fatemeh n
on 8 Oct 2020
Walter Roberson
on 8 Oct 2020
Could you confirm that the same strel that you are executing that is complaining about MakeDiskStrel not existing, does in fact define a function MakeDiskStrel at line 1028?
If so then about the only way you could get that happening is if strel.m is corrupted at some point after the line that calls MakeDiskStrel so that MATLAB is unable to parse the rest of the file properly. If that is the case then if you edit strel you would very likely see a big red error mark at the point where MATLAB gives up parsing.
Jon
on 8 Oct 2020
I noticed that in the OP original post the error message is listed as
Undefined function or variable 'MakeDiskStrel'.
Error in main (line 25)
se =MakeDiskStrel();
Note that in the last line of the error message, there is no space between the equal sign and the function MakeDiskStrel();
Usually all of the official MATLAB code would have a space there, e.g.
se = MakeDiskStrel()
This makes me wonder if someone has been editing the original MATLAB source and perhaps breaking something in the process
Walter Roberson
on 8 Oct 2020
Interesting point, Jon. Indeed, the original code, line 211 in R2018b, is
se = MakeDiskStrel(params{:});
Notice that a parameter has been passed, but the code with the error message, no parameter was passed.
Therefore the user is not using the Mathworks strel.m
I wonder what the output is of
which -all strel
fatemeh n
on 9 Oct 2020
Walter Roberson
on 9 Oct 2020
what shows up for
which -all strel
It looks like you are activating a different file.
Answers (0)
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
