% Create an image that is the shape of a 2-dimensional Gaussian density. % Do 'help fspecial' for information on the fspecial function. g2=fspecial('gaussian', [25 25 ],3); imagesc(g2); k=g2; % Create an image with a sparse set of pixels turned on. sparseim=zeros(100); for i=1:10000 sparseim(round(rand*99+1),round(rand*99+1))=rand; end subplot(1,2,1); imagesc(sparseim); % Use conv2 to do two-dimensional convolution in matlab, using the % Gaussian kernel we created above. smoothim=conv2(sparseim,k); subplot(1,2,2); imagesc(smoothim);