Figure 2:
Image Processing in MATLAB for the defective area calculation.