whats the meaning of this statement average = sum ( sum ( x(:,:) ) ) / n / n; ?
9 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Daniel Shub
2014-3-3
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.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Filtering and Enhancement 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!