In this tutorial, we compute the structure tensor of a 3D image.
For a general introduction to 3D image processing, please refer to
Explore 3D images (of cells).
The data we use here are sampled from an image of kidney tissue obtained by
confocal fluorescence microscopy (more details at [1] under
kidney-tissue-fluorescence.tif).
import
matplotlib.pyplot
as
plt
import
numpy
as
np
import
plotly.express
as
px
import
plotly.io
import
skimage
as
ski
Load image
This biomedical image is available through scikit-image’s data registry.
number of dimensions: 4
shape: (16, 512, 512, 3)
dtype: uint16
For the purposes of this tutorial, we shall consider only the second color
channel, which leaves us with a 3D single-channel image. What is the range
of values?
Let us visualize the bottom slice of our sample data and determine the
typical size for strong variations. We shall use this size as the
‘width’ of the window function.
About the brightest region (i.e., at row ~ 22 and column ~ 17), we can see
variations (and, hence, strong gradients) over 2 or 3 (resp. 1 or 2) pixels
across columns (resp. rows). We may thus choose, say, sigma=1.5 for
the window
function. Alternatively, we can pass sigma on a per-axis basis, e.g.,
sigma=(1,2,3). Note that size 1 sounds reasonable along the first
(Z, plane) axis, since the latter is of size 8 (13 - 5). Viewing slices in
the X-Z or Y-Z planes confirms it is reasonable.
Let us visualize the slices of sample data in the X-Z (left) and Y-Z (right)
planes where the maximum eigenvalue is found. The Z axis is the vertical
axis in the subplots below. We can see the expected relative invariance
along the Z axis (corresponding to longitudinal structures in the kidney
tissue), especially in the Y-Z plane (longitudinal=1).
As a conclusion, the region about voxel
(plane,row,column)=coords[1:] is
anisotropic in 3D: There is an order of magnitude between the third-largest
eigenvalues on one hand, and the largest and second-largest eigenvalues on
the other hand. We could see this at first glance in figure EigenvaluesforplaneZ=1.
The neighborhood in question is ‘somewhat isotropic’ in a plane (which,
here, would be relatively close to the X-Y plane): There is a factor of
less than 2 between the second-largest and largest eigenvalues.
This description is compatible with what we are seeing in the image, i.e., a
stronger gradient across a direction (which, here, would be relatively close
to the row axis) and a weaker gradient perpendicular to it.
In an ellipsoidal representation of the 3D structure tensor [2],
we would get the pancake situation.
Total running time of the script: (0 minutes 1.208 seconds)