# Concrete Crack Width Measurement Using a Laser Beam and Image Processing Algorithms
## 2 Materials and Methods
### Image Processing  
Image processing algorithms were applied to the captured images using Python. Libraries such as NumPy, and Matplotlib were used, but the main library used for the image processing was the Open Computer Vision (OpenCV) Library [30]. Before the crack width could be measured, it was necessary to pre-process the images. Image processing was carried out in two stages: (1) detecting the laser beam in the image and measuring its pixel diameter and (2) further image processing to segment cracks and measure their respective crack widths. The steps taken in carrying out these operations are briefly explained below:  
\begin{table}
\begin{tabular}{c c c} \hline \hline
**Images** & **Distance to Measuring Plane (mm)** & **Acquisition Device** \\ \hline \hline  
* Cropping: The images were cropped based on the region of interest, which was the area with the crack pattern that was to be measured. This was conducted to remove unnecessary information from the image that might affect the accuracy of measurements or lead to increased computation costs. * Laser beam detection and diameter measurement: In order to detect the presence of the laser beam in the images captured in the laboratory and in the field, a color filtering technique was used to isolate the color red in the image. The projected laser beam was red in color, as shown in Figure 3a. The color filtering approach allowed for red pixels in the image to be identified, as shown in Figure 3b. Hough Circle Transform, a technique commonly used in computer vision for the task of circle detection, was then applied to the filtered image. Hough Circle Transform is defined by Equation (6) and detects circles by searching for points \((x,y)\) in the image that satisfy Equation (6) for a given set of values of \((x_{0},\ y_{0})\) and \(r\). Figure 3c shows the detected circle and the center of the circle. \[(x-x_{0})^{2}+(y-y_{0})^{2}=r^{2}\] (6) The radius of the detected circle can then be used to determine the diameter of the circle in pixels, \(\varnothing_{px}\), which is inputted into Equation (5), enabling the conversion factor, \(\alpha_{c}\), to be calculated. This specific approach was chosen because the Hough Circle Transform is a well-established method for detecting circular shapes in images, and it has been widely used in various applications [8; 31; 32; 33]. Additionally, filtering out the color red was the most effective approach in eliminating the chance of other objects that might resemble circles from being falsely detected. * BGR to grayscale conversion: Images are made up of thousands of pixels, which are typically represented by three color components; red (\(R\)), green (\(G\)), and blue (\(B\)), commonly referred to as RGB. Each pixel has an \(R\), \(G\), and \(B\) value between 0 and 255. However, OpenCV reads images in BGR format. Converting the images from BGR to grayscale simplifies the representation of the pixels into a single value between 0 (black) and 255 (white). The BGR images are converted to grayscale by Equation (7). \[Gray\_image=0.114\ B+0.587\ G+0.299\ R\] (7)
* Edge detection and morphological operations: Some of the images containing text on the surface needed removal of the text, as it could easily be mistaken for a crack. The image's noise was reduced through image filters to improve the visibility of the cracks. These filters were chosen because they are effective in removing noise while preserving the edges of the cracks. The specific parameter values for the filters were chosen through trial and error to achieve the best results. The canny edge detection algorithm [34] was used to detect the cracks in the images by identifying gradient changes in the image intensity. After successful edge detection, morphological opening and closing operations were performed on the image to remove noise and fill small holes in the image. The initial kernel sizes used for each image differed and were chosen at random and fine-tuned until satisfactory results were achieved.