I am using Keras and ImageDataGenerator to augment the images in a directory and save it in another folder. After Augmentation the colour of the images turn bluish negativish and i dont want the colour to change.
Before
After
train_datagen = ImageDataGenerator(
rotation_range = 10,
shear_range = 0.15,
zoom_range = 0.15,
horizontal_flip = True,
brightness_range=[0.5,1.5])
train_batch_size = 32
val_batch_size = 32
import warnings
warnings.filterwarnings('ignore')
for img in imgs:
img=cv2.imread(train_path 'real' "\\" img)
x = img_to_array(img)
print(x.shape)
x = x.reshape((1,) x.shape)
print(x)
break
i = 0
for batch in train_datagen.flow(x, batch_size=1, save_to_dir =r'C:\Users\Shashwat Goyal\Desktop\augment', save_prefix ='people2', save_format='jpg'):
i =1
if i>4:
break
CodePudding user response:
You are using cv2 to read in your images. cv2 formats images as BGR versus RGB. To solve your problem use code
img=cv2.imread(train_path 'real' "\\" img)
x= cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
Note you do not need the code
x = img_to_array(img)
because a cv2 image is already an array