Main Content

Image Processing on a GPU

To take advantage of the performance benefits offered by a modern graphics processing unit (GPU), certain Image Processing Toolbox™ functions have been enabled to perform image processing operations on a GPU. This can provide GPU acceleration for complicated image processing workflows. These techniques can be implemented exclusively or in combination to satisfy design requirements and performance goals.

To run image processing code on a graphics processing unit (GPU), you must have the Parallel Computing Toolbox™ software. To perform a supported image processing operation on a GPU, follow these steps:

  • Move the data from the CPU to the GPU. Use the gpuArray (Parallel Computing Toolbox) function to transfer an array from MATLAB® to the GPU. For more information, see Create GPU Arrays from Existing Data (Parallel Computing Toolbox).

  • Perform the image processing operation on the GPU. For a list of all the toolbox functions that have been GPU-enabled, see Functions Supporting GPU Computing.

  • Move the data back onto the CPU from the GPU. Use the gather (Parallel Computing Toolbox) function to retrieve an array from the GPU and transfer the array to the MATLAB workspace as a regular MATLAB array.

If you call a function with GPU support using at least one gpuArray (Parallel Computing Toolbox) input argument, then the function runs automatically on a GPU and generates a gpuArray as the result. You can mix inputs using both gpuArray and MATLAB arrays in the same function call. In this case, the function automatically transfers the MATLAB arrays to the GPU for execution.

When working with a GPU, note the following:

  • Performance improvements can depend on the GPU device.

  • There can be small differences in the results returned on a GPU from those returned on a CPU.

To learn about integrating custom CUDA kernels directly into MATLAB to accelerate complex algorithms, see Run CUDA or PTX Code on GPU (Parallel Computing Toolbox).

See Also

(Parallel Computing Toolbox) | (Parallel Computing Toolbox)

Related Examples

More About