複数の画像の平均輝度値を取得する方法
12 views (last 30 days)
Show older comments
複数の画像の平均輝度値を取得したいと思っています。
どのような方法があるでしょうか。ご回答いただけると幸いです。
0 Comments
Accepted Answer
Kenta
on 11 Sep 2019
for文で各画像を参照しながら、mean(image, 'all')で平均輝度値を取り出し、さらにそれらの平均をとれば
複数の画像の平均輝度値をとりだすことができます。
5 Comments
Kenta
on 17 Sep 2019
Edited: Kenta
on 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 ;
More Answers (0)
See Also
Categories
Find more on イメージ算術 in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!