I am writing a code to rotate all the images in a dataset and saving the rotated images in the same folder of the dataset. But after saving most of the saved images are black. Why this problem is occurring and how to fix it? Here is the code I wrote.
path = r'Enhanced/train/NORMAL'
import os
import cv2 as cv
from skimage import transform
for dirName, subdirList, fileList, in os.walk(path):
for file in fileList:
full_file_path = os.path.join(dirName, file)
if file.endswith(".png"):
image = cv.imread(full_file_path, cv.IMREAD_GRAYSCALE)
# image rotation
transformed_image = transform.rotate(image, angle=45)
new_filename = file.split('.jpg')[0] +'rotation45.png'
path2 = r"Enhanced/train/NORMAL"
cv.imshow(new_filename, transformed_image)
cv.waitKey(1)
cv.imwrite(os.path.join(path2, new_filename), transformed_image)
cv.destroyAllWindows()