## 2 Materials and Methods--Porosity Classification and Fracture Identification
### Pixel-Wise k-IN Approach to Determine Rock Fractures and Pores
#### 2.4.4 Shape Variance of \(\mathcal{H}_{i}\) with Respect to the Circle  
In the current work, we have compared the shape of \(\mathcal{H}_{i}\) with that of a circle, where the circle has the same perimeter. Perimeter (\(\mathcal{H}_{i}\)) is the number of pixels lying on its boundary. We assume there are \(n\) pixels \(\{x_{i,1}\), \(x_{i,2}\), \(\cdots\), \(x_{i,n}\}\) lying on the boundary of \(\mathcal{H}_{i}\) and the perimeter is computed as \(\sum_{j=1}^{n-1}\left|x_{i,j}-x_{i,j+1}\right|\). We define the shape similarity of \(\mathcal{H}_{i}\) with that of a circle as \(\mathcal{V}_{c}(\mathcal{H}_{i})=\frac{\sigma_{r}(\mathcal{H}_{i})}{\mu_{r}( \mathcal{H}_{i})}\), where \(\sigma_{r}(\mathcal{H}_{i})\) is the mean of radial distances from the centroid (\(\mathrm{G}x_{\mathcal{H}_{i}}\), \(\mathrm{G}y_{\mathcal{H}_{i}}\)) of \(\mathcal{H}_{i}\) to its boundary points and \(\mu_{r}(\mathcal{H}_{i})\) is the standard deviation of radial distances from the centroid of \(\mathcal{H}_{i}\) to the boundary points [29; 30]. Now, \(\mu_{r}(\mathcal{H}_{i})\) and \(\sigma_{r}(\mathcal{H}_{i})\) can be calculated as \(\mu_{r}(\mathcal{H}_{i})=\frac{1}{n}\sum_{j=1}^{n-1}\mathbb{D}_{i,j}\), and \(\sigma_{r}(\mathcal{H}_{i})=\sqrt{\frac{1}{n}\sum_{j=1}^{n-1}\left(\mathbb{D }_{j}-\mu_{r}(\mathcal{H}_{i})\right)^{2}}\), respectively, where \(\mathbb{D}_{ij}=\sqrt{\left(x_{i,j}-\mathrm{G}x_{\mathcal{H}_{i}}\right)^{2} +\left(y_{i,j}-\mathrm{G}y_{\mathcal{H}_{i}}\right)^{2}}\). Now, \(\mathcal{V}_{c}(\mathcal{H}_{i})=0\) shows the shape of (\(\mathcal{H}_{i}\)) is a perfect circle, however, with bigger \(\mathcal{V}_{c}(\mathcal{H}_{i})\) values its shape diverges from that of a circle. Hence, for a pore, we restrict \(\mathcal{V}_{c}(\mathcal{H}_{i})\) between \([0,\gamma]\), i.e., \(0\leq\mathcal{V}_{c}(\mathcal{H}_{i})\leq\gamma\in\mathbb{R}^{+}\), whereas \(\mathcal{H}_{i}\) is classified as a fracture if \(\mathcal{V}_{c}(\mathcal{H}_{i})>\gamma\) in the present work.  
In the current work, we primarily varied \(\gamma\)-value between (0, 1), and subsequent accuracy variations of the current algorithm are listed in Table 1. The present data samples are the CT-scan micro images of carbonate rock that contain a large number of micro-pores and fractures of shapes similar to the circle (our presumption for the present case). We encourage the readers to make realistic presumptions considering the geological properties of the physical rock sample and image quality. Hence, for the best accuracy of the proposed algorithm, we decided \(\gamma\)-value range between (0, 0.45].  
Figure 3: Conceptual diagrams of step-by-step from a to f each for identification of rock pores (**I**) and fractures (**II**) using the proposed \(k\)-IN approach. \(\mathcal{I}_{a}\). (for simplicity) identifies one dark pixel; \(\mathcal{I}_{b}\). identifies its immediate neighbors (marked red); \(\mathcal{I}_{c}\). finds the immediate dark pixels in the red marked cells (in \(\mathcal{I}_{b}\)) and points to one pixel whose nearest dark neighbors are to be found; finally, \(\mathcal{V}_{i}\). identifies a pore by the recursive implementation of the step \(b\). Quite similarly, we can detect a rock fracture in the current work. A rock fracture can also be seen as a series of connected pores in part (**II**).