M file turn C / C , IMAGE toolbox
Without further ado, directly to the question below is an m-file, call the function image toolbox %%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%% Function SHEN009 () i = I = IM2BW (i); I1 = bwmorph ( I, 'Bridge'); Figure, IMSHOW (I1, []) %%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%
Use my method mentioned in "Summary: M file to C / C language files, VC compilation" to transform it into a separate running program:
MCC -B SGLCPP SHEN009
(I want to explain the following, my ultimate purpose is not to compile it into a separate running program, but to embed it into my VC code, but each time you compile it into a separate running program. It is normal to run, and then embedded in the VC code is a good habit. This will save a lot of debugging. This time it generates an executable called Shen009.exe, running it in the command line, there is a problem, prompting :
C: / Matlab6p5 / Work / Testimage> SHEN009EXCEPTION! FILE: HANDLER.CPP, LINE: 73 Reference To Unknown Function 'Checknargin' from FEVAL in Stand-Alone Mode. It shows that a unknown function is quoted, search for Matlab installation. Directory, we found Checknargin.m files in C: / Matlab6p5 / Toolbox / Images / images / private, (this is the "Directory of the Image Toolbox) After analyzing the file, it is found to have some parameter checks. In order to make our program function properly, we have called this function once in SHEN009.M, which is changed to:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%% Function Shen009 () Checknargin (0, 0, 0) i = I = IM2BW (i); I1 = BWMORPH (I, 'Bridge' Figure, IMSHOW (I1, []) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%
Compile, then run, new error prompt appearance: c: / matlab6p5 / work / testimage> shen009Exception! File: handler.cpp, line: 73 undefined function or variable 'checknargin'. This prompt Checknargin is an undefined function Please pay attention to the difference between "unknown" and "undefined". Let's do something again, this thing is very interesting: We copied Checknargin.m into the directory where you started in SHEN009.M. Compile, run again. New mistake:
C: / Matlab6p5 / Work / Testimage> SHEN009EXCEPTION! File: Handler.cpp, Line: 73 Reference To Unknown Function 'Checkinput' from Feval in Stand-Alone Mode. This time, checknargin is not, checkinput is coming again. I know what to do this time: In the SHen009.m, CHECKNARGIN is called once, let Checknargin.m copied to the directory where the SHEN009.M is located. SHEN009.M becomes this: %%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%% Function Shen009 () Checknargin (0, 0, 0) Checkinput (0, {'Numeric' 'logical' }, {'REAL' '' NONSPARS '' '2D'}, ... MfileName, 'BW', 1) i = IMREAD ('444.tif'); i = IM2BW (i); I1 = BWMORPH (I, ' Bridge '); figure, IMSHOW (I1, []) %%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Compile, then run, success. Ok, the rest is to compile it into a dynamic link library, add it to the VC, please refer to my "Simplified M file to C / C files, VC compilation". There are problems that encounter Checknargin, checkinput can be treated so. Summarize: Two things need to do when transformation involving the IMAGE toolbox: 1. Join the following two sentences in the M file: Checknargin (0, 0, 0) Checkinput (0, {' Numeric '' Logical '}, {' REAL '' '' '2D'}, ... MfileName, 'BW', 1) 2. Copy checknargin.m, checkinput.m to the directory where the M file is located.