Problems of the Grid Size Selection in Differential Box-Counting (DBC) Methods and an Improvement Strategy

The differential box-counting (DBC) method is useful for determining the fractal dimension of grayscale images. It is simple to learn and implement and has been extensively utilized. However, this approach has several problems, such as over- or undercounting the number of boxes due to inappropriate parameter choices, limiting the calculation accuracy. Many studies have been conducted to increase the algorithm’s computational accuracy by improving the calculating parameters of the differential box-counting method. The grid size is a crucial parameter for the DBC method. Generally, there are two typical ways for selecting the grid size in relevant studies: consecutive integer and divisors of image size. However, both methods for grid size selection are problematic. The consecutive integer method cannot partition the image entirely and will result in the undercounting of boxes; the divisors of image size can partition the image completely. However, this method uses fewer grid sizes to compute fractal dimensions and has a relatively huge distance error (DE). To address the shortcomings of the above-mentioned two approaches, this research presents an improved grid size selection strategy. The improved method enhances computational accuracy by computing the discarded image edge areas in the consecutive integer method, allowing the original image information to be used as thoroughly as the divisor strategy. Based on fractional Brownian motion (FBM), Brodatz, and Aerials image sets, the accuracy of the three grid size selection techniques (consecutive integer method, divisors of image size method, and the improved algorithm) to compute the fractal dimension is then compared. The results reveal that, compared to the two prior techniques, the revised algorithm described in this study minimizes the distance error and increases the accuracy of the fractal dimension computation.


