How can I get the intensity sum of a circular region around a particular pixel?
41 views (last 30 days)
I have two regions of light, in circles for which i want to calculate the intensity of region 1 (center circle) and region 2 (outher ring, for which i want to substract this center circle to only get the intensity only in the outher ring.).
How can i do this?
sum(sum(Img)) gives the total pixel intensity of the whole picture, but i want to know the different regions contributions.
According to my analysis my center circle have a high amplitude (dynamic range), while my outher ring region is very low in amplitude but is spread out within a larger area. I want to double check that big part of my measured intensity is distributed within this larger low amplitude region (noise region) compared to my high peak but small center circle.
Many thanks for any help.
Jan on 4 Feb 2021
If you do have the position of the center and the radius already:
% Assuming that img is a 2D matrix/a grey scale image:
img = rand(640, 480);
x = 170; % Position of center
y = 400;
r = 31; % Radius
h = size(img, 1);
w = size(img, 2);
mask = ((1-x:h-x).' .^2 + (1-y:w-y) .^2) <= r^2;
Result = sum(img(mask), 'all')