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 !

Link_file.py 854 Bytes
Newer Older
1 2 3
import cv2
import os

SoleneDc's avatar
SoleneDc committed
4
def valid_spectrums(path):
5
    ok_files = []
SoleneDc's avatar
SoleneDc committed
6 7 8 9 10 11 12 13 14 15 16 17 18 19
    for file in os.listdir(path):
        if str(file)[-4:] == '.jpg':
            print(file)
            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 27
    for file in os.listdir(path):
        if file not in ok_files:
            print('removing', file, '....')
            os.remove(path + "/" + file)
    print(ok_files)

print(valid_spectrums('spectrumImages2005'))
28