Introduction
An image captured by a camera is a projection of an actual three-dimensional shape on a plane. The image textures can reflect the morphological features of the physical object. As a result, objects can be identified by evaluating the grayscale variations of an image. Textured surfaces, on the other hand, are inherently complex in natural scenes. Irregular and complex objects cannot be described using Euclidean geometry. Mandelbrot proposed utilizing fractal geometry to describe this type of phenomenon in 1983 [1]. Fractal geometry is used to define self-similar scale-independent elements known as fractal sets. The irregularity of a fractal set can be computed using the fractal dimension. The fractal dimension is now widely utilized in computer vision applications such as texture analysis [2], image segmentation [3], shape recognition [4], pattern recognition [5], time series analysis [6], complex network analysis [7], landslide susceptibility assessment [8], topography analysis of thin films [9], cement-based materials analysis [10], and description of urban morphology [11].
In 1994, Sarkar et al. [18] proposed the differential box-counting (DBC) method to compute the fractal dimension by counting the number of boxes. This method is extensively utilized since it is simple to understand and implement. However, the DBC approach has numerous flaws, including excessive counting of z-direction boxes, inappropriate box heights, inaccurate box-counting in the xy-direction, and inappropriate box sizes. These weaknesses frequently result in incorrect fractal dimensions, severe distance errors (DEs), and other problems.
For the DBC method, the fractal dimension is calculated by fitting a series of points (log1/r, logN r ) in a log-log plot. The parameter associated with r is the grid size s, while the N r value is influenced by many parameters, such as the box side length s and height h, the number of boxes n r of each gird, and the partitioning method of the xy plane. The calculation methods of these parameters directly impact the calculating accuracy of the DBC method. Many studies have been undertaken to increase the computational accuracy by improving each parameter of the DBC method to tackle the shortcomings of the original DBC approach.
Jin et al. [19] discovered that, during the DBC calculation, the log-log plot presents "steps" under large s values. The central portion of the curve had a relatively constant gradient, while the plot started to level off for smaller values of s. This phenomenon decreased the accuracy of the calculation. Thus, the authors proposed the RDBC approach to lower the DE by optimizing the range of grid size s. Although this study indicates that the trend at both ends of the curve influences the calculation results, it does not give a complete examination of the origins of its phenomenon and does not fix the underlying problems.
Chen et al. [20] presented the SDBC method to overcome the problem of overcounting boxes in the z-direction, by introducing a box-shifting mechanism in the z-direction to optimize the calculation of n r . Li et al. proposed a new n r strategy in 2006 [21] and 2009 [22] to overcome the problem of overcounting boxes in the z-direction. They also proposed an overlapping grid partitioning approach to address box over-and undercounting problems along the xy-axis, where two nearby grids overlap by one row and one column. However, several shortcomings in this method have been identified in previous literature [23].
Long et al. [24] proposed the integer ratio DBC (IRDBC) to estimate the FD of rectangular images. IRDBC avoided the overcounting of boxes along the xy-axis by employing a new n r formula that does not use the ceiling function. As a result, IRDBC generates authentic values for n r . However, IRDBC employs only integer values for 1/r, resulting in very few grid sizes being used to compute the fractal dimension.
Liu et al. [25] optimized the formula to compute n r and introduced a grid-shifting mechanism to solve the undercounting of boxes along the xy-direction; for non-trivial plane partitioning, the image size divisors were employed as the grid size s. Compared to DBC, they indicated that the improved method enhanced accuracy by 24.1%. Based on Liu's work, Lai et al. [26] improved the computation of box h. Panigrahy et al. have put in much effort to improve the DBC method. In 2017 [27], they investigated the effect of box height on the accuracy of DBC computation and presented a new method of calculating box height, which considerably enhanced the accuracy of fractal dimension calculation. In 2020 [28], they proposed three new DBC algorithms based on weighted least squares regression. These methods also use a new xy-plane shifting mechanism and a modified formula for computing n r . However, their method utilized the divisors of image size as the grid size, resulting in a larger DE. In 2021, Liu et al. [29] proposed the IMDBC method, which improved the box-shifting mechanism. The proposed method not only solved the undercounting problem along the xy-direction but also had superior stability for image rotation. Compared to DBC and its state-of-the-art methods, the IMDBC method has higher computational accuracy.
According to the studies mentioned above, each algorithm overcomes the shortcomings of the original DBC method by optimizing the calculation parameters to enhance the computing accuracy and minimize distance error. Various parameters affect the computation of the fractal dimension; different approaches have different optimization focuses. Nevertheless, they all achieved better results than the DBC method under their corresponding validation method. However, some studies failed to provide more persuasive evidence on the enhanced accuracy because their validations were not performed using images with known theoretical fractal dimensions, such as synthesized FBM Database [25,29].
Among the various parameters utilized in DBC calculations, the grid size s is crucial. The choice of grid size for a square image impacts how the plane is partitioned during computing. The original DBC approach was based on consecutive integer partitioning, which discards areas that cannot be partitioned in an integer manner [23]. Currently, this strategy is frequently used in studies of state-of-the-art DBC methods [22,26,30,31]. However, in other works, such as those of Liu et al. [25] and Panigrahy et al. [28], the authors utilized a similar approach to that used in Biswas' study [32], employing divisors of the image size as the grid size s to partition the square image fully.
These two approaches for calculating s values are frequently used in DBC algorithms. Both strategies, however, have limitations. The consecutive integer partitioning method discards the boundary region; hence, the original image is not fully utilized, which will lead to the problem of undercounting boxes. Moreover, as noted previously, the curve of the consecutive integer method is shaped like "steps" at large s values in the log-log plots, which will also affect the calculation accuracy [19]. Although the divisor method can partition the entire image, it omits a significant amount of information at other s values, which leads to result distortion and high DE values [33].
The weight approach has been utilized to compute n r in some methods [23,24,30]. The weight technique is used to calculate n r in a grid whose area is less than s × s and to assign weights based on the actual area of the grid. Long et al. [24] were the first to propose the weight method for calculating the n r values of the boundary grids. Nunsong et al. [30] and Panigrahy et al. [23] then applied the weight technique to the modified triangle boxcounting (TBC) methods. In the work of Long et al., the grid partitioning approach is an integer multiple of r values. This strategy would result in fewer s values utilized for calculation and, sometimes, the same s for varied r values [33]. In the studies of Nunsong and Panigrahy, on the other hand, the weight technique was utilized to calculate triangular grids. However, most current DBC algorithms are based on square grids, where the weight method is rarely used. Hence, we propose an improved continuous integer technique for square grid calculation based on the weight method to tackle the problems of the typical divisor method and consecutive integer method.
In order to further investigate the impact of the grid size selection on fractal dimension calculation, this study first introduces the principles of two typical grid size selection methods and assesses their advantages and disadvantages. Then, by processing the discarded edge regions of an image with the weight method, an improved strategy is proposed to tackle the undercounting problem of the original consecutive integer approach and the result distortion problem of the divisor method. Subsequently, based on three image sets (synthesized FBM database, Brodatz database, and Aerials database), the impacts of the three grid size selection methods (original consecutive integer, divisors of image size, and the improved method) were then analyzed, evaluated, and compared. The results reveal that, compared with the original consecutive integer method and the divisor method, the DBC technique based on the improved grid size selection strategy can better estimate fractal dimension values, produce lower DE values, and obtain more consistent goodness of fit values. The various notations and abbreviated terms used in this work are summarized in Abbreviations.
The remaining parts of the paper are as follows: Section 2 describes the classic DBC method, the typical grid size selection strategies, and the drawbacks of each strategy. In the third section, an improved grid size selection strategy based on the consecutive integer method is proposed. Section 4 discusses the three image databases (FBM, Brodatz, Aerials) utilized for validation and evaluation metrics. Section 5 describes and discusses the results of the two typical grid size selection strategies and the improved one based on three image databases. Section 6 presents the conclusions.

