Trying to vectorize a column-wise image processing step
Show older comments
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.
Accepted Answer
More Answers (1)
Chad
on 29 Sep 2017
0 votes
Categories
Find more on Image Filtering in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!