SortBlur
- class tools.sort.sort_methods.SortBlur(arguments: Namespace, is_group: bool = False)
Bases:
SortMethodSort images by blur or blur-fft amount
- Parameters:
arguments (Namespace) – The command line arguments passed to the sort process
is_group (bool) – Set to
Trueif this class is going to be called exclusively for binning. Default:False
Attributes Summary
The name of each created bin, if they exist, otherwise an empty list
List of bins (list) containing the filenames belonging to the bin.
The loader that this sorter uses
List of sorted filenames for given sorter in a single list.
Methods Summary
binning()Create bins to split linearly from the lowest to the highest sample value
estimate_blur(image[, alignments])Estimate the amount of blur an image has with the variance of the Laplacian.
estimate_blur_fft(image[, alignments])Estimate the amount of blur a fft filtered image has.
score_image(filename, image, alignments)Score a single image for blur or blur-fft and add the result to
_resultsort()Sort by metric score.
Attributes Documentation
- bin_names
The name of each created bin, if they exist, otherwise an empty list
- binned
List of bins (list) containing the filenames belonging to the bin. The binning process is called when this property is first accessed
- loader_type
The loader that this sorter uses
- Type:
[“face”, “meta”, “all”]
- sorted_filelist
List of sorted filenames for given sorter in a single list. The sort process is called when this property is first accessed
Methods Documentation
- binning() list[list[str]]
Create bins to split linearly from the lowest to the highest sample value
- Return type:
List of bins of filenames
- estimate_blur(image: ndarray, alignments=None) float
Estimate the amount of blur an image has with the variance of the Laplacian. Normalize by pixel number to offset the effect of image size on pixel gradients & variance.
- Parameters:
image (ndarray) – The face image to calculate blur for
alignments – The metadata for the face image or
Noneif no metadata is available. If metadata is provided the face will be masked by the “components” mask prior to calculating blur. Default:None
- Return type:
The estimated blur score for the face
- estimate_blur_fft(image: np.ndarray, alignments: PNGAlignments | None = None) float
Estimate the amount of blur a fft filtered image has.
- Parameters:
image (np.ndarray) – Use Fourier Transform to analyze the frequency characteristics of the masked face using 2D Discrete Fourier Transform (DFT) filter to find the frequency domain. A mean value is assigned to the magnitude spectrum and returns a blur score. Adapted from https://www.pyimagesearch.com/2020/06/15/ opencv-fast-fourier-transform-fft-for-blur-detection-in-images-and-video-streams/
alignments (PNGAlignments | None) – The metadata for the face image or
Noneif no metadata is available. If metadata is provided the face will be masked by the “components” mask prior to calculating blur. Default:None
- Return type:
The estimated fft blur score for the face
- score_image(filename: str, image: np.ndarray | None, alignments: PNGAlignments | None) None
Score a single image for blur or blur-fft and add the result to
_result- Parameters:
filename (str) – The filename of the currently processing image
image (np.ndarray | None) – A face image loaded from disk
alignments (PNGAlignments | None) – The alignments dictionary for the aligned face or
None
- Return type:
None
- sort() None
Sort by metric score. Order in reverse for distance sort.
- Return type:
None
- binning() list[list[str]]
Create bins to split linearly from the lowest to the highest sample value
- Return type:
List of bins of filenames
- estimate_blur(image: ndarray, alignments=None) float
Estimate the amount of blur an image has with the variance of the Laplacian. Normalize by pixel number to offset the effect of image size on pixel gradients & variance.
- Parameters:
image (ndarray) – The face image to calculate blur for
alignments – The metadata for the face image or
Noneif no metadata is available. If metadata is provided the face will be masked by the “components” mask prior to calculating blur. Default:None
- Return type:
The estimated blur score for the face
- estimate_blur_fft(image: np.ndarray, alignments: PNGAlignments | None = None) float
Estimate the amount of blur a fft filtered image has.
- Parameters:
image (np.ndarray) – Use Fourier Transform to analyze the frequency characteristics of the masked face using 2D Discrete Fourier Transform (DFT) filter to find the frequency domain. A mean value is assigned to the magnitude spectrum and returns a blur score. Adapted from https://www.pyimagesearch.com/2020/06/15/ opencv-fast-fourier-transform-fft-for-blur-detection-in-images-and-video-streams/
alignments (PNGAlignments | None) – The metadata for the face image or
Noneif no metadata is available. If metadata is provided the face will be masked by the “components” mask prior to calculating blur. Default:None
- Return type:
The estimated fft blur score for the face
- score_image(filename: str, image: np.ndarray | None, alignments: PNGAlignments | None) None
Score a single image for blur or blur-fft and add the result to
_result- Parameters:
filename (str) – The filename of the currently processing image
image (np.ndarray | None) – A face image loaded from disk
alignments (PNGAlignments | None) – The alignments dictionary for the aligned face or
None
- Return type:
None
- sort() None
Sort by metric score. Order in reverse for distance sort.
- Return type:
None