This function bwmorph(Img,'skel',Inf) return the skeleton of a binary image.
What I'm looking for is the algorithm used by this function to do it manualy ?
The documentation gives an overview of the algorithm (scroll down a ways).
If you want to see the actual code within a function in MATLAB, you can try using the TYPE command:
type bwmorph %# Command form
type('bwmorph.m') %# Function form
Keep in mind, this will not work on all MATLAB functions. You may get a message that says the function is a built-in function, in which case the code will not be displayed. You can also try opening the file in the MATLAB Editor using the EDIT command:
edit bwmorph.m %# Command form
edit('bwmorph.m') %# Function form
Related
So in Matlab, if you start to type in a function like find( and then wait after the open parentheses, a small yellow popup will appear showing potential input options, like:
find(X)
find(X,K)
find(X,n,direction)
find(__)
So I'm wondering, is it possible to set up my own function so the same happens? I tried copying the find file in the format, so mine looks like this:
%MY_FUNCTION Description of function
% O = MY_FUNCTION(X) returns the output based on the input X.
%
% O = MY_FUNCTION(X,Y) returns the output based on the input Y.
But after saving it, when I type my_function(, all it shows is my_function(...). Is it just not possible for user functions? Thanks for any input!
It is possible to set up these hints for custom functions, but you can't do it in the function .m file. Instead, you need to put the information in a separate functionSignatures.json file in the same directory as the custom function. You can find the official documentation and file specification here.
I would like to know how to find all MATLAB function blocks in a Simulink model.
In a model in which I know there are a lot of MATLAB function blocks, I tried the following command:
find_system(myModel,'LookUnderMasks','on','FollowLinks','on','BlockType','MATLAB Function')
However, this command returns an empty cell array. If I try something like this:
find_system(myModel,'LookUnderMasks','on','FollowLinks','on','BlockType','Gain')
, I'm getting many results. Is the "MATLAB Function" an actual BlockType or is there another term to use?
You can use the following code to find all MATLAB function blocks.
S = sfroot();
% Get block handles
B = find(sfroot, '-isa','Stateflow.EMChart');
This will search all open models and returns a list of objects of type Stateflow.EMChart. You can look at the Path property of these objects to reduce the list to the model you want.
You will need to define the search depth use the below:
h=find_system(myModel,'SearchDepth',N, 'regexp', 'on', 'FollowLinks','on','Findall','on','LookUnderMasks','all', 'BlockType','Gain');
Specify N, the higher the N the deeper into the blocks the search will be.
Let me know if this doesn't work.
Im trying to perform centerline extraction for cardiac CT images, and I am stuck. I need an example code that uses the "fast marching method". I got this code from mathworks.
I1=im2double(imread('se036.png'));
SpeedImage=I1*1000+0.001;
SourcePoint=[800;803];
DistanceMap= msfm(SpeedImage, SourcePoint);
figure
imshow(DistanceMap,[0 3400]) StartPoint=[9;14];
ShortestLine=shortestpath(DistanceMap,StartPoint,SourcePoint);
hold on
plot(ShortestLine(:,2),ShortestLine(:,1),'r')
But I get error message Undefined function 'msfm' for input arguments of type 'double'.
It appears you are trying to use the Matlab File Exchange submission Accurate Fast Marching but you haven't properly installed the code. The function file you downloaded, msfm.m, needs to be in a folder on your path or in the current working directory.
I am building a reduced order observer in MATLAB. The matrices are calculated using functions/script files outside matlab and simulink function blocks are using these functions to calculate values.
The problem is that some commands like 'acker', 'place' etc which used to work on command window/function/script files are not working in simulink function block and showing errors.
I tried using simin block to take these matrices from workspace but it is also showing errors which I can't understand.
Thanks for your help.
If I get your question correctly then, from User defined functions, you could add a Matlab function block with the following code:
function fcn(in)
%#codegen
coder.extrinsic('acker', 'place')
# Now you can use acker, place so add more code.
I want to know how can this function(from MATLAB) resize the columns of an input image using weights an indices previously computed.
Which equations uses to do that?
resizeColumnsCore(double(in), weights', indices');
When I looked for a function called resizeColumnsCore in MATLAB 7.11.0 (R2010b) I didn't find anything. However, I did find a MEX-file by that name in MATLAB 7.8.0 (R2009a) in this subdirectory of the Image Processing Toolbox:
C:\Program Files\MATLAB\R2009a\toolbox\images\images\private\
I guess they've phased it out or replaced it with another function in newer MATLAB versions. Now, if you want to know what the MEX-file does, you need to look at the source code it is compiled from. Luckily, it appears that this source code resizeColumnsCore.cpp can be found in the following directory:
C:\Program Files\MATLAB\R2009a\toolbox\images\images\private\src\misc\
And you can look through that code to determine the algorithms used to resize the columns of an image given a set of weights and indices.
Now, if you want to know how these input arguments to resizeColumnsCore are computed, you'll have to look at the code of a function that calls it. I know of at least one function in the IPT that calls this function: IMRESIZE. If you type edit imresize at the command prompt it will open that function in the Editor, allowing you to look through the code so you can see how the arguments to resizeColumnsCore are created.
What I can tell you for R2009a is that there is a subfunction in the file imresize.m called contributions which computes the weights and indices that are ultimately passed as arguments to resizeColumnsCore. That is where you will want to start looking to determine what algorithms are used to compute these arguments.
Looks like this isn't a proprietary MATLAB function. Could we see some code or a link to the code?