Proc. of the 2017 IEEE Region 10 Conference (TENCON), Malaysia, November 5-8, 2017 Rust Detection using Image Processing via Matlab Julianne Alyson I. Diaz, Manuel I. Ligeralde Jr., John Anthony C. Jose, Argel A. Bandala Electronics and Communications Engineering Department De La Salle University Manila, Philippines julianne_diaz@dlsu.edu.ph Abstract -This research attempted to create a program that is capable of detecting rust through image processing. Image processing is known for the manipulation of image through quantizing the image itself in matrix form. Through this quantization, it gives opportunity to not only manipulate the image but also detect a particular subject on the image as well, such as rust. Through setting the threshold values and the use of edge detection and segmentation, rusts on the image can be detected. The threshold values will set the parameters and characterize what a rust is. The edge detection will check for the sudden changes of colors in the images. The segmentation will then determine the colors on the image. The results in the edge detection and segmentation will be integrated to determine the rust on the image. The results of the program yield a success rate 90% in detecting rust on images with rusts and did not obtain any errors on images with no rust. Keywords—Rust detection; thresholding; edge detection; segmentation; MATLAB I. INTRODUCTION The most abundant material in present day’s manufactured equipment, construction, pipes, machinery and etc. are steel and other alloys, which provides good support and sturdy structural design. Although steel and other alloys are known to react to oxygen and moisture due to their iron content, which forms a red oxide. The chemical composition of a rust is a compound named iron oxide. For prevention and maintenance purposes, rust detection is significant, as it is a sign of material’s deterioration. In the early days, detecting rust was done manually through a per piece or per section human inspection. That method is tedious and prone to human errors due to missed detection during inspection, which can lead to further damage of the material. With the presence of technology, detecting rust can become easier and more accurate due to digitized methods. In this paper, object detection like in [1-3] will be used in detecting rust. The process requires segmented images of the material to be processed in MATLAB for rust detection. Advantages of using image processing are the accuracy of reading, cost effective, faster, objective and consistent. The aim of this study is to implement rust detection through image processing and yield at least an 80% success rate. II. RELATED WORKS Steel and other alloys are combinations of different metallic elements that makes a durable material suitable for construction of different structures and various products, such as machineries. Although with its iron content it has become prone to rust when exposed to oxygen. These rusts now make the material vulnerable to corrosion, in which can later lead to the degradation of the material. Thus, early detection of these rust on the surface is important before it reaches deeper parts of the material and cause further damage. Unforeseen damages such as these can lead to machinery failure and structural integrity failure. Thus, this must be prevented as early as possible. An example of this incident is the oil spill in CA Chevron oil refinery plant last 2012. The investigation later on tracked the problem rooted on the corrosion of the pipes, in which could have been prevented of rust on the pipes were detected earlier [4]. A cost-effective implementation is by deploying a serpentine robot on a steel pipe [5]. Image processing is a developing technology with vast application. One particular application of image processing is rust detection. Many studies has been done to tackle image processing based rust detection such as the study done by Sharma V. & Tejinder T.,the techniques used for rust detection were discussed. The first step in doing rust detection using image processing is through obtaining the data, which is obtaining the image of the object. In this study the data was obtained automatically through a camera fixed on the object that is being monitored. The next step proposed is the detection of rust. In this step it was proposed that different rust detection techniques should be done, which might be due to different types and levels of rust. It was emphasized that different techniques have different steps to follow. The third step is calculating the area of rust on the image. This is to determine whether the object is either partially rusted or totally rusted. An additional feature was added in their study, which to determine on what maintenance should be done to the object [6]. In a study conducted by Huwang, N., Son, H., Kim, C., & Kim, *C, a rust detection program was created to detect rust and determine the on which area the robot is going to do the grit-blasting procedure. The first step in their program is the conversion of the RGB colors to HSI. This procedure was done to eliminate the probability of false reading. After such, the image of the rust will then undergo to the process of classification, to determine what technique or process to be used in analyzing the rust. The study offered six categories of techniques. The purpose of these techniques is to classify whether the pixel belongs to the background or the rusted area. In these techniques, the neighboring pixels were also checked for comparison on whether is a rust or part of the background. Although, this study still needs further testing on its rust detection part, since its more on a comparative study 978-1-5090-1134-6/17/$31.00 ©2017 IEEE 1327 Authorized licensed use limited to: ULAKBIM UASL - YILDIZ TEKNIK UNIVERSITESI. Downloaded on April 05,2023 at 12:51:40 UTC from IEEE Xplore. Restrictions apply. Proc. of the 2017 IEEE Region 10 Conference (TENCON), Malaysia, November 5-8, 2017 on the rust detection area and the focus is less on the analysis of each techniques proposed [7]. In a study conducted by Ghanta, S., Karp, T., & Lee, S., which introduces a method for rust detection using wavelet transform. The algorithm proposed consists of two stages, training and detection. The program was tested in rust and non-rust images. Potential areas within the image are determined using cross-correlation technique. Detection is mainly based on the fact that rust lack the color of blue thus the cross correlation is don using a blue plane. Additionally, the percentage of rust detected within the image is calculated. The program used classified 33 out of the 55 rust images into rust images and classified all the non-rust image as non-rust images. The program was able to detect rust in images but was limited by the rust size and the image size. The algorithm used was ineffective in detecting rust sizes of 8x8 blocks and in images with sizes greater than 256x256 pixels. Additionally, the program used was only 52% effective in classifying images with rust [1]. On the image processing developed by Sharifzadeh, M., Alirezaee, S., Amirfattahi, R., & Sadri, S., the image processing was attempted to be used on detecting defects on steel, such as holes, scratches, coil break and rust. On the algorithm that the researchers used on the rust detection, segmentation was done initially. In this section, the thresholding of the values was done. The thresholding binarizes the image and uses entropy techniques for execution. The entropy that was used in this study is the Shannon’s Entropy. After binarizing, the values of the ones and zeros were compared the range of values obtained in thresholding. The success rate that was achieved in this study was 90.3% on the rust detection algorithm. Although in this study a different software was used in processing the program and obtaining sufficient samples has become a problem to the researchers [8]. To resolve the limitation of image processing base rust detection, a study was done by Zaidan, B.B. et al., which introduced a method for rust detection with the use the concept of texture analysis. The method proposed uses texture segmentation with the aid of edge detection. The rough texture of the corrosion areas are detected using the combination of texture detection and edge detection. The images are classified as either corroded or not. The method was effective but application is limited to textured objects. Furthermore, precision of the method used was not specified [9]. III. THEORETICAL AND DESIGN CONSIDERATION In the design consideration of the image processing to detect rust, thresholding, edge detection, and segmentation was done. Fig 3.1: Thresholding Flowchart A. Tresholding Thresholding is the process converting the image into binary. Thus, it was used to quantize the image. In the process, the image was set as its input. The program then assigns binary values to each pixel of the image. The assigning of binary bits to the matrix of the image is dependent on the intensity of the background in the image, in which was needed for edge detection. Although there were other Thresholding techniques available, such as multi-level and histogram, they were not utilized due to their inefficiency in adapting. Adapting in this context, it is the program’s ability to detect the intensities precisely. The thresholding used is adaptable to different images and does not need calibration. In this research, adaptive method was used, where every pixel were evaluated and correlated with its surrounding pixels. This is similar to Otsu method where the value of the binary assigned to the pixel is dependent on the range of values of rust set and its surrounding pixels. The advantage of the method used is its high adaptability to changes in pixel values without losing precision. B. Edge Detection The edge detection on the other hand is the process of recognizing the frame or boundary of an object in image processing. A function for edge detection was created in the study. The output of the Threshold function was set to be the input of the Edge detection function. Edge detection works through checking the neighboring pixels if their range of value is within the acceptable values in their cluster. Given with that 1328 Authorized licensed use limited to: ULAKBIM UASL - YILDIZ TEKNIK UNIVERSITESI. Downloaded on April 05,2023 at 12:51:40 UTC from IEEE Xplore. Restrictions apply. Proc. of the 2017 IEEE Region 10 Conference (TENCON), Malaysia, November 5-8, 2017 Fig 3.1: Edge Detection Flowchart statement, importance to the adaptability of the threshold value is important as it is the basis of the edge detection. In edge detection, the difference in the intensity of light on the image was used to detect the frame of the object. From that, the image was clustered depending on the intensity of the colors in the image. Note that in this process, the program does not determine what color it is isolating. The purpose of the function is to prevent errors in the detection of rust through to the boundaries that it sets. Edge detection can be done in many ways. Examples are Prewitt and Sobel operators. Both methods were based on convolving an image with a filter on both vertical and horizontal directions. The difference between the two is the filter convoluted with the image. Both are powerful tools for edge detection but the precision of the methods decreases in high-frequency variations in images. The edge detection function created in this research is based on Shannon entropy which correlates the image pixel per pixel together with the adjacent pixels, which offers a much precise analysis without being affected by high-frequency variation present in the images used for testing. The novelty of the method is that it relies on probability. It calculates the probability of a pixel being an edge pixel based on the pixel surrounding it. C. Segmentation Segmentation in image processing is the process of dividing the image into pieces. The objective of this segmentation is to Fig 3.3: Segmentation Flowhchart classify the image better and determine the areas that are important of useful in the data that is needed [10]. There are different types of image segmentation, but in the program created, color segmentation was done. Color segmentation is the process of isolating different colors to cluster them. A function was created that counts the certain number of a particular color, in this case red, through the matrix of the image. This function acts as the filtering process of the program, whose output now determines the final percentage of rusts in the object. IV. ALGORITHM The rust detection method used is based on image segmentation and image thresholding. The image are segregated into red, green, and blue channels. The red channel image is stored into a 2D matrix. The grayscale of the image is then acquired. Thresholding is then applied to the image. The thresholding method used is Shannon entropy method. From the method, the threshold value is acquired and is used to binarize the image. After the binarization, the images are classified into non-rust images and rust images. For rust images, the black pixel represents the rusted area and by computing the number of pixels and dividing it to the total number of pixels, the approximate percentage of rust is detected. 1329 Authorized licensed use limited to: ULAKBIM UASL - YILDIZ TEKNIK UNIVERSITESI. Downloaded on April 05,2023 at 12:51:40 UTC from IEEE Xplore. Restrictions apply. Proc. of the 2017 IEEE Region 10 Conference (TENCON), Malaysia, November 5-8, 2017 Fig 4.1: Rusted Images Fig 4.1: Block diagram of the rust detection program V. SIMULATION AND DISCUSSION OF RESULTS The program created is tested by inputting 20 image of rust images and another 20 non-rust image. The images are fed one by one onto the program which then detects whether it is non-rust or rust images. The image was taken using an Iphone camera which has an 8megapixel resolution. The images were taken randomly and categorized by the researchers as either rust images or non-rust images. The part where rust was present within the image are then cropped and adjusted to a size of 560x560 so that the image can be processed easier in MATLAB. A. Rust images testing The test was done by uploading 20 images of rust into the program. Shown in Fig 4.1 are the images that were fed to the program for testing the accuracy of the program. To test the program’s success rate in detect rust, the images of rusted surfaces were inputted in the program. There were three characteristics of the image inputted that the researchers considered and delimited in the scope of this study. First, the image taken must be of a metal surface. Second, the images must show a non-uniform coloring. Lastly, the discoloration of the image must be yellowish or reddish. To summarize the three characteristics, the image data used are only limited to flat metallic surfaces showing signs of red or yellow rust. A total of three runs were done to test the accuracy of the program in detecting rust on images of rust. Shown below is the actual value of the image where 1 represents a rusted image and 0 a non-rust image. The first column represents the numbering of the sample images. The second row represents the true value of the input image. All true values are 1 for this testing because all images tested are rust images. The third to fifth column represents the three runs done to test the images. Fig 4.2: Non-rust Images Out of 20 rust images, the program was able to determine 19 as rusted images. From that data, the computed accuracy of the rust detection program is 90%. Source of error was encountered when majority of the image is composed of rust. B. Non-rust images testing The program is fed with 20 images that does not contain rust. Shown below are the images that were fed to the program for testing the accuracy of the program. The non-rust images taken, are random. To be considered a non-rust image, the image must fail in meeting at least one of the three parameters set in considering rust image. The images taken were not limited to metallic surfaces. To test the accuracy of the program, non-metallic images were also included in the sample. The purpose of this testing is to test the reliability of the program and to make sure that it does not detect rust on surfaces that does not contain rust. Similar to the previous testing, a total of three runs were done to test the accuracy of the program in detecting whether the inputted images were rust images See Table 4.2. When the program recognizes rust on the image, the program’s output states that it is a rust image. Hence, it yields an output of 1 on the table below. On the other hand, if the program does not recognize rust on the image, the program’s output will state that it is a non-rust image. Thus, an output of 0 were obtained on the table below. In this testing, the true values for all images tested are 0, since all of the input images are nonrusted images. Out of 20 rust images, the program was able to classify 20 as non-rusted images. From that data, the computed accuracy of the rust detection program is 100%. n = 40 Actual: Non-rust Actual: Rust TABLE 4.3: Confusion Matrix Predicted(Non-rust) Predicted(Rust) 20 0 2 18 22 18 20 20 1330 Authorized licensed use limited to: ULAKBIM UASL - YILDIZ TEKNIK UNIVERSITESI. Downloaded on April 05,2023 at 12:51:40 UTC from IEEE Xplore. Restrictions apply. Proc. of the 2017 IEEE Region 10 Conference (TENCON), Malaysia, November 5-8, 2017 TABLE 4.4: Values Computed Parameter Computed value: Accuracy Misclassification Rate: True Positive rate False Positive rate Specificity Prevalence F1 Score 95% 5% 90% 0% 100% 50% 0.9524 C. Confusion Matrix A confusion matrix was done to solve for the accuracy, misclassification rate, true positive rate, false positive rate, specificity, and the prevalence. VI. CONCLUSION The project aimed to create a rust detection program with a 90% success rate. To execute the whole program, three functions were created, namely the thresholding, edge, and segmentation. These methods set the parameters of a rust and detects them through their matrix values. The result of the program yields a 90% success rate in detecting rust on images and 100% in detecting non-rust images. Although in this project the researchers encountered errors in the program when the rust on the image is greater than the background or that the whole image is rust alone. Since in the program, the basis whether an object is rusted or not depends heavily on the color of the image. There were no other inputs in the program other than the image alone. In future studies, it is recommended that researchers add more sample images to further test the accuracy of the program. Moreover, given the accuracy requirement of the topic, it is recommended that researchers try other methods of image processing based rust detection. Lastly, it is recommended that future works tackle the rust detection wherein input is a live video feed instead of images. [4] J. Susong. (2016). Why Should I Care About Carbon Steel Pipe Inspection?. From http://www.industrialaccess.com/blog/carbon -steel-pipeinspection/, January 26, 2017 [5] A. Bandala, and J. W. F. Orillo. “Development of a Flexible Serpentine Robot for Disaster Surveillance Operations,” Jurnal Teknologi. vol. 78, 2016, pp 91-95. [6] A. Sharma, and T. Tejinder, “Techniques for Detection of Rusting of Metals using Image Processing: A Survey,” International Journal of Emerging Science and Engineering, vol. 1, 2013, pp 60-62. [7] N. Huwang, H. Son, C. Kim, and *C. Kim, “Rust Surface Area Determination of Steel Bridge Component for Robotic Grit-Blast Machine,” In 2013 Proceedings of the 30th ISARC, Montréal, 2013, pp 1148-1156. [8] M. Sharifzadeh, S. Alirezaee, R. Amirfattahi and S. Sadri, "Detection of steel defect using the image processing algorithms," 2008 IEEE International Multitopic Conference, Karachi, 2008, pp. 125-127. [9] B. B. Zaidan, A. A. Zaidan, H. O. Alanazi, and R. Alnaqeib, “Towards Corrosion Detection System,” International Journal of Computer Science Issues, vol. 7, pp. 33-36, 2010. [10] A. Taneja, P. Ranjan and A. Ujjlayan, "A performance study of image segmentation techniques," 2015 4th International Conference on Reliability, Infocom Technologies and Optimization (ICRITO) (Trends and Future Directions), Noida, 2015, pp. 1-6. REFERENCES: [1] S. Ghanta, T. Karp, and S. Lee, “Wavelet domain detection of rust in steel bridge images,” In 2011 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP). https://doi.org/10.1109/icassp.2011 .5946583 [2] J. P. N. Cruz, M. L. Dimaala, L. G. L. Francisco, E. J. S. Franco, A. A. Bandala and E. P. Dadios, "Object recognition and detection by shape and color pattern recognition utilizing Artificial Neural Networks," 2013 International Conference of Information and Communication Technology (ICoICT), Bandung, 2013, pp. 140-144. [3] A. Uy, R. Bedruz, A. Quiros, J. Jose, E. Dadios, A. Bandala, E. Sybingco, and O. Sapang, "Automated vehicle class and color profiling system based on fuzzy logic," 5th International Conference on Information and Communication Technology (ICoIC7), Melaka, 2017, pp. 1-6. 1331 Authorized licensed use limited to: ULAKBIM UASL - YILDIZ TEKNIK UNIVERSITESI. Downloaded on April 05,2023 at 12:51:40 UTC from IEEE Xplore. Restrictions apply.