Generating Gaussian filters in a loop
Afficher commentaires plus anciens
I want to filter an image with generated in a loop Gaussian filters and compare results.
*Error: In an assignment A(I) = B, the number of elements in B and I must be the same.
Error in PL8ex2 (line 19) fg(i) = fspecial('gaussian', h, s);*
org = imread('leftretina.tif');
%grey = rgb2gray(org);
%h = fspecial('gaussian', hsize, sigma) returns a rotationally symmetric
%Gaussian lowpass filter of size hsize with standard deviation sigma
%(positive). hsize can be a vector specifying the number of rows and
%columns in h, or it can be a scalar, in which case h is a square matrix.
%The default value for hsize is [3 3]; the default value for sigma is 0.5.
%Not recommended. Use imgaussfilt or imguassfilt3 instead.
LG = zeros(1,6);
fg = zeros(1,6);
hsize = [3 5 7 9 11 20];
sigma = [0.5 0.8 1 1.5 2 3];
title = zeros(1,6);
for i=1:6
h=hsize(i);
s=sigma(i);
fg(i) = fspecial('gaussian', h, s);
LG(i) = imfilter(org,fg(i)); % Gaussian filter
title(i) = sprintf('Gaussian filter of size %d and sd %,2f.',h, s);
end
%Graphics
subplot(2,3,1); imshow(LG(1));
title(title(1),'FontSize',12);
subplot(2,3,2); imshow(LG(2));
title(title(2),'FontSize',12);
subplot(2,3,3); imshow(LG(3));
title(title(3),'FontSize',12);
subplot(2,3,4); imshow(LG(4));
title(title(4),'FontSize',12);
subplot(2,3,5); imshow(LG(5));
title(title(5),'FontSize',12);
subplot(2,3,6); imshow(LG(6));
title(title(6)','FontSize',12);
Thank you in advance.
Réponses (0)
Catégories
En savoir plus sur Image Filtering dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!