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 x
col 3 is the x centroid location
col 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

Best Answer

  • See the FAQ: http://matlab.wikia.com/wiki/FAQ#How_do_I_create_a_circle.3F to create a circle mask at each centroid.
    You can locate the centroids by using thresholding and regionprops()
    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
    See my Image Segmentation Tutorial for a full demo.
    Place a circle at each centroid using the FAQ to create a binary image, then use the code above.
    To get the overall background intensity you can use the thresholded image
    binaryImage = grayImage > someThreshold.
    meanBackgroundIntensity = mean(grayImage(~binaryImage));
    If you want a background intensity closer to each spot, then it's more complicated - you'll have to make a binary image mask that is a ring shape around each spot.