Get the grayscale for the input images. The channels of images should be in order BGR. Args: images (tensor): the input images for getting grayscale. Dimension is `num frames` x `channel` x `height` x `width`. Returns: img_gray (tensor): blended images, t
(images)
| 326 | |
| 327 | |
| 328 | def grayscale(images): |
| 329 | """ |
| 330 | Get the grayscale for the input images. The channels of images should be |
| 331 | in order BGR. |
| 332 | Args: |
| 333 | images (tensor): the input images for getting grayscale. Dimension is |
| 334 | `num frames` x `channel` x `height` x `width`. |
| 335 | Returns: |
| 336 | img_gray (tensor): blended images, the dimension is |
| 337 | `num frames` x `channel` x `height` x `width`. |
| 338 | """ |
| 339 | # R -> 0.299, G -> 0.587, B -> 0.114. |
| 340 | img_gray = torch.tensor(images) |
| 341 | gray_channel = ( |
| 342 | 0.299 * images[:, 2] + 0.587 * images[:, 1] + 0.114 * images[:, 0] |
| 343 | ) |
| 344 | img_gray[:, 0] = gray_channel |
| 345 | img_gray[:, 1] = gray_channel |
| 346 | img_gray[:, 2] = gray_channel |
| 347 | return img_gray |
| 348 | |
| 349 | |
| 350 | def color_jitter(images, img_brightness=0, img_contrast=0, img_saturation=0): |
no outgoing calls
no test coverage detected