How to calculate single average of all rows and single average of all columns of image?
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (1)
Jan
am 19 Jan. 2017
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.
Siehe auch
Kategorien
Mehr zu Numeric Types finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!