본문 바로가기
프로그래밍/CellGAN

Printing out the list of files in the directory

by seahoon98 2021. 8. 25.
import os

path = "/home/noh/noh/CellGAN/DCGAN/data_gan/par1/img_align_par1"

files = os.listdir(path)

for i, f in enumerate(files):
	if i == 0:
    	print(type(f))
    print(f)

 

import cv2
import os

path = "/home/noh/noh/CellGAN/DCGAN/data_gan/par1_img_align_par1"

files = os.listdir(path)

for i, f in enumerate(files):
	img = cv2.imread(path + f, flags=cv2.IMREAD_UNCHANGED)
    
    if i == 0:
    	print(type(img))
        print(img.shape)
    
	img_rotate_90_clockwise = cv2.rotate(img, cv2.ROTATE_90_CLOCKWISE)
    cv2.imwrite('../data_gan/par1/img_align_par1/' + f + '_cv_rotate_90_clockwise.jpg', img_rotate_90_clockwise)
    
    img_rotate_90_counterclockwise = cv2.rotate(img, cv2.ROTATE_90_COUNTERCLOCKWISE)
    cv2.imwrite('../data_gan/par1/img_align_par1/' + f + '_cv_rotate_90_counterclockwise.jpg', img_rotate_90_counterclockwise)
    
    img_rotate_180 = cv2.rotate(img, cv2.ROTATE_180)
    cv2.imwrite('../data_gan/par1/img_align_par1/' + f + '_cv_rotate_180_clockwise.jpg', img_rotate_180)

'프로그래밍 > CellGAN' 카테고리의 다른 글

Installing OpenCV on Darwin  (0) 2021.09.03
Collecting the information of software and hardware environment  (0) 2021.08.24
Segmentation error  (0) 2021.08.18