# Fractal Dimension-Based Methodology for Discriminating Original Paintings from Replicas
## 3 Material and Methods
### The DBC-RGB Algorithm
For subsequent values of \(s\) (\(s=4\), \(s=8\), \(\ldots\), and \(s=\dfrac{M}{2}\)), the algorithm uses the four previously stored values (from the sub-grids) to efficiently obtain the new maximum and minimum values for each grid (see gray cells in Figure 3c,d), avoiding the need to compare all intensities within that grid. Figure 3: Maximum value computation for the red channel in the implementation of the DBC-RGB algorithm. For clarity, intensity values range from 0 to 9. Adapted from Figure 2 in [37]. ```
1//DBC_RGBalgorithm:IN:RGBimageI,numberofintensityvaluesG;
2//OUT:arrayNrwiththebox-counting
3 voidDBC_RGB(RGBimageI[M,M],intG,intNr[]){
4//copyreg,greenandbluechannelsofIinarraysImaxR,ImaxGandImaxB,respectively
5 intImaxR[M,M]=I[Rchannel],IminR[M,M]=I[RChannel];
6 intImaxG[M,M]=I[Gchannel],IminG[M,M]=I[Gchannel];
7 intImaxB[M,M]=I[Bchannel],IminB[M,M]=I[Bchannel];
8//processgridswithsizes=2 tos=M/2
9 ints=2;
10 intsize=M;
11 intNri=0;//indexforarrayNr
12 while(size>2){
13//computetheboxheightforgridsizes
14 inth=(s*G)/N;
15//foreachboxinthegridofsizes
16 for(inti=0;i<(N-1);i=i+s){
17 for(intj=0;j<(N-1);j=j+s){
18//computethemaxandminvaluesintheboxandstorestheresultsinthepositions(0,0)
19//ofthecorrespondingboxes
20 ImaxR[i,j]=max(ImaxR[i,j],ImaxR[i,j+s/2],ImaxR[i+s/2,j],ImaxR[i+s/2,j+s/2]);
21 IminR[i,j]=min(ImaxR[i,j],ImaxR[i,j+s/2],IminR[i+s/2,j],IminR[i+s/2,j+s/2]);
22 ImaxG[i,j]=max(ImaxG[i,j],ImaxG[i,j+s/2],ImaxG[i+s/2,j],ImaxG[i+s/2,j+s/2]);
23 IminG[i,j]=min(ImImG[i,j],ImImG[i,j+s/2],ImImG[i+s/2,j],ImImG[i+s/2,j+s/2]);
24 ImaxB[i,j]=max(ImaxB[i,j],ImaxB[i,j+s/2],ImaxB[i+s/2,j],ImaxB[i+s/2,j+s/2]);
25 IminG[i,j]=min(ImImG[i,j],ImImG[i,j+s/2],IminB[i+s/2,j],IminB[i+s/2,j+s/2]);
26//computethebox-countingfortheboxandupdatethebox-countingforthegridsizes
27 Nr[Nri]=Nr[Nri]+(ImaxR[i,j]/h-IminR[i,j]/h+1)*
28(ImaxG[i,j]/h-IminG[i,j]/h+1)*
29(ImaxB[i,j]/h-IminB[i,j]/h+1);
30 }
3133333=s*2;
32334

### The Sliding Window Methodology

The sliding window technique involves dividing the study signal, the image of the painting, into fixed-size segments, called windows. These windows move across the signal with a specified shift, which can be equal to or less than the window length. If the shift is less than the window size, the windows overlap by a certain percentage. Each window is processed individually, and the resulting values are then combined to obtain a representation for the full signal. Figure 4 graphically illustrates the sliding window computation of the fractal dimension for an original-replica pair of paintings in the Princeton dataset. The sliding window process has two parameters (see Figure 4, step 1): (1) the size of the window, which defines the dimensions of the square patches (e.g., 512 \(\times\) 512 in the example shown in Figure 4), and (2) the overlap percentage, which establishes the number of pixels that the window shifts by to define the next patch to be processed (e.g., yielding 25% overlap in the example shown in Figure 4). The FD is then computed using the DBC-RGB algorithm for each patch defined by the sliding window (see step 3 in Figure 4). The set of computed FD values from all patches is used to statistically compare the original painting with the replica (see step 4 in Figure 4). We followed a single criterion when selecting the patch size for processing the two datasets in our study to perform an analysis as similar as possible to those conducted in previous studies using these datasets, ensuring a fair comparison of our results. For the paintings in the Princeton dataset, we selected a window size of 512 \(\times\) 512 pixels, as recommended in [5]. A patch of 512 \(\times\) 512 pixels covers approximately 5 \(\times\) 5 cm\({}^{2}\) of the painting surface, which roughly corresponds to the size of the brushstrokes.