The DBC Method
In 1994, Sarkar et al. [18] proposed a differential box-counting (DBC) technique to compute the fractal dimension of a grayscale image. A square grayscale image with a resolution of M × M can be mapped in 3D space, as illustrated in Figure 1, where the xand y-directions denote the image length and width. The grayscale values are represented along the z-direction. The xy plane is divided into non-overlapping grids of size s × s. The values of s vary from 2 to M/2. Non-square grids are formed at the borders if s is not a divisor of M. In this situation, the computation disregards these non-square grids near the boundary. Thus, grids of size s × s partition the plane fully. The grid ratio, r, is calculated using s/M. To represent the gray level variation, n r boxes of size s × s × h are required for each grid, where h is the box height. The following equations are used to compute h and n r (Equations (1) and (2)): G is the total number of grayscale orders in the 8-bit grayscale image, which is 256; g max and g min are the maximum and minimum grayscale values in the (i, j)th grid. Then, the total number of boxes N r corresponding to the ratio r can be calculated using the following formula: Finally, the fractal dimension D is computed by fitting the points (log1/r, logN r ) ∀r with linear least squares regression (LLS). LLS can produce the fitting line y = px + q for these points. The slope and intercept of the fitted line are denoted by p and q, respectively. Here, the slope p is the fractal dimension D that we need.

Two Typical Methods for Determining Grid Size and Their Shortcomings
Many modified DBC methods have emerged based on Sarkar's DBC method. The grid size s is an essential parameter in these methods. It determines how to partition the xy plane. In general, there are two types of grid size selection methods: consecutive integer and divisors of image size. However, each of these solutions has its shortcomings.

Consecutive Integer Method
The original DBC method uses all successive integers between s min and s max as grid sizes. The same partitioning strategy was used in other state-of-the-art methods such as RDBC [19], SDBC [20], Li'2006 DBC [21], Liu'2008 DBC [31], Li'2009 DBC [22], Lai'2016 DBC [26], and Liu'2021 DBC [29]. Most improved algorithms employ this partitioning strategy. Using consecutive integers as grid size can obtain more fitting points for calculating fractal dimensions. However, this method suffers from some limitations. The primary problem with the consecutive integer method is that for large grid size s, several s values correspond to the same N r value, and the relevant curve would be shaped like a "step" in the log-log plot [28].
We take a 512 × 512 image as an example. For the consecutive integer method, s max can be up to 256. At this point, the grids have partitioned the image into four regions ( Figure 2e). Several circumstances occur when s is between 128 and 256, as illustrated in Figure 2. When s gradually decreases from 256, the entire image cannot be partitioned completely, and the discarded region (blue) appears, as shown in Figure 2d. Then, s continues to decrease, and the area of the discarded region increases ( Figure 2c). Finally, when s is reduced to a value less than 170, as shown in Figure 2b, the number of grids becomes nine, but the plane is still not fully partitioned, even though the discarded area is smaller. When s decreases to 128, as indicated in Figure 2a, the image can be fully partitioned once more.
The results in Figure 3 can then be obtained based on the above analysis. The relationship between the actual area for calculation (percentage of the image area) and the gird size s is depicted in Figure 3. The amplitude of the curve increases with increasing s, as shown in the figure. The minimum value of the curve is even less than 50%. When consecutive integers are used as s values, the area used for calculation differs significantly from the actual image area. This deviation becomes more pronounced as the s value increases. Because of the discarded areas, the number of boxes is undercounted, resulting in distorted results.
In theory, a smaller s value should result in a larger N r value. However, due to the vast number of undercounted boxes in this method, especially at large s values, the curve is shaped like a "step", which is a visual representation of the box undercounting problem.

