複数の画像の平均輝度値を取得する方法
15 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Asaka Masahiro
am 11 Sep. 2019
Kommentiert: Asaka Masahiro
am 17 Sep. 2019
複数の画像の平均輝度値を取得したいと思っています。
どのような方法があるでしょうか。ご回答いただけると幸いです。
0 Kommentare
Akzeptierte Antwort
Kenta
am 11 Sep. 2019
for文で各画像を参照しながら、mean(image, 'all')で平均輝度値を取り出し、さらにそれらの平均をとれば
複数の画像の平均輝度値をとりだすことができます。
5 Kommentare
Kenta
am 17 Sep. 2019
Bearbeitet: Kenta
am 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 ;
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu イメージ算術 finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!