packing_defect.core.cluster
Classes
Connected-component analysis for defect masks. |
- class packing_defect.core.cluster.DefectClustering[source]
Bases:
objectConnected-component analysis for defect masks.
Methods operate on 2D integer masks, typically produced from
DefectGrid. Non-zero entries are treated as part of a defect.- static cluster_sizes_from_mask(matrix: ndarray) list[int][source]
Return sizes of all connected components in a binary mask.
- static defect_size(matrices, nbins, bin_max, fname, prob=True)[source]
Compute and write a histogram of defect cluster sizes.
- Parameters:
matrices (sequence[np.ndarray]) – Iterable of 2D binary masks (1 for defect cell, 0 otherwise).
nbins (int) – Number of histogram bins.
bin_max (float) – Upper edge of the histogram range.
fname (str) – Output path to write two-column text: center, value.
prob (bool, optional) – If True, normalize counts to probabilities.