Trying to vectorize a column-wise image processing step
显示 更早的评论
I have a single-precision dataset specdata of size nPix x nObs. Each column 1..nObs is a (diffcols x diffrows) image stored unfolded. (nPix=diffrows*diffcols)
I can batch process them easily like this:
blurredData = zeros( size( specdata ), 'single');
for a=1:nObs
blurredData(:,a) = reshape(imgaussfilt( reshape(specdata(:,a),...
diffcols,diffrows), 0.75 ), nPix,1);
end
But, I would like to cleverly vectorize this loop if possible. This:
f = @( D, diffrows, diffcols, nPix ) reshape(imgaussfilt( reshape(D,diffcols,diffrows), 0.75 ), nPix,1);
ii = 1:nObs;
S(:, ii ) = f(specdata(:,ii),diffrows,diffcols,nPix);
blows up ("To RESHAPE the number of elements must not change."), apparently because I'm passing all of specdata to the reshape.
Any thoughts? Is there some obvious vectorization I am missing?
Thanks.
采纳的回答
更多回答(1 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Image Filtering 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!