# Fractal Features of Muscle to Quantify Fatty Infiltration in Aging and Pathology
## 2 Materials and Methods
### Image Processing and Analysis
#### 2.2.2 Computation of Index \(\rho\) (Lean/Fat Ratio)  
The algorithm to compute \(\rho\) is based on a simple count of pixels \(n_{L}\) (contractile muscle) and the pixels \(n_{F}\) (non-contractile muscle) belonging to the lean mass area (LeanCSA). The ratio between these two numbers gives the value of the index \(\rho\), which is as follows:  
\[\rho=\frac{n_{L}}{n_{F}} \tag{1}\]  
At a first glance, the decision of whether a given pixel belongs to the lean mass or to the fatty mass seems to be quite simple; in fact, fatty mass is characterized by a lighter gray level than the lean mass. However, the non-uniform illumination in the image can make it difficult to obtain a unique threshold to separate the lean mass from the fatty mass. Therefore, a simple adaptive thresholding procedure is used. The bounding box of the ROI is uniformly partitioned in \(M\) by \(N\) rectangles and a different threshold is computed for the rectangles with a not empty intersection with the ROI. Let \(R\) be the intersection of the ROI and one of such rectangles, and \(H\) the histogram of gray levels in \(R\); so, \(H(i)\) gives the number of pixels in \(R\) with a gray level \(i\), where \(i\) = 0, 1, \(\ldots\), 255. The following Algorithm 1 is used to compute the threshold \(\tau\) in \(R\). ```
\(\bullet\) let \(\tau_{1}\) be the index of the relative maximum of \(H\) that is closest to \(i\) = 0; \(\bullet\) let \(\tau_{2}\) be the index of the relative maximum of \(H\) that is closest to \(i\) = 255; \(\bullet\) let \(\tau\) = (\(\tau_{1}+\tau_{2}\))/2; \(\bullet\) do \(\circ\)\(\tau_{old}=\tau_{i}\); \(\circ\)\(\circ\) let \(\tau_{1}\) be the weighted average of gray levels less than \(\tau\) with weights \(H(i),i\) = 0, 1, \(\ldots\), \(\tau\) - 1; \(\circ\)\(\circ\) let \(\tau_{2}\) be the weighted average of gray levels greater than \(\tau\) with weights \(H(i),i\) = \(\tau\) + 1, \(\tau\) + 2, \(\ldots\), \(\circ\)\(\circ\) let \(\tau\) = (\(\tau_{1}+\tau_{2}\))/2; until \(\mid\)\(\tau\) - \(\tau_{old}\)\(\mid\) < \(T\). ```  
**Algorithm 1**(local threshold). Given the sub-image \(R\), the histogram \(H\) of gray levels in \(R\), and a tolerance \(T\), compute the threshold \(\tau\) by the following steps  
In this way, every rectangle with a not empty intersection with the ROI has a different threshold. Let \(R_{j}\) = 0, 1, \(\ldots\), \(J\) be the intersection of such rectangles and the ROI, and let \(\tau_{j}\)  
Figure 2: Schematic representation of lacunarity method. (**left**) Paraspinal muscle MRI-spin-echo to visualize muscle CSA al level of the 4 th lumbar vertebra with ROIs selection to delimit TotCSA (solid line) and separate LeanCSA and FatCSA (dotted line); (**right**) GBA curvilinear plot (dotted line) as fitted by our hyperbola model function \(L(b)\) (solid line) to compute the triplet of parameters \(\alpha^{*}\), \(\beta^{*}\), \(\gamma^{*}\); parameter \(\alpha\) correlates with fractal dimension and parameter \(\beta\) describes the concavity of the curve and gives a quantitative estimate of lacunarity. MRI: magnetic resonance imaging, CSA: cross-sectional area, GBA: gliding box algorithm. \(j=0,1,\ldots,J\) be the corresponding thresholds. The following Algorithm 2 computes the segmentation of the ROI in terms of \(n_{F}\), i.e., the number of pixels in the fat mass, and \(n_{L}\), i.e., the number of pixels in the lean mass. ```

**Algorithm 2** (image segmentation). Let \(d\) be the diagonal of the rectangles in the partition of the ROI, and \(c_{j}\) be the center of the \(j\)-th rectangle. Given the sub-images \(R_{j},j=0,1,\ldots,J\), and the corresponding thresholds \(\tau_{j}\), \(j=0,1,\ldots,J\); compute \(n_{F}\) and \(n_{L}\) as the total number of pixels in the fat mass and in the lean mass, respectively, by the following steps