回答編集履歴

2

修正

2018/09/19 17:44

投稿

tiitoi
tiitoi

スコア21956

test CHANGED
@@ -11,6 +11,10 @@
11
11
  * to_file(): ファイルに保存する。
12
12
 
13
13
  * to_array(): 形状が (Height, Width, 3) の numpy 配列として取得する。
14
+
15
+
16
+
17
+ font_path はフォント名でもよいみたいです。
14
18
 
15
19
 
16
20
 

1

追記

2018/09/19 17:44

投稿

tiitoi
tiitoi

スコア21956

test CHANGED
@@ -1,6 +1,6 @@
1
1
  matplotlib の imshow() で表示する場合、画像は描画領域の大きさに合わせてリサイズされますので、原寸大で表示したい場合は向いていません。
2
2
 
3
- (うまく dpi を計算すれば、表示できないこともないですが、少し面倒です。)
3
+ (うまく dpi を計算すれば、原寸大で表示できないこともないですが、少し面倒です。)
4
4
 
5
5
 
6
6
 
@@ -63,3 +63,55 @@
63
63
 
64
64
 
65
65
  [wordcloud の API リファレンス](http://amueller.github.io/word_cloud/index.html)
66
+
67
+
68
+
69
+ ## ウィンドウに表示したい場合
70
+
71
+
72
+
73
+ ```
74
+
75
+ import cv2
76
+
77
+
78
+
79
+ cv2.namedWindow('word cloud', cv2.WINDOW_NORMAL)
80
+
81
+ cv2.imshow('word cloud', img)
82
+
83
+ cv2.waitKey(0)
84
+
85
+ cv2.destroyAllWindows()
86
+
87
+ ```
88
+
89
+
90
+
91
+ ## IPython Notebook に表示したい場合
92
+
93
+
94
+
95
+ ```python
96
+
97
+ import IPython.display
98
+
99
+ from io import BytesIO
100
+
101
+ from PIL import Image
102
+
103
+
104
+
105
+ def show_array(img):
106
+
107
+ stream = BytesIO()
108
+
109
+ Image.fromarray(img).save(stream, 'png')
110
+
111
+ IPython.display.display(IPython.display.Image(data=stream.getvalue()))
112
+
113
+
114
+
115
+ show_array(img)
116
+
117
+ ```