Documentation

Code Generation for Image Processing

Certain Image Processing Toolbox™ functions have been enabled to generate C code usingMATLAB®Coder™. To use code generation with image processing functions, follow these steps:

  • Write your MATLAB function or application as you would normally, using functions from the Image Processing Toolbox.

  • Add the%#codegencompiler directive to your MATLAB code.

  • Open theMATLAB Coder应用程序,创建一个项目,并将您的文件添加到公关oject. Once in MATLAB Coder, you can check the readiness of your code for code generation. For example, your code may contain functions that are not enabled for code generation. Make any modifications required for code generation.

  • Generate code by clickingGenerateon the Generate Code page of theMATLAB Coderapp. You can choose to generate a MEX file, a shared library, a dynamic library, or an executable.

    Even if you addressed all readiness issues identified byMATLAB Coder, you might still encounter build issues. The readiness check only looks at function dependencies. When you try to generate code,MATLAB Codermight discover coding patterns that are not supported for code generation. View the error report and modify your MATLAB code until you get a successful build.

For more information about code generation, see theMATLAB Coderdocumentation. To see an example of using code generation, seeGenerate Code from Application Containing Image Processing Functions.

Note

To generate code from MATLAB code that contains image processing functions, you must have theMATLAB Codersoftware.

When working with generated code, note the following:

  • For some Image Processing Toolbox functions, code generation depends on a precompiled, platform-specific shared library.

Was this topic helpful?