I am trying to do image processing on my dataset. The dataset is divided into 346 folders according to the following manner
What I want to do is loop over the 346. Enter each folder and process the images within Process the image in regards to changing it to gray scale, resize and normalize (these three steps should be applied to my whole dataset. I want to keep the same folders/files names and dont change it when I run my data processing.
The folder/ files name are as follows video_0001/ 00000.png, 00001.png, ..... video_0002/ 00000.png, 00001.png,
The number of files vary according to each folder and the last video_0346
P.S when I try to normalize the images I get black images when dividing by 255
I am still new to python. Here's what I was able to accomplish
I appreciate your help
Img_height = 512
Img_width = 512
srcdir = "C:\\Users\\Desktop\\_dataset"
for subdir, dirs, files in os.walk(srcdir):
for i in range(346):
for file in os.listdir(subdir):
print(file )
img = cv2.imread(os.path.join(srcdir,file))
print("image", img)
gray_img = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
Image_sample_resized = resize(gray_img, (height, width))
plt.imshow( Image_sample_resized, cmap = "gray")
i = i+1