How to get average intensity from a selected image window

1 回表示 (過去 30 日間)
Tania
Tania 2014 年 11 月 26 日
回答済み: Abdullah 2017 年 2 月 8 日
Hi everyone,
I have got the intensity value like below from the selected image window.
66 61 54
65 59 55
60 54 60
How can I get the average of this numbers.
Any advice?
Thanks

採用された回答

Guillaume
Guillaume 2014 年 11 月 26 日
First of all, usually x is used to refer to the horizontal dimension and y to the vertical one. That's the 2nd and 1st dimension of your matrix respectively. So to access pixel (x, y), you need to do:
value = I(y, x);
Because of that, I usually don't use x and y as a variable, but row and col.
Secondly, to access a rectangle of pixels, don't use a loop (particularly as you keep overwriting the scalar value), but just use matrix indexing:
values = I(y-g:y+g, x-g:x+g)
Finally to get the average of all values in a matrix:
meanvalues = mean(values(:));
  1 件のコメント
Tania
Tania 2014 年 11 月 26 日
Excellent, Works perfect

サインインしてコメントする。

その他の回答 (1 件)

Abdullah
Abdullah 2017 年 2 月 8 日
How to let x and y read the row and column ?

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by