# Fractal Dimension-Based Methodology for Discriminating Original Paintings from Replicas
## 3 Material and Methods
### The DBC-RGB Algorithm  
As described later, our approach to analyze the paintings involves computing the fractal dimension (FD) of a set of square patches extracted from the paintings. Several methods for estimating the FD of color images have been proposed in recent years [36; 37; 38; 42; 43; 44; 45]. The most common approach has been to extend the differential box-counting (DBC) algorithm for grayscale images to the color domain [36; 37; 38; 44; 45]. Among these methods, the ultra-fast DBC-RGB algorithm presented in [37] stands out because its accuracy is comparable to reference algorithms while being much faster due to its parallel nature, which enables GPU implementation. This characteristic is crucial for the present study, as a large number of patches in each painting must be processed. A detailed description of the DBC-RGB algorithm and its GPU implementation can be found in [37]. Below, we briefly describe the fundamentals of the algorithm. Figure 1: The Princeton dataset. In the DBC-RGB algorithm (see the pseudo-C code in Listing 1), each pixel in the image is represented as a five-dimensional vector (\(x\), \(y\), \(r\), \(g\), \(b\)), where (\(x\)\(y\)) denote the pixel coordinates, while (\(r\), \(g\), \(b\)) represent the respective intensity levels of the colors red, green, and blue. The image of \(M\times M\) pixels is divided into grids of boxes of size \(s\times s\), with each grid corresponding to an RGB cube of size \(h\)\(\times\)\(h\)\(\times\)\(h\). Here, \(h\) is calculated as \(\left|\dfrac{s\times G}{M}\right|\), where \(G\) is the total number of intensity levels for each color and the grid size \(s\) ranges from 2 to \(\dfrac{M}{2}\). The method then counts the number of boxes of size \(s\times s\times h\times h\times h\) that cover at least one pixel of the image. To accomplish this, the distribution of pixels along each of the R, G, and B axes is computed independently as follows: (1) For each channel \(c\) (R, G, and B) of the image, the boxes containing the maximum and minimum intensity levels within the grid (\(i\), \(j\)) are denoted as \(k_{c}\) and \(l_{c}\), respectively; and (2) the count for each channel \(c\) in the grid (\(i\), \(j\)) is then calculated as \(n_{rc}(i,j)=k_{c}-l_{c}+1\). Once the count \(n_{rc}(i,j)\) for each channel is computed, the number \(n_{r}(i,j)\) of boxes covering pixels in the grid (\(i\), \(j\)) is estimated by multiplying these three counts: \(n_{rR}(i,j)\)\(\cdot\)\(n_{rG}(i,j)\)\(\cdot\)\(n_{rB}(i,j)\). Finally, the total box count \(Nr\) is computed as \(Nr=\sum_{i}n_{r}(i,\)\(j)\) for scale \(r\) ranging from \(\dfrac{2}{M}\) to \(\dfrac{1}{2}\), and the fractal dimension of the RGB image is determined by calculating the slope of the linear regression of the points \(\left(log\left(\dfrac{1}{r}\right),\ \log(Nr)\right)\). Figure 2: The Cleveland dataset. A parallel and highly efficient implementation of the DBC-RGB algorithm is achieved in [37] by considering only grid sizes, \(s\), that are powers of two; this approach avoids repeatedly scanning the image to compute each \(Nr\) value. The algorithm implementation initializes six buffers (\(I_{maxR}\), \(I_{minR}\), \(I_{maxG}\), \(I_{minG}\), \(I_{maxB}\), and \(I_{minB}\)) with the red, green, and blue channels of the image, respectively (see Figure 3a and lines 4-7 in Listing 1). For \(s=2\), the maximum and minimum intensity levels in each \(2\times 2\) grid are obtained for each color channel (see Figure 3b and lines 18-25 in Listing 1), and the three counts \(n_{rR}\), \(n_{rG}\), and \(n_{rB}\) are calculated. These counts are multiplied to obtain \(n_{r}\); then, \(Nr\) is computed as described previously (see lines 26-29 in Listing 1). The maximum and minimum values are then stored in the (0, 0) positions of their respective grids (see yellow cells in Figure 3).