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.
Best Answer