Synthesizing ROIs

Hi all,

I was wondering if Image J had a function which I could input parameters and the output would be an area in which within the area are the parameters I set. Basically if Image J could make an ROI for me under the conditions I set rather than choosing an ROI and make measurements from there.
For example, I’m working with thermal images, so I would like to find the area of the image in which the temperatures are greater than or equal to one standard deviation greater than the mean.

1 Like

Hey @cambriec,

would you mind sharing an example image?

Furthermore, do you mean the “mean” of the whole image or some local mean?


Hi @cambriec, (and @haesleinhuepf, you type fast! :smile: )

What you’re probably looking for is a combination of the three things, all of which can be achieved by a simple macro:

  • Some statistics derived from the image
  • Setting a threshold
  • Creating a ROI from the treshold

So, in your case, it would go like this:

run("Blobs (25K)"); // just to have some image to work with

// gather statistics
getStatistics(area, mean, min, max, std); // you have maintain the order of parameter, so you can't ommit the first ones to get the SD

// create a threshold
setThreshold(mean+std, 1e30); //1e30 works for all bitdepths as a "really high" number

// make the ROI from the thresholded area
run("Create Selection");

Does this help?


1 Like

A local mean!
Here is an example image. So I want to know the mean and std of the seal and then find an area (within the seal) in which the temperature is greater than or equal to the mean skin temp of the seal.

I will try this and let you know, thanks!

Oh, I see. That problem has several layers.
Let’s sort out some things first:

  1. Does the FLIR camera provide a grayscale image? Or just a color image? If not, that would complicate things. It can be dealt with somewhat, but it’s not ideal.

  2. When going the “local” path, you have to decide how you are going to define locality. My guess is that your local is actually a “global within the whole seal”, but it could be local within a radius from each point (see next point) . Which one did you have in mind?

  3. Those types of images display gradients that arise from the fact that the normal of the surface of the subject points at different angles with respect with the direction of the camera. That’s usually something difficult to deal with. It can be somewhat overcome if you are looking for tiny spots, by using the local within a radius, but only to a certain extent.


1 Like

When I convert the image from raw binary to thermal data it creates a .raw file that Image J can analyze and that is in grayscale (which I can change into a different palette using LUT, but it is grayscale otherwise). I think with what you described I would want the “global within the whole seal.”

1 Like

Excellent, then!
In this case, you could just delimit the seal with a roi (e.g. drawn by hand), and then proceed to calculate the new roi using only the statistics from the seal region:

SD_factor = 1;
waitForUser("Trace the region to include");

// threshold bases on current ROI statistics
getStatistics(area, mean, min, max, std); 
setThreshold(mean + SD_factor*std, 1e30); 
run("Create Selection");

roiManager("select", newArray(nr-2, nr-1)); // select both to intersect
roiManager("select", nr-1); //select first trheshold ROI
roiManager("Show All without labels");

(I took the image you provided and [kind-of] recreated the original temperature image, you should definitely use the raw image.)


Yes this worked! Thank you!