How to calculate single average of all rows and single average of all columns of image?
4 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposte (1)
Jan
il 19 Gen 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.
Vedere anche
Categorie
Scopri di più su Numeric Types in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!