Code Error?
Show older comments
Hi, I'm new in Matlab and I've problem in running this code below, can anyone tell me how to solve the problem? And also, where to put in the image? Thanks a lot:)
[EDITED: Code copied from Matlab toolbox function deleted, Jan S]
% Skip NaN check here; it will be done by imreconstruct if input
% is double.
[EDITED: Code formatted, Jan S]
6 Comments
Jan
on 4 May 2012
Please format your code and use meaningful tags. Thanks.
You forgot to mention which problem you have. Do you get an error message, if so, which one and wehere? Or do the results differ from your expectations, and if so, how?
Superb
on 4 May 2012
Daniel Shub
on 4 May 2012
This is a clear case of copyright infringement. This code has been copied from the imclearborder function in the IPT.
Jan
on 4 May 2012
*All* questions in this forum concern "Matlab", and only some theoretical questions do not concern "Matlab code". Therefore the tag "Matlab code" is not sufficient to classify the question. See http://www.mathworks.com/matlabcentral/answers/33319-is-matlab-or-matlab-code-a-useful-tag
Please follow the "Markup help" link on this page for an introduction in formatting messages in this forum. Further good tips are found at:
http://www.mathworks.com/matlabcentral/answers/6200-tutorial-how-to-ask-a-question-on-answers-and-get-a-fast-answer
http://www.mathworks.com/matlabcentral/answers/13205-tutorial-how-to-format-your-question-with-markup
Superb
on 4 May 2012
Jan
on 4 May 2012
Please, Superb, do not post copyright protected code. This conflicts with the license conditions you have accepted, while you have installed Matlab. You can use the code and modify copies of Matlab's toolbox functions, but you cannot copy it. And do not forget to mention the author of the code, when you submit it as homework.
Answers (1)
Jan
on 4 May 2012
0 votes
You cannot define a function inside a script. The differences between functions and scripts are explained in the documentation. An easy solution is to convert the M-file to a function by starting it with the term "function" and define for the inputs and outputs as arguments.
11 Comments
Superb
on 4 May 2012
Jan
on 4 May 2012
I have to guess what you want. It is *not*, that you have a painting on paper and want to scan it.
But I cannot guess how you have your "image" represented: As file name, imported by IMREAD or a live picture from a web cam?
Are you asking for the way to define inputs and outputs of a function? While you can see a lot of examples in Matlab's toolbox functions, it is explained in general in the Getting Started chapters of the documentation.
Superb
on 4 May 2012
Walter Roberson
on 4 May 2012
Do not put those three lines inside the imclearborder() routine. Leave imclearborder() completely unchanged (not a copy.) Then in a _different_ .m file, put the lines
I=imread('21.jpg');
bw=im2bw(I);
figure, imshow(bw);
newbw = imclearborder(bw);
figure, imshow(newbw);
Superb
on 4 May 2012
Walter Roberson
on 4 May 2012
conn2array() is a method that is specific to the "image" object class, and cannot be accessed from outside of that.
I do not understand why you are wanting to use a modified imclearborder() rather than using the built-in one?
Superb
on 5 May 2012
Daniel Shub
on 5 May 2012
Converting copyright MATLAB code into OpenCV seems to be a direct violation of the MATLAB EULA.
Superb
on 5 May 2012
Jan
on 5 May 2012
@Superb: Either you reprogram the function from scratch by your own, or you pay somebody to do this for you. But copying or "converting" copyrighted code is not an option.
You will not get assistance for stealing Matlab code in this forum.
Superb
on 6 May 2012
Categories
Find more on MATLAB Coder 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!