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 an image processing operation on a GPU, follow these steps:

  • Move the data from the CPU to the GPU. Use the gpuArray 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. Any toolbox function that accepts a gpuArray object as an input can work on a GPU. For example, you can pass a gpuArray to the imfilter function to perform the filtering operation on a GPU. For a list of all the toolbox functions that have been GPU-enabled, see List of Supported Functions with Limitations and Other Notes.

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

When working with a GPU, note the following:

  • Performance improvements can depend on the GPU device.

  • There may 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


Related Examples

More About