gbvision.utils.thresholds package

Submodules

gbvision.utils.thresholds.color_threshold module

class gbvision.utils.thresholds.color_threshold.ColorThreshold(pixel_range: Union[Tuple[Tuple[Union[int, float], Union[int, float]], Tuple[Union[int, float], Union[int, float]], Tuple[Union[int, float], Union[int, float]]], Tuple[Union[int, float], Union[int, float]]], thresh_type='BGR')[source]

Bases: gbvision.utils.thresholds.threshold.Threshold

a class that represents a function that maps from an image to a binary image where 255 states that the pixel at the original image was in a range represented by the threshold object and 0 states the pixel was out of the range for example: Threshold([[200, 255], [0, 50], [0, 50]], ‘RGB’) the above threshold represents a relatively red pixel. when an image is filtered by it, every pixel that is relatively red will be given the value 255, and every pixel that isn’t will be given the value of 0

Parameters:
THRESH_TYPE_BGR = 'BGR'
THRESH_TYPE_GRAY = 'GRAY'
THRESH_TYPE_HLS = 'HLS'
THRESH_TYPE_HSV = 'HSV'
THRESH_TYPE_LAB = 'LAB'
THRESH_TYPE_LUV = 'LUV'
THRESH_TYPE_RGB = 'RGB'
THRESH_TYPE_XYZ = 'XYZ'
THRESH_TYPE_YUV = 'YUV'
gbvision.utils.thresholds.color_threshold.bgr_threshold(frame: Optional[numpy.ndarray], params: Tuple[Tuple[Union[int, float], Union[int, float]], Tuple[Union[int, float], Union[int, float]], Tuple[Union[int, float], Union[int, float]]])[source]
gbvision.utils.thresholds.color_threshold.gray_threshold(frame: Optional[numpy.ndarray], params: Tuple[Union[int, float], Union[int, float]])[source]

gbvision.utils.thresholds.threshold module

class gbvision.utils.thresholds.threshold.Threshold[source]

Bases: gbvision.utils.pipeline.PipeLine, abc.ABC

An abstract class that represents a function that maps from an image to a binary image where 255 states that the pixel at the original image was in a range represented by the threshold object and 0 states the pixel was out of the range

For example: ColorThreshold([[200, 255], [0, 50], [0, 50]], ‘RGB’)

The above threshold represents a relatively red pixel. when an image is filtered by it, every pixel that is relatively red will be given the value 255, and every pixel that isn’t will be given the value of 0

threshold(frame: Optional[numpy.ndarray]) → Optional[numpy.ndarray][source]

Runs this threshold on the given frame, and returns the resulting binary frame

Parameters:frame – The frame to run the threshold on
Returns:The binary frame, with the type being uint8. each pixel should either be 0 (not captured in the threshold) or 1 (cuptured in the threshold)
class gbvision.utils.thresholds.threshold.ThresholdGroup(binary_mask: Callable[[Optional[numpy.ndarray], Optional[numpy.ndarray]], Optional[numpy.ndarray]], *thresholds)[source]

Bases: gbvision.utils.thresholds.threshold.Threshold

A class that constructs a threshold filter out of several threshold filters and a binary mask function for example, use of the function on two thresholds with the binary function “bitwise_or” will result in a filter that outputs 255 for a pixel if it is in either one of the threshold’s range using the “bitwise_and” function will output 255 for a pixel only if it is in both the threshold’s range

Parameters:
  • thresholds – all the thresholds to join in the threshold group
  • binary_mask – a binary function that maps from a pair of binary images to a single binary image default value is cv2.bitwise_or

Module contents