【发布时间】:2016-11-14 09:58:01
【问题描述】:
我有一个大小为 (nrows x cols x ndivs) 的 3-D 数组(图像),我希望以 0.01 的间距计算沿第 3 维的 1-D 数值梯度,并获得 (nrows x ncols) 的梯度集。
我已经想到了一种通过循环遍历每个像素的方法:
grad_F = zeros(nrows,ncols,ndivs);
for irow = 1:nrows
for icol = 1:ncols
grad_F(irow,icol,:) = gradient(F(irow,icol,:),0.01);
end
end
我想问一下是否有梯度的数组操作来做上面的而不循环每个像素?如果有这样的方法,是更快还是需要同样的时间?
【问题讨论】: