Ce serveur Gitlab sera éteint le 30 juin 2020, pensez à migrer vos projets vers les serveurs gitlab-research.centralesupelec.fr et gitlab-student.centralesupelec.fr !

valid_spectrums.py 861 Bytes
Newer Older
1 2 3
import cv2
import os

SoleneDc's avatar
SoleneDc committed
4 5
def valid_spectrums(year):
    path = f'./spectrumImages/spectrumImages{year}'
6
    ok_files = []
SoleneDc's avatar
SoleneDc committed
7 8 9 10 11 12 13 14 15 16 17 18 19
    for file in os.listdir(path):
        if str(file)[-4:] == '.jpg':
            img = cv2.imread('./'+ path + '/' + file, 1)
            image = cv2.cvtColor(img, cv2.COLOR_BGR2LAB)
            length, width, lab = image.shape
            colors = []
            for i in range(width):
                tuple = (image[0][i][0], image[0][i][1], image[0][i][2])
                if tuple not in colors:
                    colors += [tuple]
                if len(colors) >= 10:
                    ok_files += [file]
                    break
20

SoleneDc's avatar
SoleneDc committed
21 22 23 24 25 26
    for file in os.listdir(path):
        if file not in ok_files:
            print('removing', file, '....')
            os.remove(path + "/" + file)
    print(ok_files)

SoleneDc's avatar
SoleneDc committed
27
# valid_spectrums(year)
28