# GAN-Based Image Dehazing for Intelligent Weld Shape Classification and Tracing Using Deep Learning
## 4 Results and Discussion
### Coordinate Transformation Using the Artificial Neural Network
To find the effective training parameters for the neural network, the dataset was analysed with different combinations of training-testing-validation ratios, namely, 70-20-10, 80-10-10 and 50-25-25 and training functions _trainscg_, _trainlm_, _trainmp_ and _traindx_. The learning rate for the neural network was 0.001 with _purelin_ as the activation function. The model was trained for 1000 epochs with a momentum coefficient of 0.9. The number of hidden layers for this analysis was chosen as 1, with 100 of hidden neurons to reduce the computation  
Figure 16: Coordinate transformation between camera and weld plate with respect to robot base. time and processing power. The corresponding _Mean Square Error (MSE)_, _Correlation Coefficient (R)_ value and _Root Mean Square Error (RMSE)_ values are noted and are plotted for various combinations, as shown in Figure 17,b. From the graph, the learning loss was comparatively less with the _trainscg_ function and with the 50-25-25 ratio. From the regression plot, it can be inferred that the R = 0.99981 value was higher for the 50-25-25 training-validation-testing ratio compared to other combinations, and also it had lower MSE and RMSE values of 230.6 and 15.18, respectively. Among the training functions, _trainscg_ performed better and training was faster than the other functions. Additionally, _trainlm_, _trainpr_ did not converge and training was stopped within 120 iterations out of 1000, leading to underfitting. _trainingdx_ was able to converge at 1000 epochs, but the RMSE and MSE values were huge, so it was not selected for training. The regression plot for training and testing for different combinations is illustrated in Figure 18. Finally, the contour pixels obtained from the contour detection algorithm were further converted to robot coordinates using the NN model, which was then sent to the robot via MATLAB for tracing the particular weld shape. Figure 17: **(a)** Graph of training functions vs. MSE and RMSE; **(b)** graph of different training–validation–testing ratios vs. MSE and RMSE. \[X_{i}(t)=\left\{x_{pi},\:y_{pi}\right\}\:\text{where}=1,2,\ldots\ldots,N(\text {\emph{size of input}}) \tag{24}\]0 _Cont._  
From the above ANN model hyperparameter analysis, it can be concluded that _trainscg_ with the 50-25-25 data split performed best for the weld seam coordinates. Furthermore, in this work, to validate the real-time testing, the robot coordinates for shape 2 and shape 5 were obtained after transformation from the ANN model, and these coordinates were sent to the robot for tracing. The robot tracing path for the abovementioned shapes is shown in \[X_{i}(t)=\left\{x_{pi},\:y_{pi}\right\}\:\text{where}=1,2,\ldots\ldots,N(\text {\emph{size of input}}) \tag{24}\]1 These trajectory points were recorded while the robot was tracing, and they were compared with the theoretical and actual trajectory points. \[X_{i}(t)=\left\{x_{pi},\:y_{pi}\right\}\:\text{where}=1,2,\ldots\ldots,N(\text {\emph{size of input}}) \tag{24}\]2 (**a**) Regression plot for 50-25-25; (**b**) regression plot for 70-10-20; (**c**) regression plot for 80-10-10. The theoretical trajectory for shape 2 (red line) was obtained using linear interpolation, whereas the reference trajectory (pink line) was obtained from the contour points. The robot-traced path is given by a blue line, and it can be inferred that for shape 2 the average tracking error between the reference and the actual path traced by the robot was 0.225 mm for \(X\) and 0.263 mm for the \(Y\) robot coordinates. The theoretical trajectory for shape 2 is as follows:  
\[X_{i}(t)=\left\{x_{pi},\:y_{pi}\right\}\:\text{where}=1,2,\ldots\ldots,N(\text {\emph{size of input}}) \tag{24}\]3  
Similarly, the theoretical trajectory (red dotted line) for shape 5 was obtained by using the spline function to fit all the points, and it can be seen that the variation between the reference (pink line) and the actual trajectory traced by the robot (blue line) was about 0.299 mm for \(X\) and 0.114 mm for the \(Y\) robot coordinates.