## 2 Materials and Methods
### Mathematical Definition and Application of Bhattacharyya Distance
#### 2.6.2 Quantifying Image Similarity through Bhattacharyya Distance in Histogram Analysis  
In image processing and computer vision, quantifying the similarity between two images is a fundamental task with applications ranging from image retrieval to medical imaging. Traditional metrics like Euclidean distance or Manhattan distance often fall short when dealing with high-dimensional spaces or various types of noise in images. Bhattacharyya distance, a measure based on probability distributions, offers a robust and nuanced metric for image similarity. This paper employs Bhattacharyya distance as a means to evaluate the likeness between histograms of different images. The Bhattacharyya distance is a metric used for measuring the similarity between two probability distributions. In this context, the two probability distributions are the histograms of two grayscale images. The mathematical definition of the Bhattacharyya distance, denoted as DB (P, Q), is \(-\)ln(sum(\(i\)) sqrt (\(pi\times qi\))), where P = {p1, p2,..., pn} and  
Figure 11: Image 0—The Original State of the Wall. Figure 12: Color BGR and its scale. Q = {q1, q2, \(\ldots\), qn} are the two probability distributions, and n is the number of bins in the distributions. Step 1: Compute the Square Root of the Product for Each Dimension (or Bin). In this step, the corresponding elements _pi_ and _qi_ from P and Q, respectively, are multiplied and then the square root is calculated: sqrt (_pi_\(\times\)_qi_). This operation is done for all \(i\) values. Step 2: Summation of the Square Root Products. Next, sum up all of the square root products computed in Step 1: sum(_i_) sqrt (_pi_\(\times\)_qi_). Step 3: Take the Negative Natural Logarithm. Finally, take the natural logarithm (In) of this sum and then negate it: \(-\)ln(sum(_i_) sqrt (_pi_\(\times\)_qi_)). This gives the Bhattacharyya distance, DB (P, Q). Physical or Statistical Interpretation. The Bhattacharyya distance measures the extent of overlap between the two distributions. When both distributions are identical (P = Q), the Bhattacharyya distance is zero. When there is no overlap, it tends towards infinity. The distance has the following properties:  
* When DB = 0, P and Q are identical distributions. * The larger the value of DB, the less similar P and Q are. To make the ratio more intuitive, it is often termed as the \"Bhattacharyya Coefficient\" or \"Bhattacharyya Distance\" in the field of image processing. For a more intuitive description, the term \"Image Similarity Score\" is chosen, scaled between 0 and 1 or 0 and 100. The conversion formula is: Similarity Score = (1 - DB) \(\times\) 100. Thus, a higher \"Similarity Index\" or \"Similarity Score\" would intuitively indicate that the two images are more alike. In histograms, a \"bin\" is a term for a data range used for classifying a set of data points. Specifically, in the context of image processing, a histogram describes the distribution of pixel values in an image. A grayscale image histogram usually has 256 bins, corresponding to 256 different levels of gray (ranging from 0 to 255). Each bin contains the number of pixels within a certain range of gray values. For instance, in a 256-bin grayscale image histogram, the first bin might represent the number of pixels with a gray value of 0, the second bin might represent the number of pixels with a gray value of 1, and so on, up to the last bin which represents the number of pixels with a gray value of 255. In the histogram, the _x_-axis represents the bins (in this case, the levels of gray), and the _y_-axis represents either the number of pixels in each bin or the probability density of that pixel value when normalized. \[normalizedvalue=maxvalue-minvalueoriginalvalue-minvalue\times(beta-alpha)+alpha\]  
In this formula, \"originalvalue\" refers to the original value of a specific bin in the histogram, while \"minvalue\" and \"maxvalue\" represent the minimum and maximum values within the histogram.