How to calculate the mean of an image?

조회 수: 90 (최근 30일)
bh dhouha
bh dhouha 2015년 2월 16일
댓글: Kweku Nkrumah 2018년 6월 15일
How to calculate the mean of an image? Does the code mean2(img) give the right result?

채택된 답변

Image Analyst
Image Analyst 2015년 2월 16일
To calculate the mean of all pixels in the image, without regard to what color channel they came from (if it's a color image), you do
meanIntensity = mean(img(:));
What you did will not do it, as I'm sure you found out.
  댓글 수: 2
bh dhouha
bh dhouha 2015년 2월 16일
편집: bh dhouha 2015년 2월 16일
Thank you very much :) just a little thing : i used mean(mean(img1(:,:,1)))and it gave me the same result as mean(img1(:)).The first code is focused on the red channel only i think-as you answered me in another question- so how could it be the same result?
Image Analyst
Image Analyst 2015년 2월 16일
It could be the same if the image was gray since the blue and green channel would be identical to the red channel. It would also be the same for lots of other cases, like where the green and blue channels are scrambled (spatially rearranged) versions of the red channel since they would have the same pixel values regardless of how they're rearranged.

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

추가 답변 (1개)

Rashmi.D Jeya kumar
Rashmi.D Jeya kumar 2018년 1월 8일
meanval = mean2(I) you can get mean value of an image
  댓글 수: 3
Image Analyst
Image Analyst 2018년 6월 13일
Why does that mean anything is wrong? Maybe you took a bunch of photos through a microscope and they all have the same mean brightness (or really close to each other). Doesn't seem inherently unusual to me. Why do you think it indicates something is wrong?
Kweku Nkrumah
Kweku Nkrumah 2018년 6월 15일
Ok. I get it now. Thank you.

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

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by