Signal Filters¶
Filters that return a bool depending on if the inputted image passes a set of tests.
-
psbeam.filters.
moments_within_range
(M=None, image=None, contour=None, max_m0=1000000.0, min_m0=10)¶ Checks that the image moments are within the specified range.
Parameters: - M (dict, optional) – Moments of the image.
- image (np.ndarray, optional) – Image to check the moments for.
- contour (np.ndarray, optional) – Beam contours
- max_m0 (float, optional) – Maximum value that the zeroth moment can have
- min_m0 (float, optional) – Minimum value that the zeroth moment can have
Returns: within_range – Whether the moments were within the specified range.
Return type: bool
Raises: MomentOutOfRange
– If the zeroth moment is out of the specified range.
-
psbeam.filters.
contour_area_filter
(image, kernel=(9, 9), resize=1.0, uint_mode='scale', min_area=100, min_area_factor=3, factor=3, **kwargs)¶ Checks that a contour can be returned for two thresholds of the image, a mean threshold and an otsu threshold.
Parameters: - image (np.ndarray) – Image to check for contours.
- kernel (tuple, optional) – Kernel to use when gaussian blurring.
- resize (float, optional) – How much to resize the image by before doing any calculations.
- uint_mode (str, optional) – Conversion mode to use when converting to uint8.
- min_area (float, optional) – Minimum area of the otsu thresholded beam.
- factor (float) – Factor to pass to the mean threshold.
- min_area_factor (float) – The amount to scale down the area for comparison with the mean threshold contour area.
Returns: passes – True if the image passes the check, False if it does not
Return type: bool
-
psbeam.filters.
full_filter
(image, centroids_ad, resize=1.0, kernel=(13, 13), n_opening=1, cent_atol=2, thresh_m00_min=10, thresh_m00_max=10000000.0, thresh_similarity=0.067, thresh_mode='otsu')¶ Runs the full pipeline which includes:
- Checks if there is beam by obtaining an image contour
- Checks the sum of all pixels is above and below a threshold
- Checking if the computed centroid is close to the adplugin centroid
- Checks that the beam is above the threshold of similarity
Parameters: - image (np.ndarray) – Image to process
- centroids_ad (tuple) – Centroids obtained from the areadetector stats plugin.
- resize (float, optional) – Resize the image before performing any processing.
- kernel (tuple, optional) – Size of kernel to use when running the gaussian filter.
- n_opening (int, optional) – Number of times to perform an erosion, followed by the same number of dilations.
- cent_atol (float, optional) – Absolute tolerance to use when comparing AD’s and OpenCV’s centroids.
- thresh_m00_min (float, optional) – Lower threshold for the sum of pixels in the image.
- thresh_m00_max (float, optional) – Upper threshold for the sum of pixels in the image.
- thresh_similarity (float, optional) – Upper threshold for beam similarity score (0.0 is perfectly circular).
- thresh_mode (str, optional) –
Thresholding mode to use. For extended documentation see preprocessing.threshold_image. Valid modes are:
[‘mean’, ‘top’, ‘bottom’, ‘adaptive’, ‘otsu’]
Returns: Bool indicating whether the image passed the tests.
Return type: bool