How to divide the sum of convolution value in matlab syntax?
Mostra commenti meno recenti
Hi,
I'm colvolving an image by using my own kernel as in the syntax. The question is, how can i get the average 1/9 for each of the convolution point as normally used in the smoothing process.
I = imread('C:\\MEKH\\conveg.jpg');
figure, imshow(I);
J=rgb2gray(I);
figure, imshow(J)
A = [1,1,1;1,1,1;1,1,1]
%how to get the average eg here 1/9
B = conv2(A,J)
figure, imshow(B)
Thanks
Risposta accettata
Più risposte (1)
Haritha GB
il 13 Giu 2020
I'm not entirely sure what your question means, since I am not familiar with the smoothing process.
From what I gather, you either want to a) find the sum of the entire output matrix elements and then divide by nine, or you want to b) divide each element of the output matrix by nine.
Either way the implementation line of code must come after calculating the convolution, i.e, put it after this line:
B = conv2(A,J)
So, for a)
m = length(B);
sum = 0;
for i = 1:m
sum = sum + B[i];
end
average = sum/9
And for b)
AVG = B/9
Hope I answered your question.
If you had intended otherwise with the question, let me know so I could answer it.
Categorie
Scopri di più su 2-D and 3-D Plots in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!