Divisors of Image Size
Biswas [32] first proposed using 2 i ∀ ∈ Z + , where i ∈ [1, log 2 (M) − 1] and log 2 (M) ∈ Z + . Such methods identify the divisors of M to determine s values. This results in grids that partition the entire image without the issue of discarding edge regions, as shown in Figure 2a,e. Some s values, as illustrated in Figure 3, correlate to a calculated area/image area percentage that can reach 100%. In the divisor method, such s values are selected for calculation. This approach is relatively fast since the number of calculated s values is significantly lower than that in the consecutive integer method. All of the s values can completely partition the image, and the corresponding N r values can better capture the properties of the entire image. However, the reduced number of s values introduces other issues. Images of natural settings are frequently not ideal fractal objects [23] but rather approximate fractals. As a result, fewer computed points may not necessarily represent the image features and cause the results to deviate from the actual fractal dimensions. Moreover, for a 512 × 512 image, the highest s value of the method is 256, with the second biggest grid size being 128. This significant interval between s values at large scales tends to ignore plenty of grayscale information. Furthermore, the distance error of the divisor method is likewise fairly large [33].

Improved Consecutive Integer Method
As mentioned above, the divisor method can thoroughly partition the image, but the number of s values is minimal, which can easily lead to distorted results. Although more s values are used in the consecutive integer technique, most of the s values, which cannot entirely partition the image, are prone to the undercounting problem of boxes, especially at large grid size s. Thus, we expect an improved method that can entirely partition the image like the divisor method, but also has numerous s values involved in FD calculation like the consecutive integer method.
To achieve this, we can improve the consecutive integer method by supplementing it with the undercounting boxes. If a given value of s does not completely partition the image, a zone with a width less than s is generated at the boundaries. This is depicted in the blue region of Figure 4. Although the area of each grid in the blue region is less than s × s, it also corresponds to a part of a two-dimensional surface with grayscale variations inside, and the n r value can be computed using Equation (2). However, because the area is less than s × s, the n r value cannot be determined directly as other grids. Thus, the weight approach is introduced here.
The weight method would assign the corresponding weights according to the actual area of the grids [24]. The number of boxes and the area weights need to be considered simultaneously in calculating the n r value of grid (i, j)th. The weight factor F is calculated as shown in Equation (4). A(i, j) is the actual area of the (i, j)th square, and S stands for s × s, which is the area of a grid. F is the ratio of the actual grid area to the theoretical grid area. The corresponding n r value calculation can be obtained from Equation (5). The code of the DBC method based on two consecutive integer methods is shown in Figure 5. The improved method's specifics are as follows: Partition an M × M image into tiny square grids with size s. The number of grids is Size × Size. If M is not divisible by s at this point, non-square regions will form at the margins. As shown in Figure 4, grids 1, 2, 4, and 5 are square regions while grids 3, 6, 7, 8, and 9 are irregular edge regions. By replacing Equation (2) with Equation (5), the n r value for each grid of the image can be calculated. Subsequently, summing the n r values for each grid gives N r (Equation (6)).
Finally, linear least squares regression (LLS) is used to fit the obtained points (log1/r, logN r ) ∀r to calculate the fractal dimension D. Section 5 of the study will further investigate the validity of the method.

Databases for Validation
To compare the performance of the consecutive integer technique, the divisor method, and the improved method, we validate these three approaches using the synthesized FBM images, Brodatz database, and Aerials database. The FBM images can be synthesized based on the theoretical fractal dimension, and the produced grayscale images can be used to validate the accuracy of the three algorithms. The Brodatz and the Aerials databases are typical for validating the fractal dimension algorithm, both obtained in natural scenes. With the help of the Brodatz and the Aerials databases, the algorithms' performance for texture images and aerial photographs could be evaluated, respectively.

Synthesized FBM Images
In this research, FBM images are synthesized based on the random midpoint displacement (RMD) method. [34] Table 1 tab displays the computational parameters of RMD. The "maxlevel" is used to limit the size of the synthesized image, which is 2 maxlevel + 1; "sigma" is the initial standard deviation; H is the Hurst parameter to determine the actual fractal dimension D = 3 − H. The Boolean parameter "addition" is used to turn on and off the random additions. The "seed" is the seed value for the random number generator.
Nine images with a resolution of 513 × 513 are created using the RMD method with varied Hurst parameters. To obtain images with a resolution of 512 × 512, the last row and last column of the image are removed. Figure 6 depicts the synthesized images and their theoretical fractal dimension values.

Brodatz Database
The Brodatz database [35] contains 112 grayscale texture images and is one of the most extensively used image databases. Each image in the database has an unknown theoretical fractal dimension. Sixteen images (shown in Figure 7) were chosen from the database for calculation. Because the images in the Brodatz database are all 640 × 640 resolution, the bicubic algorithm was employed to resize the chosen images to 512 × 512 resolution.

