torch_concepts.data.utils.colorize¶
- colorize(images, colors)[source]¶
Colorize grayscale images based on specified colors.
Converts grayscale images to RGB by assigning the intensity to one of three color channels (red, green, or blue).
- Parameters:
images – Tensor of shape (N, H, W) containing grayscale images.
colors – Tensor of shape (N) containing color labels (0=red, 1=green, 2=blue).
- Returns:
Colored images of shape (N, 3, H, W).
- Return type:
Tensor
- Raises:
AssertionError – If colors contain values other than 0, 1, or 2.