Average intensity of pixels

15 ビュー (過去 30 日間)
Inês
Inês 2022 年 1 月 11 日
回答済み: KALYAN ACHARJYA 2022 年 1 月 11 日
How can I ignore the bakground of this photo and calculate the average pixel intensity of the non black ones?

回答 (1 件)

KALYAN ACHARJYA
KALYAN ACHARJYA 2022 年 1 月 11 日
#One Way: Segmentation and useing Mask
im_original=read the image considering RGB Image
im_binary=imbinarize(rgb2gray(im_original),th);
#Segmentation
%. th^ Decide threshold value for good segementation
% Get the largest 2 blobs as per this case
mask_im=bwareafilt(im_binary,2);
total_pix=sum(mask_im(:));
#Mask the RGB Original Image
mask=cat(3,mask_im,mask_im,mask_im);
image_RGB=im;
image_RGB(~mask)=0;
#Average Pix
ave_pix=sum(image_RGB(:))/sum(mask(:));
disp(ave_pix); %Display the average pix
Hope it helps!

カテゴリ

Help Center および File ExchangeImage Processing Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by