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 ssatisfy design requirements and performance goals. form an image processing operation on a GPU, follow these steps:
Move the data from the CPU to the GPU. You do this by creating an object of type gpuArray, using the gpuArray function.
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. Applications typically move the data from the GPU back to the CPU after processing, using the gather function.
For more information:
For general information about using GPUs, see Transfer Arrays Between Workspace and GPU.
To see an example of performing image processing operations on a GPU, see Perform Thresholding and Morphological Operations on a GPU.
To see an example of using the MATLAB® arrayfun function to perform element-wise or pixel based operations on a GPU, see
To learn about integrating custom CUDA kernels directly into MATLAB to accelerate complex algorithms, see Run CUDA or PTX Code on GPU.
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.