How to apply hsize of 3x3 square matrix into gaussian filter ?

1 view (last 30 days)
I saw a few examples of gaussian filter. H = FSPECIAL('gaussian',N,SIGMA). I found that N is always a 1-by-2 vector specifying the number of rows and columns in H. My question is, I have 3x3 matrix square of N, i.e. [1 2 3; 4 5 6; 7 8 9], How do I put this 3x3 matrix square of N into FSPECIAL('gaussian',N,Sigma. I have tried to infer N as [1 2 3; 4 5 6; 7 8 9] and the errors are listed as below: _ _??? Error using ==> iptcheckinput Function FSPECIAL expected its second input, N, to be integer-valued.
Error in ==> fspecial>ParseInputs at 347 iptcheckinput(p2,{'double'},...
Error in ==> fspecial at 97 [type, p2, p3] = ParseInputs(varargin{:});__

Answers (1)

Wayne King
Wayne King on 9 Apr 2012
Why are you trying to do that? fspecial() gives you the Gaussian filter, then you use that to filter your matrix.
H = fspecial('gaussian',[3 3],0.5);
A = [1 2 3; 4 5 6; 7 8 9];
out = imfilter(A,H,'replicate');

Categories

Find more on Image Processing Toolbox in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!