Integration and average of the pixel values for an image.

2 ビュー (過去 30 日間)
Joydeb Saha
Joydeb Saha 2021 年 9 月 30 日
コメント済み: DGM 2021 年 9 月 30 日
If I have a spatial map, how can I calculate the integration and average of the pixel values for the map? say my file nname is 'spatial.png' . I should get two numbers.

採用された回答

DGM
DGM 2021 年 9 月 30 日
You just mean the global sum and mean? Should the image be normalized? Assuming not:
A = imread('cameraman.tif'); % this is uint8 (0-255)
sumA = sum(A,'all')
sumA = 7780728
meanA = mean(A,'all')
meanA = 118.7245
Just to demonstrate that it makes sense:
sumA/numel(A) % same as the mean
ans = 118.7245
  2 件のコメント
Joydeb Saha
Joydeb Saha 2021 年 9 月 30 日
Error using sum
Invalid option. Option must be 'double', 'native', 'default', 'omitnan' or 'includenan'.
what should i do then,,
DGM
DGM 2021 年 9 月 30 日
You must be using an older version. I don't remember when the options changed, but this should do the same:
sumA = sum(A(:))
meanA = mean(A(:))

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeOctave についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by