# MATLAB: Extracting sum of intensity values at various locations with various diameters

circlesextractionimageImage Processing Toolboximage segmentationintensity

Hello. I have an image (grayscale) of spots, that have a spread of intensities and sizes.
I have the centroid location of each spot and an "size" of each spot obtained by my own encircled energy calculation for both x&y directions.
data =            8.35          8.14         43.00       2266.00           10.76          8.24         43.00       2362.00            8.96         11.07         43.00       2459.00            8.55          7.98         43.00       2555.00
where
col 1 is the size of my object in y   col 2 is the size in xcol 3 is the x centroid locationcol 4 is the y centroid location
What I am trying to achieve is at each x,y centroid location, draw a circle with a diameter given by the average of the size in x & size in y, and then caluclate the integrated intensity in the circle. The circles (representing the size) may be different for each spot.
As a second request, I would also like to then consider a distance d, say 15 pixels from the x,y centroid location and obtain the background values from a square or circle that I can call background to then subtract from the integrated signal requested above to get the background subtracted integrated signal.
Thanks for any help Jason

binaryImage = grayImage > someThreshold;props = regionprops(binaryImage, grayImage, 'Centroid', 'BoundingBox', 'MeanIntensity', 'Area');centroids = [props.Centroid];xCentroids = centroids(1:2:end);yCentroids = centroids(2:2:end);allAreas = [props.Area];allMeanIntensities = [props.MeanIntensity];integratedGrayValue = allAreas .* allMeanIntensities
binaryImage = grayImage > someThreshold.meanBackgroundIntensity = mean(grayImage(~binaryImage));