Calculate mean of gray Value
8 ビュー (過去 30 日間)
古いコメントを表示
Hello, In this picture I want to calculate mean of the circle. but when I use mean( ) it calculates all the pixels including the black ones, so the mean value decreases. Is there a way to calculate only the gray value?
Thank you in advance.
0 件のコメント
採用された回答
その他の回答 (1 件)
Chad Greene
2021 年 3 月 31 日
Try this. Below I'm creating an example matrix M, and calculate the mean of only the values that exceed zero:
M = peaks(100); % example matrix
M(M<=0) = 0;
figure
imagesc(M)
colormap(gray)
colorbar
mask = M>0; % logical mask corresponding to all values greater than zero
figure
imagesc(mask)
mean(M(mask),'all') % mean of all values of M that exceed zero.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Modify Image Colors についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!