Kevin Mader
26 March 2015
ETHZ: 227-0966-00L
Segmentation and all the steps leading up to it are really a specialized type of learning problem.
Returning to the ring image we had before, we start with our knowledge or ground-truth of the ring
Which we want to identify the from the following image by using image processing tools
What does identify mean?
We can then apply a threshold to the image to determine the number of points in each category
Try a number of different threshold values on the image and compare them to the original classification
Thresh | TP | TN | FP | FN |
---|---|---|---|---|
0.0 | 224 | 0 | 217 | 0 |
0.2 | 224 | 26 | 191 | 0 |
0.4 | 217 | 112 | 105 | 7 |
0.6 | 143 | 178 | 39 | 81 |
0.8 | 58 | 209 | 8 | 166 |
1.0 | 0 | 217 | 0 | 224 |
Thresh | TP | TN | FP | FN | Recall | Precision |
---|---|---|---|---|---|---|
0.30 | 223 | 63 | 154 | 1 | 100 | 59 |
0.38 | 218 | 97 | 120 | 6 | 97 | 64 |
0.46 | 207 | 137 | 80 | 17 | 92 | 72 |
0.54 | 170 | 160 | 57 | 54 | 76 | 75 |
0.62 | 130 | 182 | 35 | 94 | 58 | 79 |
0.70 | 98 | 194 | 23 | 126 | 44 | 81 |
Reciever Operating Characteristic (first developed for WW2 soldiers detecting objects in battlefields using radar). The ideal is the top-right (identify everything and miss nothing)
We can then use this ROC curve to compare different filters (or even entire workflows), if the area is higher the approach is better.
Different approaches can be compared by area under the curve
Another way of showing the ROC curve (more common for machine learning rather than medical diagnosis) is using the True positive rate and False positive rate
These show very similar information with the major difference being the goal is to be in the upper left-hand corner. Additionally random guesses can be shown as the slope 1 line. Therefore for a system to be useful it must lie above the random line.
While finding a ring might be didactic, it is not really a relevant problem and these terms are much more meaningful when applied to medical images where every False Positives and False Negative can be mean life-threatening surgery or the lack thereof. (Data courtesy of Zhentian Wang)
From these images, an expert labeled the calcifications by hand, so we have ground truth data on where they are:
We can perform the same analysis on an image like this one, again using a simple threshold to evalulate how accurately we identify the calcifications
Thresh | TP | TN | FP | FN | Recall | Precision |
---|---|---|---|---|---|---|
7 | 2056 | 13461 | 74483 | 0 | 100 | 3 |
23 | 2030 | 25806 | 62138 | 26 | 99 | 3 |
34 | 1950 | 38744 | 49200 | 106 | 95 | 4 |
42 | 1726 | 51676 | 36268 | 330 | 84 | 5 |
48 | 1435 | 64161 | 23783 | 621 | 70 | 6 |
54 | 1043 | 76363 | 11581 | 1013 | 51 | 8 |
Since our image has two channels we can examine both of them (Recall is not on a linear scale so the differences can more easily be seen). It is clear that scattering provides more useful information than absorption except for very high recall and meaninglessly low precision.
We can get even better results by using a combination of both absorption and scattering to find the calcifications
This can then be represented as a pseudo-ROC curve by showing all of the points and finding the maximum value.
We have dramatically simplified our data, but there is still too much.
56GB / sample
\[ \downarrow \]
(1.75GB / sample)
Once we have a clearly segmented image, it is often helpful to identify the sub-components of this image. The easist method for identifying these subcomponents is called component labeling which again uses the neighborhood \( \mathcal{N} \) as a criterion for connectivity, resulting in pixels which are touching being part of the same object.
In general, the approach works well since usually when different regions are touching, they are related. It runs into issues when you have multiple regions which agglomerate together, for example a continuous pore network (1 object) or a cluster of touching cells
The more general formulation of the problem is for networks (roads, computers, social). Are the points start and finish connected?
We start out with the network and we grow Begin to its connections. In a brushfire-style algorithm
Same as for networks but the neighborhood is defined with a kernel (circular, full, line, etc) and labels must be generate for the image
Assign a unique label to each point in the image \[ L(x,y) = y*\text{Im}_{width}+x \]
For each point \( (x,y) \)
Repeat until no more \( L \) values are changed
The image very quickly converges and after 4 iterations the task is complete. For larger more complicated images with thousands of components this task can take longer, but there exist much more efficient algorithms for labeling components which alleviate this issue.
Now all the voxels which are connected have the same label. We can then perform simple metrics like
Next week we will cover how more detailed analysis can be performed on these data.
\[ I_{id}(x,y) = \begin{cases} 1, & L(x,y) = id \\ 0, & \text{otherwise} \end{cases} \]
\[ \bar{x} = \frac{1}{N} \sum_{\vec{v}\in I_{id}} \vec{v}\cdot\vec{i} \] \[ \bar{y} = \frac{1}{N} \sum_{\vec{v}\in I_{id}} \vec{v}\cdot\vec{j} \] \[ \bar{z} = \frac{1}{N} \sum_{\vec{v}\in I_{id}} \vec{v}\cdot\vec{k} \]
If the gray values are kept (or other meaningful ones are used), this can be seen as a weighted center of volume or center of mass (using \( I_{gy} \) to distinguish it from the labels)
\[ \Sigma I_{gy} = \frac{1}{N} \sum_{\vec{v}\in I_{id}} I_{gy}(\vec{v}) \] \[ \bar{x} = \frac{1}{\Sigma I_{gy}} \sum_{\vec{v}\in I_{id}} (\vec{v}\cdot\vec{i}) I_{gy}(\vec{v}) \] \[ \bar{y} = \frac{1}{\Sigma I_{gy}} \sum_{\vec{v}\in I_{id}} (\vec{v}\cdot\vec{j}) I_{gy}(\vec{v}) \] \[ \bar{z} = \frac{1}{\Sigma I_{gy}} \sum_{\vec{v}\in I_{id}} (\vec{v}\cdot\vec{k}) I_{gy}(\vec{v}) \]
Exents or caliper lenghts are the size of the object in a given direction. Since the coordinates of our image our \( x \) and \( y \) the extents are calculated in these directions
Define extents as the minimum and maximum values along the projection of the shape in each direction \[ \text{Ext}_x = \left\{ \forall \vec{v}\in I_{id}: max(\vec{v}\cdot\vec{i})-min(\vec{v}\cdot\vec{i}) \right\} \] \[ \text{Ext}_y = \left\{ \forall \vec{v}\in I_{id}: max(\vec{v}\cdot\vec{j})-min(\vec{v}\cdot\vec{j}) \right\} \] \[ \text{Ext}_z = \left\{ \forall \vec{}\in I_{id}: max(\vec{v}\cdot\vec{k})-min(\vec{v}\cdot\vec{k}) \right\} \]
By definition (New Oxford American): varying in magnitude according to the direction of measurement.
Due to its very vague definition, it can be mathematically characterized in many different very much unequal ways (in all cases 0 represents a sphere)
\[ Aiso1 = \frac{\text{Longest Side}}{\text{Shortest Side}} - 1 \]
\[ Aiso2 = \frac{\text{Longest Side}-\text{Shortest Side}}{\text{Longest Side}} \]
\[ Aiso3 = \frac{\text{Longest Side}}{\text{Average Side Length}} - 1 \]
\[ Aiso4 = \frac{\text{Longest Side}-\text{Shortest Side}}{\text{Average Side Length}} \]
\[ \cdots \rightarrow \text{ ad nauseum} \]
Let's take some sample objects
Y Extent | Aiso1 | Aiso2 | Aiso3 | Aiso4 |
---|---|---|---|---|
0.00 | 4999.00 | 1.00 | 1.00 | 2.00 |
0.01 | 499.00 | 1.00 | 1.00 | 1.99 |
0.10 | 49.00 | 0.98 | 0.96 | 1.92 |
1.00 | 4.00 | 0.80 | 0.67 | 1.33 |
2.00 | 1.50 | 0.60 | 0.43 | 0.86 |
3.00 | 0.67 | 0.40 | 0.25 | 0.50 |
4.00 | 0.25 | 0.20 | 0.11 | 0.22 |
5.00 | 0.00 | 0.00 | 0.00 | 0.00 |
Objects with uniformally distributed, independent \( x \) and \( y \) extents
While easy to calculate, the bounding box / extents approach is a very rough approximation for most of the objects in our image. In particular objects which are not parallel to the \( XY \)-axes are misrepresented.
While many of the topics covered in Linear Algebra and Statistics courses might not seem very applicable to real problems at first glance, at least a few of them come in handy for dealing distributions of pixels (they will only be briefly covered, for more detailed review look at some of the suggested material)
Similar to K-Means insofar as we start with a series of points in a vector space and want to condense the information. With PCA instead of searching for distinct groups, we try to find a linear combination of components which best explain the variance in the system.
As an example we will use a very simple example of corn and chicken prices vs time
The first principal component condenses the correlated information in both the chicken and corn prices (perhaps the underlying cost of fuel) since it explains the most variance in the final table of corn and chicken prices.
The second principal component is then related to the unique information seperating chicken from corn prices but neither indices directly themselves (maybe the cost of antibiotics)
Going back to a single cell, we have the a distribution of \( x \) and \( y \) values.
A principal component analysis of the voxel positions, will calculate two new principal components (the components themselves are the relationships between the input variables and the scores are the final values.)
We start off by calculating the covariance matrix from the list of \( x \), \( y \), and \( z \) points that make up our object of interest.
\[ COV(I_{id}) = \frac{1}{N} \sum_{\forall\vec{v}\in I_{id}} \begin{bmatrix} \vec{v}_x\vec{v}_x & \vec{v}_x\vec{v}_y & \vec{v}_x\vec{v}_z\\ \vec{v}_y\vec{v}_x & \vec{v}_y\vec{v}_y & \vec{v}_y\vec{v}_z\\ \vec{v}_z\vec{v}_x & \vec{v}_z\vec{v}_y & \vec{v}_z\vec{v}_z \end{bmatrix} \]
We then take the eigentransform of this array to obtain the eigenvectors (principal components, \( \vec{\Lambda}_{1\cdots 3} \)) and eigenvalues (scores, \( \lambda_{1\cdots 3} \))
\[ COV(I_{id}) \longrightarrow \underbrace{\begin{bmatrix} \vec{\Lambda}_{1x} & \vec{\Lambda}_{1y} & \vec{\Lambda}_{1z} \\ \vec{\Lambda}_{2x} & \vec{\Lambda}_{2y} & \vec{\Lambda}_{2z} \\ \vec{\Lambda}_{3x} & \vec{\Lambda}_{3y} & \vec{\Lambda}_{3z} \end{bmatrix}}_{\textrm{Eigenvectors}} * \underbrace{\begin{bmatrix} \lambda_1 & 0 & 0 \\ 0 & \lambda_2 & 0 \\ 0 & 0 & \lambda_3 \end{bmatrix}}_{\textrm{Eigenvalues}} * \underbrace{\begin{bmatrix} \vec{\Lambda}_{1x} & \vec{\Lambda}_{1y} & \vec{\Lambda}_{1z} \\ \vec{\Lambda}_{2x} & \vec{\Lambda}_{2y} & \vec{\Lambda}_{2z} \\ \vec{\Lambda}_{3x} & \vec{\Lambda}_{3y} & \vec{\Lambda}_{3z} \end{bmatrix}^{T}}_{\textrm{Eigenvectors}} \] The principal components tell us about the orientation of the object and the scores tell us about the corresponding magnitude (or length) in that direction.
princomp
or pca
in various languages and scale well to very large datasets.While the eigenvalues and eigenvectors are in their own right useful
We see that there seems to be a general, albeit weak, correlation between the two measures. The most concerning portion is however the left side where the extents or bounding box method reports 0 anisotropy and the elliptical method reports substancial amounts of it.
The models we have done are all applicable to both 2D and 3D images. The primary difference is when looking at 3D images there is an extra dimension to consider.
It can also be shown as a series of 2D slices.
Anisotropy applies to these samples as well but it only gives us information about the shortest and the longest dimensions. Is that enough?
Each of these images has the exact same anisotropy because the shortest semiaxis length remains
If we take a slice through the image we can image the final shape looking like a very small thin rod in the case where the second dimension is equal to 3 (short in two directions and long in the other) and a pankcake (short in one direction and long in the other two).
We can thus introduce a new metric for assessing the second-degree anisotropy in the object and this we shall somewhat more formally call Oblateness.
\[ \textrm{Ob} = 2\frac{\lambda_{2}-\lambda_{1}}{\lambda_{3}-\lambda_{1}}-1 \]
The value like in anisotropy is bound between -1 and 1.
Many physical and chemical processes occur at surfaces and interfaces and consequently these structures are important in material science and biology. For this lecture surface and interface will be used interchangebly and refers to the boundary between two different materials (calcified bone and soft tissue, magma and water, liquid and gas) Through segmentation we have identified the unique phases in the sample under investigation.
We see that the dilation and erosion affects are strongly related to the surface area of an object: the more surface area the larger the affect of a single dilation or erosion step.
Constructing a mesh for an image provides very different information than the image data itself. Most crucially this comes when looking at physical processes like deformation.
While the images are helpful for visualizing we rarely have models for quantifying how difficult it is to turn a pixel off
If the image is turned into a mesh we now have a list of vertices and edges. For these vertices and edges we can define forces. For example when looking at stress-strain relationships in mechanics using Hooke's Model \[ \vec{F}=k (\vec{x}_0-\vec{x}) \] the force needed to stretch one of these edges is proportional to how far it is stretched.
Since we uses voxels to image and identify the volume we can use the voxels themselves as an approimation for the surface of the structure.
From this we can create a mesh by
A wide variety of methods of which we will only graze the surface (http://en.wikipedia.org/wiki/Image-based_meshing)
Voxels are very poor approximations for the surface and are very rough (they are either normal to the x, y, or z axis and nothing between). Because of their inherently orthogonal surface normals, any analysis which utilizes the surface normal to calculate another value (growth, curvature, etc) is going to be very inaccurate at best and very wrong at worst.
The image is processed one voxel at a time and the neighborhood (not quite the same is the morphological definition) is checked at every voxel. From this configuration of values, faces are added to the mesh to incorporate the most simple surface which would explain the values.
Marching tetrahedra is for some applications a better suited approach
So while bounding box and ellipse-based models are useful for many object and cells, they do a very poor job with the sample below.