Defining an n x n matrix that is the Gaussian
17 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
MLnoob5340
il 23 Set 2014
Commentato: Image Analyst
il 23 Set 2014
I am doing practice problems in a digital image processing book One of the questions is:
Define an 9x9 matrix that is a Gaussian function of the form exp(−((x−x0)^2+(y−y0)^2)/w)where x0 and y0 denote the center of the matrix and w is a width parameter.
x0 & y0 = 64
You are supposed to experiment with the values of w to see what happens I am extremely new to MATLAB
My thoughts were creating a 9x9 matrix of ones and multiplying it by the function???? However I am pretty sure a loop needs to be made.
I don't know how to input functions or how to go about this. Later it says to convolve this matrix with a previous matrix I made (which I do now how to do...lol)
0 Commenti
Risposta accettata
Image Analyst
il 23 Set 2014
You don't need a loop. You can use fspecial() if you have the Image Processing Toolbox. See my DOG filter demo, attached. If you want a loop, you can do (untested)
gFilter = zeros(9,9);
x0=64;
y0=64;
for col = 1 : 9
for row = 1 : 9
gFilter(row, column) = exp(−((col−x0)^2+(row−y0)^2)/w);
end
end
Of course with the filter centered at 5,5 and your Gaussian centered at 64,64, your 9x9 array will be just a distant patch on the far side of the hump.
2 Commenti
Image Analyst
il 23 Set 2014
gFilter is the 9 by 9 array that is the Gaussian filter. First I initialize it to all zeros, then I scan it element by element and assign the correct value according to your formula (strange as it may be). row and col are just normal for loop iterators just like any other for loop you've ever seen in MATLAB.
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Matrix Indexing in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!