How to sum data points within contour lines/isolines?

7 views (last 30 days)
Hello,
I have a numeric matrix, z, in which each data point represents a single pixel of an image. If I plot a filled contour, I get the image below that defines my regions of interests (cancer cells) very nicely. Is there a method by which I can sum all the raw data points of my matrix within the outer contour line, including those within the lightest-coloured areas? I am hoping to obtain the total signal intensities of each cancer cell, and then the integrated intensity values. Many thanks in advance.
Screenshot 2019-03-20 at 1.47.10 PM.png

Answers (1)

Star Strider
Star Strider on 20 Mar 2019
Edited: Star Strider on 20 Mar 2019
You can certainly get the (x,y) coordinates of the contours, although it takes a bit of code the get the result you likely want. See specifically the documentation section on Custom Line Width (link) and the detailed explanation of the contour matrix in the documentation section for M (link). You will also find the Contour Properties (link) documentation section on 'LevelList' (link) helpful.
EDIT —
Also consider the inpolygon (link) function.

Categories

Find more on Contour Plots in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!