# Scratch Detection On Noisy Textured Surface

I wish to extract long thin scratches from the noisy background image.I have tried several ways such as stacking smoothed image with input image to remove some of the noisy background patch before applying blob detection filtering on those images to get the long thin scratch. However, overkill will happen due to the noisy background patches.

Any good suggestion or guidance on other things to try?

One approach would be to compute the Phase Only Transform (PHOT) of your image, i.e., set the magnitude of the discrete Fourier transform (DFT) to unity [1].

It is computed as follows. First compute the DFT of the input image: $$A(x,\,y) = \text{DFT}\left\{x,\,y\right\}=\sum_{j=0}^{N-1}\sum_{k=0}^{N-1}a(j,\,k)\cdot \text{exp}\left(\frac{-i2\pi}{N}\cdot(uj+vk)\right),$$

then compute the amplitude-normalized DFT: $$A_\text{PHOT}(x,\,y) = \frac{A(x,\,y)}{\left|A(x,\,y)\right|},\qquad(2)$$

and compute the inverse DFT: $$a_\text{PHOT}(x,\,y) = \sum_{j=0}^{N-1}\sum_{k=0}^{N-1}a_\text{PHOT}(j,\,k)\cdot \text{exp}\left(\frac{i2\pi}{N}\cdot(uj+vk)\right).$$

As described in [1], the process of normalizing the DFT magnitude in Eq. (2) removes regularities from the input image and makes sudden changes stand out. Basically, this is an alternative to the computation of the prediction error of an autoregressive (AR) model. By thresholding the PHOT, it may be possible to detect the desired artifacts in your images.

For me, the PHOT performed much better than computing the AR prediction error - however, your results may vary as my field of application was audio signal processing.

### References

[1] D. Aiger, H. Talbot, The Phase Only Transform for Unsupervised Surface Defect Detection, IEEE Computer Society Conference on Computer Vision and Pattern Recognition, 13-18 June 2019, San Francisco, CA, USA, DOI: 10.1109/CVPR.2010.5540198.