Area selection to a best fit line then get line plot profiles tangent to the best fit line (or curve rather))


I have been working on analyzing brain tissue by tagging certain proteins and drawing area ROIs with the polygon selection tool to extract mean intensity values. Now I would like to turn the area ROIs (they are the shape of the letter “C”) into best fit curves and get a tangent plot profile along the best fit curve. I have attached an image so it is more easily understood.

I have found some ways I could approach the best fit curve and plot profile creation but I have not been able to find anything on turning an area selection to line selection.

I am trying to take the pixel intensity measurements of the “C” shaped object as it has 3 layers along that “C” shape as shown in figure 1.

If there is a better way to do this please let me know.

Thank You!

I was thinking about turning the area selection into coordinates along the edge of the area, then just doing a best fit line or curve with those points. I would most likely have to rotate the image 90degrees so the two endpoints of the area are do not stand on the same x-coordinates. I could not find how to do that either though.

Hi @davidjh,

What software are you using? ImageJ/fiji? Python? something else?

If I were in your shoes, I’d do the following

  1. Compute the skeleton of your ROI
  2. Compute the distance transform
  3. Use the distance transform at the skeleton to get the perpendicular direction (the red lines you drew)

(1) is kind-of like a “best-fit” line, but you won’t have to do the rotation trick you had in mind. Step 3 doesn’t exist in imagej and would need some coding probably. I can try to help when I have time - or maybe someone else will pick up this idea?


1 Like

Thank you for your quick response. I am using ImageJ. How do you compute the skeleton? I am not familiar with these steps!

I appreciate your help.

you can get the skeleton by Process>Binary>Make Binary then Process>Binary>Skeleton. There are other ways to skeletonize, but I think that is the most genertic. That said, @bogovicj by distance transform. Do you mean the process>binary>Distance map? or did you use one of the transformation plugins and if so which one? I have a similar task at hand. I am trying to measure the thickness of membranes inside an ROI. In this case the membranes inside the larger circular like structure in the center of Image. I think I can segment them out reasonably well and could use the plot profile to get the thickness, but I need tangents to all my membranes of interest and they are not straight. This seems like a similar problem. Example