How to calculate single average of all rows and single average of all columns of image?
4 ビュー (過去 30 日間)
古いコメントを表示
I am having a gray image of size 256 by 256 and want to calculate row and column mean. I am able to calculate column mean of image as follow im=imread('E:\xyz.jpg') cmean=mean(mean(im)); In order to take row mean I took transpose of im matrix and then calculated the mean. im1 = transpose(im); rmean=mean(mean(im1));
Column and row mean should be different. But gives the same answer for row and column mean. What is wrong?
0 件のコメント
回答 (1 件)
Jan
2017 年 1 月 19 日
As explained in the documentation of doc mean, the dimension to operate on can be defined by the second input:
x = rand(10, 10);
m_dim1 = mean(x, 1);
m_dim2 = mean(x, 2);
If mean(X) and mean(X.') reply the same values, either X is a vector or the means are equal. mean(X) without specifying the dimension operates on the first non-singelton dimension. This is risky: You save half a second during typing, but might spend hours with debugging. So prefer to define the dimension explicitly, because sometime Matlab's smart decisions to guess what you want, are too smart.
参考
カテゴリ
Help Center および File Exchange で Numeric Types についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!