Aerials Database
As illustrated in Figure 8, twelve satellite images from the SIPI image database [36] were chosen to validate the algorithms' performance. Because the original photos are not grayscale, they need to be converted into grayscale images before calculation using rgb2gray function in Matlab software. The rgb2gray algorithm used in Matlab is a weighted average of the R, G, and B channels' values, as shown in Equation (7):

Evaluation Metrics
Generally, LLS fit to a set of points in a log-log plot is required to calculate the fractal dimension. The goodness of fit (R 2 ) measures how well the fitting line matches the scattered points, whereas the distance error (DE) measures the average error between the fitted and actual values. All three databases are calculated using these two assessment measures. The correlation coefficient and slopeb are introduced to the calculation of synthetic FBM images. These two metrics can evaluate whether the estimated fractal dimensions correlate well with the theoretical fractal dimensions.

Goodness of Fit (R 2 )
The goodness of fit is used to evaluate the fit of the regression line to the observed values. The maximum value of R 2 is 1. R 2 close to 1 indicates the excellent fit of the regression line to the observed values; conversely, R 2 close to 0 indicates the poor fit of the regression line to the observed values. For m samples, (x 1 , y 1 ), (x 2 , y 2 ), . . . , (x m , y m ), the estimates corresponding to the model are (x 1 ,ŷ 1 ), (x 2 ,ŷ 2 ), . . . , (x m ,ŷ m ).
Then, calculate the total sum of squares (TSS): Calculate the residual sum of squares (RSS): Then, we can get:

Distance Error (DE)
The fractal dimension is calculated using LLS fitting in the various DBC techniques. The distance error (DE) is defined as the root-mean-square distance between the scatter points and the fitted line in a log-log plot. DE is a crucial metric for evaluating DBC methods and has been utilized in many studies [23,29,33]. Various optimizations of the DBC method are also aimed at smaller DE. The calculation equation is shown below.

Correlation Coefficient γ
Correlation coefficients are used to show the linear relationship between two sets of data. The algorithms provide a number between −1 and 1, where 1 represents a strong positive relationship, −1 represents a strong negative association, and zero represents no relationship at all. For two sets of variables, X(x 1 ,x 2 , . . . ,x m ) and Y(y 1 ,y 2 , . . . ,y m ), the correlation coefficient γ can be calculated by the following equation:

Slopeb
b is the slope of LLS fitting line for m sets of samples (x 1 , y 1 ), (x 2 , y 2 ), . . . , (x m , y m ). Corresponding to the model estimates (x 1 ,ŷ 1 ), (x 2 ,ŷ 2 ), . . . , (x m ,ŷ m ), the slope b is determined as shown in Equation (13). This metric is utilized in the FBM database calculation to assess how well the fractal dimension calculated by DBC methods matches the theoretical values.b

Flow Chart of the Experiment
Combining the above content, we can get the experimental process of this study, as shown in Figure 9. The experimental results in the fifth section are obtained according to this procedure.

