Chapter/Index: Introduction | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z | Appendix
| This Python script (code) performs a defect detection analysis by comparing two grayscale images—page35a.png (the test image) and page35b.png (the reference). It uses the Structural Similarity Index (SSIM) to compute a pixel-wise similarity map, which is then inverted to emphasize dissimilar regions. After normalizing and thresholding the resulting difference map, the script identifies and outlines all defective areas using contours, drawing them in blue. The most significant defect (based on contour area) is highlighted in green to distinguish it from smaller discrepancies. Finally, the annotated result is saved as defect_highlighted.png and displayed. This method effectively locates and visualizes the most structurally inconsistent region, making it especially useful for pattern-based defect inspection in repetitive image arrays. To make detection more sensitive (detect smaller differences):
To make detection less sensitive (ignore small differences):
|