I am trying to do data augmentation on sentinel 2. Everything else is working and the only problem I have is the output I am getting is only one band when the input image has 10 bands. I also tried with rasterio but the results are still only one band.
Why am I only getting one band as output?
from keras.preprocessing.image import ImageDataGenerator, array_to_img, img_to_array, load_img
# import io
from PIL import Image
from osgeo import gdal
import cv2
import rasterio
import numpy as np
from osgeo import gdal
datagen = ImageDataGenerator(
rotation_range=180,
width_shift_range=0,
height_shift_range=0,
shear_range=0,
zoom_range=0.5,
horizontal_flip=True,
vertical_flip = True,
fill_mode='nearest') #Also try nearest, constant, reflect, wrap
a = 1
while True:
ds = gdal.Open("E:\\opencv\\12.tif")
myarray = np.array(ds.ReadAsArray())
""Rasterio code""
#fp = r'E:\\opencv\\12.tif'
#img = rasterio.open(fp)
#img = img.read()
""""""
x = img_to_array(myarray)
x = x.reshape(x.shape + (1, ))
i = 1
for batch in datagen.flow(x, batch_size=16,
save_to_dir='E:\\opencv\\',
save_prefix= a,
save_format='tif'):
i += 1
if i > 1:
break
a += 1
if a > 3:
break