我遇到了以下问题:这两个库的调整大小函数的行为不同。这是一个小测试:
import numpy as np
import PIL
import cv2
from matplotlib import pyplot as plt
img = np.random.randn(10, 10, 3)
SIZE = (5, 5)
img -= img.min()
img /= img.max()
img = (img*255).astype(np.uint8)
# Display the initial image
plt.figure(figsize=(16,9))
plt.imshow(img)
plt.show()
plt.close()
# resize the image in two different ways
img_cv2 = cv2.resize(img, dsize=SIZE, interpolation=cv2.INTER_LINEAR)
img_pil = PIL.Image.fromarray(img).resize(SIZE, resample=PIL.Image.BILINEAR)
# get the difference image and normalize it
diff = np.abs(img_cv2.astype(np.float32) - img_pil)
diff /= diff.max() or 1
# display results …
Run Code Online (Sandbox Code Playgroud) 我正在寻找免费的翻译词典。Freedict ( freedict.org ) 提供了我需要但我不知道如何解析 *.index 和 *.dict 文件的文件。我也真的不知道,要谷歌什么,才能找到有关这些格式的有用信息。
*.index 文件如下所示:
00databasealphabet QdGI l
00databasedictfmt1121 B b
00databaseinfo c 5o
00databaseshort 6E u
00databaseurl 6y c
00databaseutf8 A B
a BHO M
a bad risc BHa u
a bag of nerves BII 2
[...]
Run Code Online (Sandbox Code Playgroud)
和 *.dict 文件:
[Lot of info stuff]
German-English FreeDict Dictionary ver. 0.3.4
Pipi machen /pi?pi?max?n/
to pee; to piss
(Aktien) zusammenlegen /aktsi??ntsu?zam?nle?g?n/
to merge (with)
[...]
Run Code Online (Sandbox Code Playgroud)
我很高兴看到一些示例项目(最好是在 python 中,但 java、c、c++ 也可以)来了解如何处理这些文件。