whats the meaning of this statement average = sum ( sum ( x(:,:) ) ) / n / n; ?
9 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
i am using this formula for increasing the contrast of the image. this is the formula used to calculate the average value of the after getting the size of the array of the image by using n=size(x,1); ? where x is the image on which we are working..
0 commentaires
Réponse acceptée
Daniel Shub
le 3 Mar 2014
The meaning of the statement
average = sum ( sum ( x(:,:) ) ) / n / n;
is that whoever wrote the code knows very little about MATLAB. Assuming x is an n x n matrix, the code calculates the average/mean by summing over all the columns to create a row of sums and then summing across the row to get the total sum of the matrix. It then divides by n twice to get the average. The same thing can be done much more clearly with
average = mean(x(:));
where (:) is needed to turn a matrix into a column vector.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Image Filtering and Enhancement dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!