MCPcopy Create free account
hub / github.com/OpenGVLab/HumanBench / bgr2gray

Method bgr2gray

PATH/core/data/datasets/images/image_helper.py:82–96  ·  view source on GitHub ↗

Convert a BGR image to grayscale image. Args: img (ndarray): The input image. keepdim (bool): If False (by default), then return the grayscale image with 2 dims, otherwise 3 dims. Returns: ndarray: The converted grayscale image.

(img, keepdim=False)

Source from the content-addressed store, hash-verified

80
81 @staticmethod
82 def bgr2gray(img, keepdim=False):
83 """Convert a BGR image to grayscale image.
84
85 Args:
86 img (ndarray): The input image.
87 keepdim (bool): If False (by default), then return the grayscale image
88 with 2 dims, otherwise 3 dims.
89
90 Returns:
91 ndarray: The converted grayscale image.
92 """
93 out_img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
94 if keepdim:
95 out_img = out_img[..., None]
96 return out_img
97
98 @staticmethod
99 def gray2bgr(img):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected