## 2 Materials and Methods--Porosity Classification and Fracture Identification
### Pixel-Wise k-IN Approach to Determine Rock Fractures and Pores
#### 2.4.3 Finding the Contiguous Dark Pixels Using k-IN  
Initially, we determine the \(\mathcal{L}\) values of all the pixels in a given input image sample and classify each of them based on their respective \(\mathcal{L}\) values (see Algorithm 1). Next, we locate all the dark pixels in the input image and store their relevant information (mainly location) in a separate bag of pixels, i.e., \(\mathbb{L}\). Quite expectedly, the size of \(\mathbb{L}\) should be any positive integer greater than 0. Next, we recursively identify all \(k\)-immediate dark neighboring pixels (\(0\leq k\leq 8\), see Figures 1a and 3) for every dark pixel in \(\mathbb{L}\), which covers most of the dark regions in an image sample; this, in turn, points to the identification of the majority of the rock pores and fractures.  
For better and clearer understanding, we present an over-simplified toy example of one 4 \(\times\) 4 image (see Figure 1). Of 16 pixels, eight among them are classified dark (classifications are done using Algorithm 1), whose locations are 1, 4, 7, 8, 10, 12, 15 and 16. We have to classify these pixels as a pore (if any), given that the collection of two or more contiguous dark pixels is considered as a pore. Initially, we kept all eight dark pixels in the bag of pixels \(\mathbb{L}\) = [1,4,7,8,10,12,15,16] and the subsequent bags of pixels for each element of \(\mathbb{L}\) are \(\mathbb{L}_{1}=\{\varphi\}\) (no adjacent dark pixel); \(\mathbb{L}_{4}\) = [7,8]; \(\mathbb{L}_{7}\) = [4,8,10,12]; \(\mathbb{L}_{8}\) = [7,15]; \(\mathbb{L}_{12}\) = [7,8,15,16]; \(\mathbb{L}_{15}\)= [10,12,16] and \(\mathbb{L}_{16}\) = [12,15]. This has been done using the recursive function PIXEL-WISE, \(k\)-IN(\(\mathbb{L}\)) (see Algorithm 2).  
Next, from the other bags of pixels, \(\mathbb{L}_{1}\) is a null set, and hence pixel \(\mathbb{L}_{1}\) cannot either be a pore or a fracture. Then for the next bag of pixel \(\mathbb{L}_{4}\) we found 7 and 8 are the dark neighbors of pixel 4 and again from \(\mathbb{L}_{7}\) and \(\mathbb{L}_{8}\), it can be confirmed that \(\mathcal{H}_{4}\) = {4,7,8,10,12}. After analyzing \(\mathbb{L}_{10}\) and \(\mathbb{L}_{12}\) (since occurring in \(\mathbb{L}_{7}\) and \(\mathbb{L}_{8}\)), \(\mathcal{H}_{0}\) can be extended to \(\mathcal{H}_{0}\) = {4,7,8,10,12,15,16}. Later analyzing \(\mathbb{L}_{15}\) and \(\mathbb{L}_{16}\) since occurrence in \(\mathbb{L}_{10}\) and \(\mathbb{L}_{12}\)) we finalize \(\mathcal{H}_{0}\) as \(\mathcal{H}_{0}\)= {4,7,8,10,12,15,16}. Since \(\mathcal{H}_{0}\) contains more than two pixels, hence it is considered a pore (see Figure 1a). After all the analyses, it can be confirmed that this toy example has only one identifiable pore. As mentioned earlier, it is an over-simplified case presented for a better understanding of the proposition, for which the detailed implementation of the proposed technique in the presence of a complex data set has been given in the later part to show its wide applicability range. A pictorial representation of the step-wise execution of the proposed algorithm is shown in Figure 3.