Guide for segmentation of volumes after X-Ray Computed Tomography reconstruction. This is one of multiple ways to make a segmentation for a volume at IMDEA Materials Institute (Getafe, Spain, 2019). ImageJ software is used.
DevEX - reference for building teams, processes, and platforms
How to make a manual binary segmentation for an XCT reconstructed volume with ImageJ
1. Madrid institute for advanced studies ofmaterials
Parque tecnológico Tecnogetafe· Calle Eric Kandel, 2 · 28906 Getafe, Madrid · Spain
Telephone: +34 91 549 34 22 · Fax: +34 91 550 30 47 · E-mail: contact.materials@imdea.org
HOW TO MAKE A MANUAL BINARY SEGMENTATION FOR AN XCT
RECONSTRUCTED VOLUME WITH IMAGEJ
Javier García Molleja
IMDEA Materials Institute – X-Ray Laboratory
First of all, open ImageJ software.
File -> Import -> Raw… (and use the browser in order to select your volume). Click Open.
A dialog window is shown. Please, identify the image bit type, the width (in pixels), the height (in
pixels) and the number of slices. Normally, these values are written at the end of the filename (or
they are automatically loaded). It is supposed that you will perform the segmentation from an
equalized, concatenated and aligned volume, so the file is saved as raw (then do not click Little-endian
byte order). Click OK.
The volume is loaded in the TOP-BOTTOM view. It is important that you make, from the same volume,
a proper mask. We will use it later.
2. Madrid institute for advanced studies ofmaterials
Parque tecnológico Tecnogetafe· Calle Eric Kandel, 2 · 28906 Getafe, Madrid · Spain
Telephone: +34 91 549 34 22 · Fax: +34 91 550 30 47 · E-mail: contact.materials@imdea.org
Make sure which regions will be segmented. For example, in the present case we need to identify the
internal pores from the rest (material, air…). Thus, pores will be detected in black colour (grey level 0)
and the rest will be presented in white colour (grey level 255).
Furthermore, volume must be in 8 bits, so Image -> Type -> 8-bit. Save this new volume, just in case.
Image -> Adjust ->Auto Local Threshold… will show a window with different options.
3. Madrid institute for advanced studies ofmaterials
Parque tecnológico Tecnogetafe· Calle Eric Kandel, 2 · 28906 Getafe, Madrid · Spain
Telephone: +34 91 549 34 22 · Fax: +34 91 550 30 47 · E-mail: contact.materials@imdea.org
This dialog window enables several local thresholds. Sauvola is the most used method in our
laboratory, followed by the Niblack method. Indeed, Sauvola method is an evolution from the Niblack
one and its formula is the following one:
> ∙ 1 + ∙ − 1
It is worth mentioning that pixel is the pixel to be segmented (one by one in all slices). MEAN is the
grey mean of the nearest pixels to the one to be segmented. In the dialog window, “Radius” is the
option to tell to the software the size of the neighbourhood. k is the “Parameter1” in the dialog
window. STDEV is the standard deviation of the mean calculated with the grey levels from the pixels
of the neighbourhood. Finally, r is the “Parameter2” in the dialog window. So, if the grey level of the
present pixel is higher than the calculated value it will be labelled as Foreground, i.e., white colour. On
the other hand, if the grey level of the present pixel is lower than the calculated value it will be
labelled as Background, i.e., black colour.
But, how to select the best parameters? It is important that you do several trials in order to optimize
all parameters. Image -> Duplicate… several times of one random slice. In the present case, slice
number 1292 is duplicated many times. Furthermore, if you want to compare the grey level slice with
another segmented slice the following command will help you:
Analyze -> Tools -> Synchronize Windows and select the ones you are interested in. Thus, all
operations will be replicated in all synchronized windows.
First, try to optimize the value of the Radius. If you have big pores, a low Radius produces a
segmentation where the centre of the pore is not in black colour. On the other hand, if a high Radius
is selected, pores will be more rounded than the expected.
GREY LEVEL
RADIUS = 60 RADIUS = 80 RADIUS = 100
4. Madrid institute for advanced studies ofmaterials
Parque tecnológico Tecnogetafe· Calle Eric Kandel, 2 · 28906 Getafe, Madrid · Spain
Telephone: +34 91 549 34 22 · Fax: +34 91 550 30 47 · E-mail: contact.materials@imdea.org
Second, try to optimize the Parameter1 (k in the Sauvola formula). If you use a low value, the Sauvola
method is more aggressive, i.e., pores are bigger than expected (pixels with higher grey values near
the pore border are not considered as foreground but they are considered as background) and noise
in the material can be labelled as background. On the other hand, using a high parameters make
Sauvola method less aggressive, so pores will be thinner than expected (pixels with lower grey values
near the pore border are considered as foreground).
GREY LEVEL
PARAMETER1 = 0.4
PARAMETER1 = 0.6
PARAMETER1 = 0.8
5. Madrid institute for advanced studies ofmaterials
Parque tecnológico Tecnogetafe· Calle Eric Kandel, 2 · 28906 Getafe, Madrid · Spain
Telephone: +34 91 549 34 22 · Fax: +34 91 550 30 47 · E-mail: contact.materials@imdea.org
Don’t ask me why, but in our laboratory we use Parameter2 (r in the Sauvola formula) with a fixed
value, namely, 128. This parameter does have not much effect when the value is low but if it is high, it
will remove noise in the material and pores will be rounded.
GREY LEVEL
PARAMETER2 = 0
PARAMETER2 = 128
PARAMETER2 = 256
6. Madrid institute for advanced studies ofmaterials
Parque tecnológico Tecnogetafe· Calle Eric Kandel, 2 · 28906 Getafe, Madrid · Spain
Telephone: +34 91 549 34 22 · Fax: +34 91 550 30 47 · E-mail: contact.materials@imdea.org
Finally, after a good parameter choice, go back to the complete volume and select Sauvola method
and use the best parameters achieved. In this case we used Radius = 80, Parameter1 = 0.6 and
Parameter2 = 128. Please, check White objects on black background and check Stack. Click OK.
You can save this new volume. In order to check the goodness of the parameter choice you can make
a projection of all defects in the grey level volume and in the segmented one and compare (note this
is possible when you have a low amount of defects!):
Image -> Stacks -> Z-Project… (Start slice: the most convenient one for your purposes, Stop slice: the
most convenient one for your purposes, Projection type: Min Intensity). Click OK.
Now, we can improve the output with the mask previously done (please, check the other manuals).
Local thresholds can have problems with the segmentation of air, i.e., air next to the sample surface
will be black (background) but air far from the sample tends to be white (foreground). How to solve
this? One quick solution is try to use a higher Radius but if your pores are compromised with this new
choice try to open now the mask.
7. Madrid institute for advanced studies ofmaterials
Parque tecnológico Tecnogetafe· Calle Eric Kandel, 2 · 28906 Getafe, Madrid · Spain
Telephone: +34 91 549 34 22 · Fax: +34 91 550 30 47 · E-mail: contact.materials@imdea.org
With the mask, we are sure that the air is always black, so we need to combine the segmented
volume with the mask.
Process -> Image Calculator… (Image1: Sauvola volume, Operation: Multiply, Image2: mask volume,
check Create new window and uncheck 32-bit (float) result). Click OK and then Yes.
You can save this new volume!
In the present case you won’t see much difference (pay attention to the sample surface) but in some
cases this step is very important. Now, if you use this volume to extract information of the pores (the
objects we are interested in) you must ignore the air in the quantification process.
8. Madrid institute for advanced studies ofmaterials
Parque tecnológico Tecnogetafe· Calle Eric Kandel, 2 · 28906 Getafe, Madrid · Spain
Telephone: +34 91 549 34 22 · Fax: +34 91 550 30 47 · E-mail: contact.materials@imdea.org
Yes, we can do a couple of extra steps in order to avoid the air and keep the pores.
Edit -> Invert and click Yes. Now pores and air are white (grey level 255) and the material is black (grey
level 0).
Go to the mask and try to reduce the size of the white region. Remember this region of grey level 255
includes material and inner pores without discrimination. Here the point is that the surface of the
segmented volume does not perfectly match with the surface of the mask volume because we
smoothed it with several dilate and erode binary operations. Then, in order to avoid the inclusion of
noise very near to the surface we need to reduce this white region:
Process -> Binary -> Dilate and click Yes. Please, check that this operation is performed in black pixels.
Do this operation few times (less than 5). If noise is still present try to make another mask with better
performance.
Process -> Image Calculator… (Image1: inverted Sauvola×Mask, Operation: Multiply, Image2: dilated
mask, check Create new window and uncheck 32-bit (float) result). Click OK and then Yes to apply this
operation to all slices.
9. Madrid institute for advanced studies ofmaterials
Parque tecnológico Tecnogetafe· Calle Eric Kandel, 2 · 28906 Getafe, Madrid · Spain
Telephone: +34 91 549 34 22 · Fax: +34 91 550 30 47 · E-mail: contact.materials@imdea.org
Edit -> Invert and click Yes in order to keep pores in black colour.
Of course, save this new volume with the name of the sample, the operation you did, the bit type and
the stack size. The extension, as usual, will be .raw:
06-MB3_17_381_P02_8b_OnlyPores_2120x950x1672.raw
(Thanks to Jonathan Espinoza for his critical review of the process and his valuable comments about
the process)