The Effect of Grid Size Selection on the Fractal Dimension Calculation for Synthesized FBM Images
The RMD method was used to generate FBM images with theoretical fractal dimensions ranging from 2.1 to 2.9. The following methods were used to calculate grid size: divisor of image size (ER), original consecutive integer method (CI), and optimized consecutive integer method (OCI). Table 2 displays the fractal dimension calculation, the goodness of fit, and the distance error corresponding to the three methods. Figures 10-12 illustrate the data in Table 2. The correlation coefficients and slopeb between the theoretical fractal dimensions and the calculated fractal dimensions are shown in Table 3. Theoretically, the estimated fractal dimensions should be identical to the theoretical values, but this does not happen due to methodology error. When the correlation coefficient and slope are near 1, we can conclude that the corresponding method performs well. Figure 10 shows that the fractal dimension value calculated by the three methods rises as the TFD value increases. The consecutive integer method achieves the largest value from the fractal dimension value calculation, the divisor method produces the smallest value, and the computed value of the enhanced consecutive integer method is between the two. According to the data in Table 3, the improved approach has the largest correlation coefficient, the original consecutive integer method has the smallest, and the divisor method has a correlation coefficient between the two. This demonstrates that the fractal dimension values calculated by the improved consecutive integer method correlate better with TFD values than those of the other two methods. In terms of slope, the improved consecutive integer method has a somewhat lower slope than the original method. However, both have higher slope values than the divisor method. The above results demonstrated that, compared to the consecutive integer methods, the computed fractal dimensions derived by the divisor method have a relatively good correlation with the TFD values but the trend deviation is large. The calculated results of the original consecutive integer method can better match the trend of the TFD values, but the correlation is the worst. The improved method outperforms the other two in terms of linear correlation between calculated FD and TFD values, although it has slightly lower slope values than the original consecutive integer method.
When comparing the goodness of fit results in Table 2 and Figure 11, it can be observed that the improved method has the highest goodness of fit, followed by the divisor method, and the original consecutive integer method has the lowest goodness of fit. When the DE values are compared (Figure 12), the divisor method has the largest distance error; the consecutive integer method has a relatively moderate distance error, and the enhanced method has the smallest distance error.
To investigate the causes of this phenomenon, we generated Figure 13 based on the calculation of the FBM image with a theoretical fractal dimension of 2.9. Figure 13a-c depict the log-log plot curves of the three approaches, respectively. We produced Figure 13d to compare the difference in the number of boxes between the improved consecutive integer method and the original method.
In this work, eight s values are employed for the divisor method and 255 for the consecutive integer method. These 255 s values contain the divisor method's eight s values. This is equivalent to the consecutive integer technique having 247 more data points than the divisor method for LLS fitting. The absence of these 247 points is also responsible for the distinction between the divisor method and the consecutive integer method.
According to Figure 13c, the divisor method requires fewer scatter points for the calculation, which is related to the lower number of s values needed for the calculation. Fewer points reduce the computing work accordingly. However, the relatively small number of grid size values leads to the insufficient utilization of the original image, which can easily distort the fractal dimension result. As a result, although the divisor method has a higher R 2 value and the obtained fractal dimension value has a higher correlation with the TFD value, the calculated fractal dimensions are smaller than those of the two consecutive integer methods, the distance errors are larger, and the trend deviation of the calculated result from the TFD value is relatively large.
For the consecutive integer methods, more s values are used, and more corresponding N r values are acquired. Even though the calculation amount is substantially larger than that of the divisor method, the grayscale information offered by the original image can be fully utilized. As a result, consecutive integer methods produce higher FD and lower distance error compared to the divisor method, and the computed fractal dimensions trend is closer to the TFD values. However, because the edge region is discarded in the original consecutive integer technique, the undercounting of boxes emerges at most s values. The "steps" in the curve, as seen in Figure 13a, best represent this problem. The improved method reconsiders the discarded boxes and produces a smoother curve, as seen in Figure 13b.    The improved method considerably improves the number of computed boxes compared to the original consecutive integer method, as shown in Figure 13d. The higher the s value, the greater the percentage of improvement. This curve resembles the trend in Figure 3. It can be interpreted as the improved approach compensating exactly for the original method's discarded boxes, and the larger the s value, the larger the percentage of compensation. Compared to the original consecutive integer method, the improved method makes better use of the image's grayscale information. The compensating for the discarded boxes, on the one hand, raises the N r values under large s values, which results in a reduction in the slope of the LLS line (i.e., the fractal dimension value) in Figure 13a. As a result, the fractal dimension of the improved method appears to be less than that of the original consecutive integer methods, as illustrated in Figure 10.  On the other hand, the "steps" in the curve of the original consecutive integer method are deleted, the incorrect box-counting is revised, and the computational accuracy is enhanced. Thus, compared to the original consecutive integer method, the improved method achieves larger goodness of fit and a smaller distance error, and the computed fractal dimension has a better correlation with the TFD value.
In summary, the improved consecutive integer method outperforms the divisor method and the original consecutive integer method in computing accuracy for the fractal dimension calculation of FBM images.

