Quantify and qualify new bone formation within a ROI

CCC3.VK15_5.0x(1).tif (10.8 MB)


This image is a coronal view of a mouse skull. In the middle, the bone has been removed surgically. This created a defect. Now, we want to know how much bone has been repaired within the defect area. We also want to qualify this new bone by assessing the trabecular surface (porosity of new bone = surface of hole within this new bone).

I plan to :

  1. Quantify the amount of new bone (in black surface) within the bone defect (not in the side where the native skull is).
    Could you please provide me a protocol that includes :
  • the creation of a ROI
  • the calculation of the amount of black surface / ROI total surface.
  • repeat this procedure on several images (batch)
  1. Qualify the new bone by assessing the surface of trabeculation (porosity = surface of hole) within the new bone formation in the ROI
    Could you please provide me a protocol that includes :
  • the creation a ROI
  • the calculation of the surface of white/grey holes within the bone in the ROI / total surface of bone in the ROI
  • repeat this procedure on several images (batch)

Thanks very much

MB) DDD2.VK8_5.0x(1).tif (10.8 MB)


You might want to take a look at BoneJ - it’s a tool specifically made for bone analysis. For all the basics in ImageJ - making ROIs, calculating measurements, etc. … here are some helpful links to get you started:


Thank you so much for your help.

I followed your instruction and here is the work that I have produced from the segmentation/scripting workshop video.

From my original pictures, I have been able to :

  • create and save a first squared ROI with a specific dimension (tried to have 4000microx2000micro)
  • create a second ROI from the first one with color threshold
  • obtain BV/TV with BoneJ > fraction > area volume fraction

My script is as below.

Now, I would like to use a script that allows me to batch my image from a folder. Could you help me on that, please ?

GG1.VK23_5.0x(3).tif (10.8 MB)
Mask after fill holes.tif (3.6 MB)
image after the 1ROI and 2ROI .tif (11.3 MB)

run("Bio-Formats Importer", "open=[/Volumes/Sophie/Scan lames Immuno histologie/TIFF VK/GG1.VK23_5.0x(3).tif] autoscale color_mode=Default rois_import=[ROI manager] view=Hyperstack stack_order=XYCZT");
run("RGB Color");
run("ROI Manager...");
roiManager("Open", "/Volumes/Sophie/Scan lames Immuno histologie/OUTPOUT/ROI 4000x2000 500.500 (2).roi");
roiManager("Select", 0);
setBackgroundColor(0, 0, 0);
run("Clear Outside");
run("Color Threshold...");
// Color Thresholder 2.0.0-rc-69/1.52p
// Autogenerated macro, single images only!
run("HSB Stack");
run("Convert Stack to Images");
for (i=0;i<3;i++){
  setThreshold(min[i], max[i]);
  run("Convert to Mask");
  if (filter[i]=="stop")  run("Invert");
imageCalculator("AND create", "0","1");
imageCalculator("AND create", "Result of 0","2");
for (i=0;i<3;i++){
selectWindow("Result of 0");
selectWindow("Result of Result of 0");
// Colour Thresholding-------------
run("Create Mask");
run("Fill Holes");
saveAs("Tiff", "/Volumes/Sophie/Scan lames Immuno histologie/OUTPOUT/GG1(3)Mask.tif");
run("Area/Volume fraction", "inputimage=net.imagej.ImgPlus@7de0572e");

Macroessay1.ijm (1.5 KB)

1 Like


Awesome job! Ok… time to batch then… the best way is via a script. If I were you - I would use the available templates for processing files in folders/subfolders. Open the script editor, select Templates :arrow_forward: ImageJ 1.x :arrow_forward: Batch :arrow_forward: Process Folder (IJ1 Macro) . Here is the code:

 * Macro template to process multiple images in a folder

#@ File (label = "Input directory", style = "directory") input
#@ File (label = "Output directory", style = "directory") output
#@ String (label = "File suffix", value = ".tif") suffix

// See also Process_Folder.py for a version of this code
// in the Python scripting language.


// function to scan folders/subfolders/files to find files with correct suffix
function processFolder(input) {
	list = getFileList(input);
	list = Array.sort(list);
	for (i = 0; i < list.length; i++) {
		if(File.isDirectory(input + File.separator + list[i])) {
			processFolder(input + File.separator + list[i]);
		if(endsWith(list[i], suffix)) {
                  // here you can add another if statement to check the file 
                  // name... and only process if it matches
			processFile(input, output, list[i]);

function processFile(input, output, file) {
	// Do the processing here by adding your own code.
	// Leave the print statements until things work, then remove them.
	print("Processing: " + input + File.separator + file);
	print("Saving to: " + output);

And again - some helpful links to guide you through this:

**The workshop goes through this script example directly - so might be the best place to start. :slight_smile: