detect_cracks
- detect_cracks(images, theta=0, crack_width=10, ar=2, bandwidth=1, n_stds=3, min_size=5, threshold='yen', sensitivity=0)[source]
Crack detection based on a simpler version of the algorithm by J.A. Glud. All images are treated separately.
- Parameters
- images: ImageStack, list
Image stack or list of grayscale images on which the crack detection will be performed. This algorithm treats each image separately as no image influences the results of the other images.
- theta: float
Angle of the cracks in respect to a horizontal line in degrees
- crack_width: int
The approximate width of an average crack in pixel. This determines the width of the detected features.
- ar: float
The aspect ratio of the gabor kernel. Since cracks are a lot longer than wide a longer gabor kernel will automatically detect cracks easier and artifacts are filtered out better. A too large aspect ratio will result in an big kernel which slows down the computation. Default: 2
- bandwidth: float, optional
The bandwidth of the gabor filter, Default: 1
- n_stds: int, optional
The size of the gabor kernel in standard deviations. A smaller kernel is faster but also less accurate. Default: 3
- min_size: int, optional
The minimal number of pixels a crack can be. Cracks under this size will not get counted. Default: 5
- threshold: str
Method of determining the threshold between foreground and background. Choose between ‘otsu’ or ‘yen’. Generally, yen is not as sensitive as otsu. For blurry images with lots of noise yen is nearly always better than otsu.
- sensitivity: float, optional
Adds or subtracts x percent of the input image range to the Otsu-threshold. E.g. sensitivity=-10 will lower the threshold to determine foreground by 10 percent of the input image range. For crack detection with bad image quality or lots of artefacts it can be helpful to lower the sensitivity to avoid too much false detections.
- Returns
- rho_c: float
Crack density [1/px]
- cracks: np.ndarray
Array with the coordinates of the crack with the following structure: ([[x0, y0],[x1,y1], […]]) where x0 and y0 are the starting coordinates and x1, y1 the end of one crack. Each crack is represented by a 2x2 array stacked into a bigger array (x,2,2).
- rho_th: float
A measure how much of the area of the input image is detected as foreground. If the gabor filter can not distinguish between cracks with very little space in between the crack detection will break down and lead to false results. If this value is high but the crack density is low, this is an indicator that the crack detection does not work with the given input parameters and the input image.