The Effect of Grid Size Selection on the Fractal Dimension Calculation for Brodatz Images
The Brodatz texture database, a commonly used database in DBC investigations, is utilized for validation to examine the three methods' performance in fractal dimension calculation of texture images. This database is composed of grayscale images with various textures. The calculation in this section is based on the consecutive integer method, the divisor method, and the improved consecutive integer method for 16 images from the Brodatz database. Table 4 displays the acquired results for fractal dimension, the goodness of fit, and distance error, and Figures 14-16 illustrate the data in the table. Figure 14 shows that the three methods for calculating the fractal dimension have a similar variation trend. The trend depicted in Figure 14 is generally consistent with the prior study [33]. The fractal dimensions acquired by the consecutive integer method are large, while the fractal dimensions produced by the divisor method are small; the fractal dimension result of the improved method is between the two. The improved consecutive integer method has a much higher goodness of fit than the original consecutive integer method, according to the goodness of fit curve in Figure 15; the goodness of fit achieved by the divisor method is between the two. Figure 16 illustrates that the distance error values of the divisor method are higher than those of the two consecutive integer methods, and the improved consecutive integer method obtains the smallest distance errors.
The Brodatz texture database, unlike the FBM images, is derived from the natural scene. As discussed in Section 2.2.2, images of natural scenes are not always ideal fractal patterns [23]. This is where the Brodatz database images differ from the FBM-generated images. It also emphasizes the significance of validating with the Brodatz database. Based on the analysis of the previous section, in the calculation of Brodatz images, the improved consecutive integer method considers edge regions and calculates more boxes than the original consecutive integer method. It is equivalent to raising the value of N r under certain s values, particularly when s is large. Compared to the original consecutive integer approach, the improved method decreases the slope of the fitted line, i.e., the fractal dimension value. For calculating the fractal dimension of texture images, the improved method obtains larger goodness of fit and a smaller distance error compared to the original method. It demonstrates that the conclusions obtained in the previous section are still applicable to texture image calculation.
The preceding section mentioned that using fewer s values can result in distorted computing results for the divisor method. For the Brodatz database, the distortion of the divisor method results in small fractal dimensions and large distance errors. This result agrees with the FBM-based study described above.
In summary, the improved consecutive integer method outperforms the original method for texture image calculation. Because of distortion, the divisor method does not produce satisfactory results when calculating texture images. In 2021, Liu et al. [29] compared their method to the algorithms proposed by Panigrahy et al. in 2020 [28] and Li et al. in 2014 [25]. For the Brodatz database, the mean value of DE calculated by these methods is more than 0.0025. In this study, the Brodatz database's mean DE value determined by using the DBC algorithm only modified with the improved consecutive integer method is 0.024. Furthermore, only the grid size selection method is optimized in this study compared to the original DBC approach; no box-shifting mechanism or box height change is utilized. This also emphasizes the significance of grid size selection.

The Effect of Grid Size Selection on the Fractal Dimension Calculation for Aerials Images
To compare the performance of the three methods, twelve images from the Aerials database with a resolution of 512 × 512 were chosen. As these are high-altitude aerial images, they are suitable for remote sensing applications. Figures 17-19 and Table 5 illustrate the fractal dimension, goodness of fit, and DE values obtained by three different methods. According to Figure 17, the estimated fractal dimensions are identical to those of Brodatz and FBM. The original consecutive integer method produces the highest fractal dimension, the divisor method produces the smallest fractal dimension, and the improved consecutive integer method produces values in between. In terms of goodness of fit, the improved method outperforms the original consecutive integer method. Unlike Brodatz and FBM, the divisor technique's goodness of fit for Aerials images is almost equivalent to that of the improved consecutive integer approach. The distance error results are similar to the FBM and Brodatz results, with the divisor method generating the highest error, followed by the original consecutive integer method; the improved consecutive integer method produces the lowest error.
The Aerials images are pictures of natural scenes, which are also not ideal fractals. Compared to Figures 14 and 16 in the preceding section, the fractal dimension and distance error results of the Aerials images (Figures 17 and 19) are extremely similar to the computed results of Brodatz images. This also validates the conclusion of the previous section. It indicates that, for Aerials images, the improved method still achieves lower distance errors than the divisor method and the original consecutive integer method. However, unlike the results for Brodatz images, the goodness of fit values obtained by the divisor method are not intermediate between the two consecutive integer methods. We indicated in Section 5.1 that the divisor method requires eight points to fit an LLS line, whereas the consecutive integer method takes 255 points, including the 8 points of the divisor method and the other 247 data points. The absence of 247 points in the divisor method makes the calculation results "distorted". The effect of the "distortion" varies depending on the image type. Comparing Figures 7 and 8, it can be seen that the aerial image has different characteristics from the texture image. The Brodatz texture image is more homogeneous and has basically the same features in all image regions, but the Aerials image usually appears with some conspicuous objects. Because there are fewer s values in the divisor technique, the fitting results will be considerably influenced if the image's conspicuous objects influence certain s values. Because the consecutive integer method uses a large number of s values, some abnormal scatter points do not affect the results. As a result, in Figure 18, the divisor method's goodness of fit curve seems to oscillate around the curve of the improved consecutive integer method. Of course, further research is required to confirm this. In summary, the improved consecutive integer method outperforms the divisor method and the original continuous integer method for computing the fractal dimension of Aerials images.

