3

このようなグレースケール画像を作成しました

def create_new_image(size, luminance):
    width, height = size
    black_frame = int(luminance) * np.ones((width, height, 1), dtype=np.uint8)
    return black_frame

輝度は [0, 255] の要素です

imageioを使用して画像を保存しました

def save_image(image, output_path):
    imageio.imwrite(output_path, image)

は/valid_path/img.jpg のoutput_pathようなものです

ここで、グレースケール イメージをロードし直します。

img = imageio.imread(file, format ='jpg')

しかし、私が得るのは構文エラーです。

raise SyntaxError("not a JPEG file")
  File "<string>", line None
SyntaxError: not a JPEG file

形式を指定しないと、別のエラーが発生します。

    "Could not find a format to read the specified file in %s mode" % modename
ValueError: Could not find a format to read the specified file in single-image mode

なんで?ありがとう

4

4 に答える 4