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.Thresholda 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: - pixel_range – the threshold parameters, as a list of integers in the shape of 3x2 for a color image and 1x2 for a gray image
- thresh_type – a string, the type of color encoding to transform the image before applying the range test binary filter can be selected from the given list: ‘BGR’: default opencv color encoding (no change) ‘RGB’: default opencv color encoding in reverse ‘HLS’: hue, luminous, saturation ‘HSV’: hue, saturation, value ‘LUV’: https://en.wikipedia.org/wiki/CIELUV ‘LAB’: https://en.wikipedia.org/wiki/CIELAB_color_space ‘YUV’: https://en.wikipedia.org/wiki/YUV ‘XYZ’: https://en.wikipedia.org/wiki/CIE_1931_color_space ‘GRAY’: grayscale images (single channel), image presented doesn’t have to be gray, the threshold will convert it
-
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.threshold module¶
-
class
gbvision.utils.thresholds.threshold.Threshold[source]¶ Bases:
gbvision.utils.pipeline.PipeLine,abc.ABCAn 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.ThresholdA 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