Applying Improved Grid Selection Strategies to Other DBC Methods
From the above analysis based on the original DBC method, it is found that the improved grid selection strategy, i.e., the improved consecutive integer method, can obtain better accuracy of fractal dimension calculation. For further validation, we tested the effectiveness of the improved strategy based on the three methods of Long'2013DBC [24], Lai'2016DBC [26], and Liu'2021DBC [29]. The image database used for the calculation is the same as that described in Section 5.1. The results of the three methods (with/without the improved strategy) are calculated separately based on the FBM images. The obtained results of fractal dimension, goodness of fit, and distance error are shown in Tables 6-8.
From the fractal dimension results in Table 6, we can find that the Long'2013 method with the improved strategy obtains a higher fractal dimension than the original method. FDs of Lai'2016 and Liu'2021 methods show a fractal dimension decrease after applying the improved strategy. From the results in Tables 7 and 8, it can be found that for all three methods, the improved strategy improves the goodness of fit and reduces the distance error compared to the original methods.  The strategy of integer r used in the Long'2013 method leads to fewer values of s involved in the calculation. This is very similar to the divisor method. Therefore, it is easy to produce the problem of small fractal dimension, large goodness of fit, and large distance error. However, because the weight method is used in Long's method, the distance error obtained is not much different from that of the consecutive integer method even though the above problems exist. After applying the "consecutive integer method + weighting method" strategy, Long's method could involve more s values and fully use the grayscale variation of the original image, resulting in a larger fractal dimension, higher goodness of fit, and smaller distance error.
In both Lai'2016 and Liu'2021 methods, the original consecutive integer method is used as the grid selection strategy. Thus, even though various optimizations have been performed in their methods, the problems caused by the original consecutive integer method still exist. Based on the analysis of previous sections, the original consecutive integer method has the problem of undercounting boxes. The larger the value of s, the higher the percentage of undercounting boxes. After applying the improved strategy, it is equivalent to raising the vertical coordinates of the points corresponding to large s values. This change reduces the excessive fractal dimension while increasing the goodness of fit and reducing the distance error. The fractal dimension, goodness of fit, and distance error results for Lai'2016 and Liu'2021 (Tables 6-8) confirm this conclusion.
In summary, the grid selection strategy based on the "consecutive integer method + weight method" can improve the goodness of fit, reduce the distance error, and obtain more accurate fractal dimension results for DBC methods. However, from the results in this section, although the grid selection strategy improves the computational accuracy compared to the original method, the calculated results of the three methods are very different. This is because many parameters affect the fractal dimension, and each method uses different optimization strategies for other parameters, resulting in many deviations in the results.

Conclusions
This study proposes an improved consecutive integer method to address the current difficulties of distorted calculation results and huge distance errors caused by the inappropriate choice of grid size s in the differential box-counting method. The synthetic FBM images, Brodatz database, and Aerials database are then used to evaluate and compare the effects of three grid size selection methods, namely the consecutive integer method, the divisor method, and the improved consecutive integer method, on the accuracy of fractal dimension calculation. Except for the different grid selections, all other parameters are identical to the DBC approaches. The results indicate that the original consecutive integer method ignores the boxes along the edges, resulting in fewer boxes to calculate. This reduces the goodness of fit and increases the distance error, distorting the estimated fractal dimension.
Although the divisor method has a small computation and can partition the whole image completely, the number of s values is too small. Then, a large amount of effective information is ignored compared with the consecutive integer method, resulting in a severe distortion of fractal dimension results and more significant distance error, and the fitting goodness is not stable. The improved strategy solves the undercounting problem of the original consecutive integer method by retaining the edge regions of images. Furthermore, the method can partition the image completely like the divisor method. Thus, the improved consecutive integer method obtains a smaller distance error than the original consecutive integer method and the divisor method, improving the accuracy of fractal dimension calculation.  Maximum gray level over a grid g min Minimum gray level over a grid n r Total number of boxes at scale r, required to cover the rough surface over (i, j)th grid N r Total number of boxes at scale r, required to cover the rough surface of an image r The scale of a square grid for an image h Height of a box γ Correlation coefficient R 2 Goodness of fit b The slope of LLS fitted line (for evaluation of FBM images) ER Equal ratio. Indicates that s is a divisor of the image size CI Consecutive integer. Indicates that the value of s is all integer from s min to s max . CW The "consecutive integer + weight method" strategy OCI Optimized consecutive integer. Indicates that the division of the xy plane is based on the improved consecutive integer method.