![]() Toc % display figure ( 'units', 'normalized', 'outerposition', ) subplot 151, imshow (CICcut, ) title ( 'Mass density' ) subplot 152, imshow (g, ) title ( 'Green`s function' ) subplot 153, imshow (filtered, ) title ( = G ( i, j ) = ( ( i- 1 )/lenMone - 0.5 )^ 2 + ( ( j- 1 )/lenMone - 0.5 )^ 2 įiltered = imfilter (g, CICcut, 'replicate', 'conv' ) įilteredFFT = conv2fft (g, CICcut, 'same' ) Gauss = fspecial ( 'gaussian', round ( sqrt (len ) ), sqrt ( sqrt (len ) ) ) ĬICcut = imfilter (CICcut, gauss, 'replicate', 'conv' ) Thanks in advance!ĬICcut = imnoise (CICcut, 'salt & pepper', 0.0001 ) If you have read my book, please be kind enough to post your feedback about it on Amazon ( link), for the benefit of others. But given the significant speedup potential, I contend that you should give it a try and see how well it performs on your specific system and data. It should be noted that the builtin Matlab functions can still be faster for relatively small data arrays, or if your machine has a large number of CPU cores and free memory that Matlab’s builtin conv* functions can utilize, and of course also depending on the Matlab release. Bruno’s implementation ( convnfft) is made even more efficient by using MEX in-place data multiplications, power-of-2 FFTs, and use of GPU/Jacket where available. This latest result shows that the results are nearly identical, up to a tiny difference, which is certainly acceptable in most cases when considering the enormous performance speedup (780x in this specific case). % Compare the relative accuracy (the results are nearly identical) ![]() N = length(x) + length(y) - 1 % we need to zero-pad % Compute the convolution using the builtin conv() % Compare the relative accuracy (the results are nearly identical) disp ( max ( abs (z1-z2 )./ abs (z1 ) ) ) N = length (x ) + length (y ) - 1 % we need to zero-pad tic, z2 = ifft ( fft (x,n ). % Now compute the convolution using fft/ifft: 780x faster! % Compute the convolution using the builtin conv() tic, z1 = conv (x,y ) toc % Prepare the input vectors (1M elements each)
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |