필터 지우기
필터 지우기

How to calculate single average of all rows and single average of all columns of image?

조회 수: 4 (최근 30일)
anu
anu 2017년 1월 19일
편집: anu 2017년 1월 19일
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?

답변 (1개)

Jan
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.
  댓글 수: 1
anu
anu 2017년 1월 19일
Your solution is working. But when I applied my solution for following example, its working properly.
A = [0 1 1; 2 3 2; 1 3 2; 4 2 2]
A =
0 1 1
2 3 2
1 3 2
4 2 2
mean(A)
ans =
1.7500 2.2500 1.7500
>> B=transpose(A)
B =
0 2 1 4
1 3 3 2
1 2 2 2
>> mean(B)
ans =
0.6667 2.3333 2.0000 2.6667
But when applied to image matrix not working properly. why?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Images에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by