Package to help analyze fracture patterns on broken glass plys.
Project description
Fracture Suite
This package helps identifying splinters on broken glass plys.
It performs several operations on the input image to enhance the visibility of scanned cracks and analyzes contours in the image. Filtering then helps to remove unwanted artifacts like dust speckles or glue residue. The remaining contours are then used to calculate the size (in px) as well as the round- and rough-ness of the splinter.
How it works
Several steps are necessary to analyze a fracture scan:
- Cropping of input image (optional)
- Analyze the image and find the biggest rectangular shape
- Perspective transform the image, so that the rectangle is filling the extents
- Preprocessing
- Gaussian Blur + (optional) Resize of the input image
- Adaptive Threshold
- Contour detection
- Find all contours on the preprocessed image
- Filter Contours, remove all:
- Whose perimeter is too small
- Whose area is way too large (25000px²)
- Create stencil with the found contours
- This helps to quickly remove all contours that lie within a bigger contour
- Draw all contours onto a new image (resulting image will display the cracks)
- Skeletonization #1
- Skeletonize the stencil to minimize the crack width to 1px wide lines
- Use Erode/Dilate (closing kernel) to connect gaps in contours (this will widen the 1px wide lines)
- Skeletonization #2
- Skeletonize the image again to retrieve the crack middle lines
- (enabled by default) Remove splinters, whose are is all black in the original image and fill those spaces
- Contour detection #2
- Now with minimal fuzziness, run the splinter detection again
- Create splinters from resulting contour list
A couple of outputs are saved to a directory next to the input image. These are:
- Contour plot of recognized splinters (you have to zoom in, contour thickness is 1px)
- Filled plot of splinters
- Figures
- Splinter size distribution
- Splinter relative share distribution
- Voronoi overview
- Fracture Intensity overlay
Installation
pip install fracsuite
Usage
Use the module directly
py -m fracsuite.splinters "path/to/image"
Create a script
from fracsuite.splinters.analyzer import Analyzer, AnalyzerConfig
image = r"Path/to/some/image.bmp"
config = AnalyzerConfig()
# size of cropped image (if cropping is needed)
config.cropsize = (4000,4000)
analyzer = Analyzer(image, config)
analyzer.plot()
analyzer.plot_area()
analyzer.plot_area_2()
CLI
options:
-h, --help show this help message and exit
General:
--displayplots Instruct the analyzer to display output plots.
--debug Sets a debug flag to display verbose output.
--exp-debug Sets an experimental debug flag to display verbose output.
-display-region DISPLAY_REGION DISPLAY_REGION DISPLAY_REGION DISPLAY_REGION
Region to display in debug outputs.
Image operations:
image The image to be processed.
-realsize REALSIZE REALSIZE
Real size of the input image.
-cropsize CROPSIZE CROPSIZE
Crop image size in pixels.
Preprocessor:
-gauss-size GAUSS_SIZE
Gaussian filter size
-gauss-sigma GAUSS_SIGMA
Gaussian filter sigma
-min-area MIN_AREA Minimum fragment area threshold [px²]
-max-area MAX_AREA Maximum fragment area threshold [px²]
-thresh-sens THRESH_SENS
Adaptive threshold sensitivity
-thresh-block {1,3,5,7,9,11,13,15,17,19,21}
Adaptive threshold block size
-resize-fac RESIZE_FAC
Image resize factor before adaptive th.
Postprocessor:
-skelclose-sz SKELCLOSE_SZ
Size for final skeleton close kernel.
-skelclose-amnt SKELCLOSE_AMNT
Iterations for final skeleton close kernel.
--skip-spot-elim Instruct the postprocessor to skip "dark-spot" removal.
-intensity-width INTENSITY_WIDTH
Pixel width for intensity calculation.
Output:
-out [OUT] Output directory path.
-plot-ext [{png,pdf,jpg,bmp}]
Plot file extension. Default: png.
-image-ext [{png,jpg,bmp}]
Image file extension. Default: png.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
fracsuite-0.1.10.tar.gz
(37.3 kB
view hashes)
Built Distribution
fracsuite-0.1.10-py3-none-any.whl
(40.1 kB
view hashes)
Close
Hashes for fracsuite-0.1.10-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e95c7ebf68f90ff7f8cd475812c3d86f25a7139736fc11a497aabe3efe4f5d91 |
|
MD5 | 0f0ed44e6711fd84c3f928e1865d9fd2 |
|
BLAKE2b-256 | 242090c1ee981e465687b80ff6fe9e69e177cd1cf21551953ca2f41efa2b109f |