Comparing ROI to area immediately surrounding it

Would greatly appreciate help with the following questions:

I am trying to characterize the mean gray value of a ROI and the region immediately surrounding it to demonstrate that the difference between the ROI and the region around it is statistically significant. Previously, I manually sampled areas within and around the ROI however this is tedious and I need to be able to automate the process to apply it to a batch of images.

I have tried the following thus far:
I set a brightness threshold to identify the ROIs and then analyze>>particles.
This gives me the mean gray value inside the ROI but I cannot find a way to get the mean gray value around the outside of the border of the ROI.

As I mentioned, I need to be able to automate this process to work for over 200 images so I cannot manually sample the surrounding area. I have included an image below showing how I get mean gray values inside the ROI…its the area outside the border that I need mean gray values for.

Also, sometimes when I use the threshold function followed by analyze particles, I get an error message that says “No particles detected. Threshold 255-255 may not be correct.”

Thanks for your help!

To measure the non ROI regions use the “Make Inverse” function, see:

https://imagej.nih.gov/ij/docs/guide/146-27.html#sub:Make-Inverse

If you have several regions it makes sense to add the ROI’s to the ROI manager.

Then select all measured regions (e.g. with Shift key+mouse click) in the ROI manager.

Then use More->OR (Combine) in the ROI Manager to create a composite ROI from all ROI’s.

Use Edit->Selection->Make inverse to select the non ROI area and make you measurements.

Example:

run("Blobs (25K)");
setAutoThreshold("Default");
run("Analyze Particles...", "  show=Nothing clear include add");
roiManager("Select", newArray(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63));
roiManager("Combine");
run("Make Inverse");
run("Measure");
run("Summarize");

Bio7, Thank you very much for your helpful reply!

I tried the approach you suggested but I am running into the following problem: For any given image, there are several different ROI and I need the area immediately surrounding each individual ROI rather than a collection of the inverse of all the ROI. Is there a way to take the current ROI and then ask to sample a given radius around the ROI and compute the mean gray value just for that perimeter or something similar?

As you can see in the attached image there are multiple ROI and I need to be able to compare each to its immediate surroundings not the collective surroundings.

In other words, I want to use some sort of of thresholding to initially identify ROI but then be able confirm that the ROI were correctly selected by demonstrating a difference in mean gray value between the ROI and surroundings…for example in the picture above both the upper and lower region are identified by thresholding but only the top region differs significantly from its surroundings. The third region off to the side is essentially junk and I don’t want it to contribute to calculations of the surroundings.

Thanks again for your help!

  1. You can enlarge each selected ROI in the ROI manager and add the region again to the ROI manager
    Edit->Selection->Enlarge. For a more geometrical interpretation you can create a circle (or bounding box,etc.) from the resized selection: Edit->Selection->Fit Circle

  2. If you have many similar images you can create an ImageJ macro which automatically iterates over all ROI’s and draw whatever selection (e.g., cross sections, etc.) over the extracted coordinates of each ROI.

One additional tip: You can clean up your default measurements by only counting particles of a certain size. See the particle analyzer dialog:

https://imagej.nih.gov/ij/docs/guide/146-30.html

Here a short macro which enlarges and converts two ROI’s. I would recommend to fit the circle first and then to enlarge the circle if needed:

run("Blobs (25K)");
setAutoThreshold("Default");
run("Analyze Particles...", "clear include add");
roiManager("Select", 30);
run("To Bounding Box");
run("Enlarge...", "enlarge=50");
makeRectangle(63, 59, 127, 141);
roiManager("Add");
roiManager("Select", 32);
run("Enlarge...", "enlarge=50");
run("Fit Circle");
makeOval(99, 66, 132, 132);
roiManager("Add");

Here you find an example how to iterate over all ROI’s in the ROI Manager:

Use the Edit > Selection > Make Band… command to select the immediate surrounding of the current ROI.

1 Like