import os
import glob
from scipy.misc import imread
from PIL import Image
class NpyGenerator:
def __init__(self, directory):
if not os.path.isdir(directory):
raise ValueError('The argument is not a valid directory')
directory = os.path.join(directory, '')
self.directory = directory
def convert(self):
# Here convert loop through all the files in the directory and convert it to NpyFile
filelist = glob.glob(self.directory + '*_intensity.ppm')
print("The number of files detected = ", len(filelist))
for intensityFile in filelist:
phaseFile = intensityFile.replace("_intensity", "_phase")
inten_img = Image.open(intensityFile)
phase_img = Image.open(phaseFile)
if __name__ == '__main__':
directory_1 = 'D:/save/Rotifiers'
npyGen = NpyGenerator(directory_1)
npyGen.convert()
Я получаю ошибку:
Исключение: ValueError Слишком много цветов для полосы: 65535
Я хочу знать, есть ли способ исправить эту ошибку
Python Версия: 3.7.