albumentations
albumentations copied to clipboard
[FR] Grayscale to RGB
Hi, I'm using albumentations
for my project, but my image is GrayScale with shape [H, W]
but I need to use RGB image (3 channels or [H, W, 3]
) for training neural networks. Does the library provides any transformation to convert grayscale to RGB
, which is similar to tf.image.grayscale_to_rgb
? thank you
You can use cv2.cvtColor function from OpenCV to do this conversion. We have support for grayscale image augmentation for vast majority of transforms as well. You can also change the network to take the single channel input instead of taking three channels. So there are many options.
Пт, 8 окт. 2021 г. в 17:49, Tran N.M. Hoang @.***>:
Hi, I'm using albumentations for my project, but my image is GrayScale with shape [H, W] but I need to use RGB image (3 channels or [H, W, 3]) for training neural networks. Does the library provides any transformation to convert grayscale to RGB, which is similar to tf.image.grayscale_to_rgb? thank you
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/albumentations-team/albumentations/issues/1032, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAEB6YG4FCVXRKXGP7ROCE3UF4AHXANCNFSM5FTZIUVA .
@BloodAxe I understand your idea, but I think having a transformation like A.RepeatChannels(3)
or A.ToRGB
will be more easy-to-use rather than use cv2.cvtColor
outside A.Compose[...]
. Another question is how to scale image in range [0, 255] to [0, 1] like torchvision
's ToTensor
, but when I try albumentations.pytorch.transforms.ToTensorV2
, it just swaps channels from [H, W, C] to [C, H, W]. Does albumentations
have any equivalent transform?
A combination of [A.Normalize(), A.ToTensorV2()]
should do the job. Please refer to this notebook for an example.
Hi @BloodAxe, as I understand RGBShift is used for RGB image with shape [H, W, 3], does albumentations
has the equivalent transform for Grayscale image with shape [H, W]?
+1 for a ToRGB
transformation in the same vein as ToGray
Is this Issue still ongoing? Can I take it?
A transformation A.ToRGB
would be very usefull.
ToRGB added in #1323