Convert rgba to rgb for all images in dataset

Hello! How do you create a loop to strip down the 4th colour channel in rgba images to rgb for the whole dataset?

  img, name=None

I tried using the above cell to pre-process images but it yields a transformation for only one image at a time and the resultant shape is not saved for image processing.

You can define the number of channels inside decoding function like tf.image.decode_image(image, channels=3) and use it when you are creating a dataset. It will convert 4-channel images into 3-channel tensors.

1 Like