<p>我创建了一个像这样的灰度图像</p>
<pre><code>def create_new_image(size, luminance):
width, height = size
black_frame = int(luminance) * np.ones((width, height, 1), dtype=np.uint8)
return black_frame
</code></pre>
<p>其中亮度是[0255]的元素</p>
<p>我已使用imageio保存图像</p>
<pre><code>def save_image(image, output_path):
imageio.imwrite(output_path, image)
</code></pre>
<p>其中<code>output_path</code>类似于/valid_path/img.jpg</p>
<p>现在我想重新加载我的灰度图像:</p>
<pre><code>img = imageio.imread(file, format ='jpg')
</code></pre>
<p>但我得到的是一个语法错误</p>
<pre><code>raise SyntaxError("not a JPEG file")
File "<string>", line None
SyntaxError: not a JPEG file
</code></pre>
<p>如果我没有指定格式,我会得到另一个错误</p>
<pre><code> "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
</code></pre>
<p>为什么??
谢谢</p>