GPUCONV2

版本 1.0.0.0 (11.2 KB) 作者: Dirk-Jan Kroon
Example, Matlab R2010B Cuda CONV2 on GPU using Cuda kernels
1.6K 次下载
更新时间 2010/12/8

查看许可证

GPUCONV2 Two dimensional convolution on the GPU using Cuda.

C = GPUCONV2(A, B) performs the 2-D convolution of matrices A and B.
If [ma,na] = size(A), [mb,nb] = size(B), and [mc,nc] = size(C), then
mc = max([ma+mb-1,ma,mb]) and nc = max([na+nb-1,na,nb]).

C = GPUCONV2(A, B, SHAPE) returns a subsection of the 2-D
convolution with size specified by SHAPE:
'full' - (default) returns the full 2-D convolution,
'same' - returns the central part of the convolution
that is the same size as A.
'valid' - returns only those parts of the convolution
that are computed without the zero-padded edges.
size(C) = max([ma-max(0,mb-1),na-max(0,nb-1)],0).

Note!
This function depends on two Cuda kernel files
conv2_float.cu and conv2_double.cu which needs to be compiled
to .ptx files using the nvcc compiler.

See also CONV2, NVCC

Example,
Load an image
I=im2double(imread('moon.tif'));
Create a Gaussian filtering kernel
H = fspecial('gaussian',[20 20],3);
Perform the convolution on the CPU
J = conv2(I,H);
Perform the convolution on the GPU
Jcuda = gpuconv2(I,H);
Show the results
figure,
imshow(J,[]); title('CPU filtering');
imshow(Jcuda,[]); title('GPU filtering');
imshow(Jcuda-J,[]); title('Difference');

引用格式

Dirk-Jan Kroon (2024). GPUCONV2 (https://www.mathworks.com/matlabcentral/fileexchange/29648-gpuconv2), MATLAB Central File Exchange. 检索时间: .

MATLAB 版本兼容性
创建方式 R2010b
兼容任何版本
平台兼容性
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
版本 已发布 发行说明
1.0.0.0