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)
| 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): |
nothing calls this directly
no outgoing calls
no test coverage detected