Filter löschen
Filter löschen

画像からある範囲の平均輝度値を取得する方法

16 Ansichten (letzte 30 Tage)
daisuke shuugisono
daisuke shuugisono am 7 Jun. 2018
添付画像の円のそれぞれの平均輝度値を取得したいです。 どのような方法がありますか? ご回答よろしくお願いいたします。

Akzeptierte Antwort

Akira Agata
Akira Agata am 7 Jun. 2018
Bearbeitet: Akira Agata am 8 Jun. 2018
例えば以下のようにすると、 regionprops 関数でそれぞれの円領域に含まれるピクセルの位置情報を取得したうえで、その情報を使って円ごとの輝度の平均値を算出することができます。
% Read image and convert to gray-scale
I = imread('sample_circles.bmp');
Igray = rgb2gray(I);
% Obtain regions of interest
BW = imbinarize(Igray);
BW = imclearborder(BW);
se = strel('disk',1);
BW = imclose(BW,se);
% Obtain information for each region
s = regionprops('table',BW,{'Centroid','BoundingBox','PixelIdxList'});
% Calculate average luminance for each region
avLuminance = zeros(height(s),1);
for kk = 1:height(s)
avLuminance(kk) = mean(Igray(s.PixelIdxList{kk}));
end
% Show the result
figure
imshow(Igray)
hold on
for kk = 1:height(s)
rectangle('Position', s.BoundingBox(kk,:),'EdgeColor', 'c');
text(s.Centroid(kk,1),s.Centroid(kk,2),...
sprintf('%.1f',avLuminance(kk)),...
'FontWeight', 'bold',...
'HorizontalAlignment','center',...
'Color', 'c')
end
  1 Kommentar
daisuke shuugisono
daisuke shuugisono am 8 Jun. 2018
ご回答ありがとうございます。 参考にさせていただきます。

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Produkte

Community Treasure Hunt

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

Start Hunting!