小编Blo*_*dyD的帖子

PIL和OpenCV的resize有什么区别

我遇到了以下问题:这两个库的调整大小函数的行为不同。这是一个小测试:

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)

python opencv image-resizing python-imaging-library

8
推荐指数
0
解决办法
3781
查看次数

如何解析 freedict 文件(*.dict 和 *.index)

我正在寻找免费的翻译词典。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++ 也可以)来了解如何处理这些文件。

python java translation language-translation

7
推荐指数
1
解决办法
1532
查看次数