複数の画像の平均輝度値を取得する方法
12 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Asaka Masahiro
le 11 Sep 2019
Commenté : Asaka Masahiro
le 17 Sep 2019
複数の画像の平均輝度値を取得したいと思っています。
どのような方法があるでしょうか。ご回答いただけると幸いです。
0 commentaires
Réponse acceptée
Kenta
le 11 Sep 2019
for文で各画像を参照しながら、mean(image, 'all')で平均輝度値を取り出し、さらにそれらの平均をとれば
複数の画像の平均輝度値をとりだすことができます。
5 commentaires
Kenta
le 17 Sep 2019
Modifié(e) : Kenta
le 17 Sep 2019
int=zeros(40,1);
for i=1:40
if i<=20
filename=sprintf('A%d.png',i);
I=imread(filename);
int(i)=mean(I,'all');
else
filename=sprintf('B%d.png',i-20);
I=imread(filename);
int(i)=mean(I,'all');
end
end
ave_int=mean(int);
img=ones(size(I,1),size(I,2)).*ave_int;
figure;imshow(uint8(img));
40枚でそれぞれ、全ピクセルの輝度の平均を計算
その輝度の値をもつ1チャンネルの画像を生成
例)全画像の平均輝度が100の場合:画像サイズがAやB画像と同じで、すべてのピクセルの値が100の画像を出力
このような感じですが、質問者さまの意図が正しくくみ取れていますでしょうか。
ちなみに、上では、rgb2grayをしてから平均を計算されていたと思いましたが、
グレースケール化には、以下のような変換式をが使われています。
そのため、厳密にRGBの平均をとって計算しているわけではないので、
注意が必要です。
gray_image=0.2989 * R + 0.5870 * G + 0.1140 * B ;
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur イメージ算術 dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!