gpt4 book ai didi

Mathematica 中的图像导出和导入不连贯

转载 作者:行者123 更新时间:2023-12-01 12:16:09 26 4
gpt4 key购买 nike

大家新年快乐!

我在 Mathematica 11 中运行以下代码,但无法理解输出。 b 和 b1 的大小相同,以字符形式显示时看起来也相同,但 Mathematica 对它们的看法不同。您能给我一些建议,说明为什么会这样吗?

a = Import["ExampleData/rose.gif"];
b = ExportString[a, "PNG"];
c = ImportString[b, "PNG"];
Export["D:/flower.txt", b];
b1 = Import["D:/flower.txt"];
ByteCount /@ {b, b1}
b == b1

最好的问候!

最佳答案

要导出为文本,您需要字符串形式的 b。转换为 PNG Base64 有效。

a = Import["ExampleData/rose.gif"];
b = ExportString[a, {"Base64", "PNG"}]
c = ImportString[b, {"Base64", "PNG"}]
Export["D:/flower.txt", b, "String"];
b1 = Import["D:/flower.txt", "String"];
ByteCount /@ {b, b1}
b == b1
{41016, 41016}
True

新年快乐!

关于Mathematica 中的图像导出和导入不连贯,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48042542/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com