Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Python中调整图像大小而不丢失字母质量_Python_Python 3.x_Python Imaging Library - Fatal编程技术网

在Python中调整图像大小而不丢失字母质量

在Python中调整图像大小而不丢失字母质量,python,python-3.x,python-imaging-library,Python,Python 3.x,Python Imaging Library,我试着用下面的代码来调整我的图片大小,但我失去了太多的质量,我甚至不能清楚地阅读字母。首先,我从一个字符串创建了一张图片,它的质量非常好 handoverNote = str.encode(handoverNote) with open("test.png", "wb") as f: f.write(codecs.decode(handoverNote, "base64")) image = Image.open("test.png") image.thumbnail((500, 50

我试着用下面的代码来调整我的图片大小,但我失去了太多的质量,我甚至不能清楚地阅读字母。首先,我从一个字符串创建了一张图片,它的质量非常好

handoverNote = str.encode(handoverNote)
with open("test.png", "wb") as f:
    f.write(codecs.decode(handoverNote, "base64"))

image = Image.open("test.png")
image.thumbnail((500, 500), Image.ANTIALIAS)
image.save("test2.png", quality=95)
但调整大小后,图像看起来不可读或几乎无法识别,如本例所示:

这是原始图像,我没有调整大小

我做错了什么?是因为我使用PNG吗


你能把原始图像也贴出来吗?也许是你的缩略图转换,试试不贴
image=image.resize((500500),image.ANTIALIAS)
I使用image=image.resize((200200),image.ANTIALIAS),但它看起来仍然很糟糕。我上传了原始版本,这是一个类似于取消拜耳模式的问题。通常,下采样(比如2倍)很容易,因为只需取每个2x2盒的平均值。但是,如果你有小写字母或其他感兴趣的特征,在大小上与那个盒子相当,那显然是不够好的。现在,您必须添加边缘感知,这意味着基于频率的过滤。这是一个有趣的主题。你能把原始图像也贴出来吗?也许是你的缩略图转换,试着不用它
image=image.resize((500500),image.ANTIALIAS)
I使用image=image.resize((200200),image.ANTIALIAS),但它看起来仍然很糟糕。我上传了原始版本,这是一个类似于取消拜耳模式的问题。通常,下采样(比如2倍)很容易,因为只需取每个2x2盒的平均值。但是,如果你有小写字母或其他感兴趣的特征,在大小上与那个盒子相当,那显然是不够好的。现在,您必须添加边缘感知,这意味着基于频率的过滤。这是一个有趣的话题。