mathematical operation on each element of gpuArray
5 ビュー (過去 30 日間)
古いコメントを表示
How can i do mathematical operation on each element of gpuArray with the equation below? s = 2r(i, j) − r(i, j +1) + r(i, j −1). here r is the image matrix. I've written the code below:
im = imread('(HTC-1-M7)1.jpg');
tic
img = gpuArray(im);
for j =2: size(im,2) -1
A(:,:,:) = 2*img(:, :,:) -img(:,j+1,:) + img(:, j-1,:);
end
B = gather(A);
toc
Is there anyway to apply equation on each element of gpuarray with function like arrayfun without using loop? Thanks in advance.
2 件のコメント
Matt J
2018 年 1 月 22 日
Are you certain that it is not a 2nd order differencing filter that you want:
s = 2r(i, j) − r(i, j +1) - r(i, j −1)
参考
カテゴリ
Help Center および File Exchange で GPU Computing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!