## 3 Design of the Algorithm
### Algorithm Description  
The main flowchart of the following algorithm is described in Figure 4. It consists of three phases, which are explained below:  
1. Input elements
2. Pixel matrix set: Each matrix corresponds to the image associated with a cross-section of the pulp chamber, in ascending order of height. It is understood that the first image corresponds to the first plane of the pulp chamber that does not include the molar canals. 3. Pixel dimension: For each set of images, the unit of distance is the measurement of the pixel side. In turn, the inter-planar distance corresponds to the height of the pixel. For the sets considered, we work with cubic pixels (voxel). 4. First surface point: To allow the detection of the pixels of the pulp chamber surface in the first matrix, it is necessary to consider a pixel belonging to it. If this pixel is not provided by the user, a pixel is selected automatically in the manner indicated below. 5. Control parameter \(k\) (threshold): In the images considered, there is a color difference between pixels that belong to the bony surface of the tooth and those that do not. The control parameter \(k\) makes it possible to establish a prior separation between the elements of the pixel matrix that potentially belong to the pulp chamber and those that do not. Figure 4: Main flowchart of the pulp chamber surface point detection algorithm. Determination of the surface matrix  
Starting from the pixel matrix I of each plane, a new matrix M (surface matrix) is constructed such that:  
\[M_{ij}=\left\{ \begin{array}{ll}1&if\;\;I_{ij}\;\geq k\\ 0&if\;\;I_{ij}<k\end{array} \right. \tag{4}\]  
Calculation of pixel surfaces  
Given a non-zero element a of matrix M of coordinates (a\({}_{1}\), a\({}_{2}\)), we define the equivalence class with representative a as \(\left\{M_{ij}\in\mathrm{M/(i,\,j)}\!\!\sim_{2}(a_{1},a_{2})\!\!\wedge\!M_{ij} \
eq 0\right\}\). Each of the equivalence classes is called a surface. In the first step of the algorithm, a pixel of the pulp chamber is required. The first image, which is being worked with in the first step, is selected by an expert and is the closest to the molar canals. To identify the pixel belonging to the pulp chamber automatically, a pixel from the center of the image is selected first. If the pixel value is greater than the threshold value, it is considered to belong to the pulp chamber, and the algorithm is started. If the selected pixel is below the threshold value, the next closest pixel to the center of the image that has not yet been considered is taken, and the process is repeated. Since the first image is the one closest to the molar canals, we are under the assumption that all pixels in the pulp chamber, in that plane, belong to the same equivalence class. To separate each equivalence class, we begin by selecting a non-zero element in M (pixel) with coordinates P, from which we define a set S. This element is then set to zero in M. Next, we check if there are elements in M with coordinates P\({}^{\prime}\) that satisfy d(P, P\({}^{\prime}\)) \(\leq\) 2 and are non-zero. If such elements exist, they are added to S, and the process is repeated for these new elements. Once no more elements are added to S, the surface is considered complete, and a new non-zero element is taken in M. The algorithm ends when there are no more non-zero elements in M to add to an equivalence class. At the end of the process, we have a separation of M into its different surfaces. The flowchart for this phase is shown in Figure 5.  
Figure 5: Main flowchart for calculation of pixel surfaces. Identification of the pulp chamber  
If it is the first image, only the surface containing the first surface point given as an input parameter is retained. If it is a subsequent image, surfaces far from those obtained in the previous iteration are eliminated.