# Computer-Vision-Based Product Quality Inspection and Novel Counting System
## 3 Methods and Result
### Image-Based Product Quality Inspection and Feature Matching Techniques
#### 3.1.2 Defect Detection Using a Combined SSIM, PSNR, and MSE Evaluation
\begin{table}
\begin{tabular}{c c} \hline \hline
**Metric** & **Formula** \\ \hline \multirow{4}{*}{SSIM} & \(\frac{\left(2\mu_{\text{x}},\mu_{\text{y}}+C_{\text{i}}\right)\left(2\sigma_{ \text{y}},+C_{\text{j}}\right)}{\left(\mu_{\text{x}}^{2}+\mu_{\text{y}}^{2}+C_{ \text{i}}\right)\left(\sigma_{\text{z}}^{2}+\sigma_{\text{z}}^{2}+C_{\text{z}}\right)}\) \\  & \(\mu_{\text{x}}\) and \(\mu_{\text{y}}^{\text{i}}\): The mean brightness values of the two images \\ \multirow{4}{*}{SSIM} & \(\alpha_{\text{x}}^{2}\) and \(\alpha_{\text{y}}^{2}\): The variance of each image \\ \multirow{4}{*}{SSIM} & \(\alpha_{\text{y}}\): The covariance between the two images \\ \multirow{4}{*}{SSIM} & \(\frac{1}{\text{m}}\sum\limits_{\text{i}=1}^{\text{m}}\left[\text{I}_{\text{ I}}(\text{i},\text{j})-\text{I}_{\text{2}}(\text{i},\text{j})\right]^{2}\) \\  & \(\text{I}_{\text{I}}(\text{i},\text{j})\) and \(\text{I}_{\text{2}}(\text{i},\text{j})\): The pixel values at the i,j coordinates of the two images \\ \multirow{4}{*}{PSNR} & \(10\text{log}_{10}\left(\frac{\text{MAX}_{\text{I}}^{2}}{\text{MSE}}\right)\) \\  & MAX\({}_{\text{I}}\): The maximum possible pixel value in the image \\ \multirow{4}{*}{MSE: The mean squared error between the two images} \\ \cline{2-2}  & \(10\text{log}_{10}\left(\frac{\text{MAX}_{\text{I}}^{2}}{\text{MSE}}\right)\) \\ \cline{2-2}  & MAX\({}_{\text{I}}\): The maximum possible pixel value in the image \\ \multirow{4}{*}{MSE: The mean squared error between the two images} \\ \cline{2-2}  & \(10\text{log}_{10}\left(\frac{\text{MAX}_{\text{I}}^{2}}{\text{MSE}}\right)\) \\ \cline{2-2}  & MAX\({}_{\text{I}}\): The maximum possible pixel value in the image \\ \multirow{4}{*}{MSE: The mean squared error between the two images} \\ \cline{2-2}  & \(10\text{log}_{10}\left(\frac{\text{MAX}_{\text{I}}^{2}}{\text{MSE}}\right)\) \\ \cline{2-2}  & MAX\({}_{\text{I}}\): The maximum possible pixel value in the image \\ \multirow{4}{*}{MSE: The mean squared error between the two images} \\ \cline{2-2}  & \(10\text{log}_{10}\left(\frac{\text{MAX}_{\text{I}}^{2}}{\text{MSE}}\right)\) \\ \cline{2-2}  & MAX\({}_{\text{I}}\): The maximum possible pixel value in the image \\ \multirow{4}{*}{MSE: The mean squared error between the two images} \\ \cline{2-2}  & \(10\text{log}_{10}\left(\frac{\text{MAX}_{\text{I}}^{2}}{\text{MSE}}\right)\) \\ \cline{2-2}  & MAX\({}_{\text{I}}\): The maximum possible pixel value in the image \\ \multirow{4}{*}{MSE: The mean squared error between the two images} \\ \cline{2-2}  & \(10\text{log}_{10}\left(\frac{\text{MAX}_{\text{I}}^{2}}{\text{MSE}}\right)\) \\ \cline{2-2}  & MAX\({}_{\text{I}}\): The maximum possible pixel value in the image \\ \multirow{4}{*}{MSE: The mean squared error between the two images} \\ \cline{2-2}  & MAX\({}_{\text{I}}\): The mean squared error between the two images \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Formulas and descriptions for SSIM, MSE, and PSNR Metrics. Figure 6: This figure shows the difference images for products A and B, along with the numerical results of SSIM, PSNR, and MSE derived from the difference image analysis. similarity based on these standards. For example, in manufacturing processes where defect detection is critical, even minor defects may significantly impact results. Thus, an SSIM value of 0.95 or higher could indicate an acceptable product, and a PSNR value of 40 dB or higher could suggest good quality [42]. In the case of MSE, a lower value signifies fewer differences between the two images. Therefore, to ensure consistent interpretation within \(S_{\text{combined}}\), the inverse of MSE is used in calculations. This approach allows for a more intuitive interpretation, where a higher \(S_{\text{combined}}\) score indicates greater similarity between the images.