回答編集履歴
1
実行結果を追記
test
CHANGED
@@ -1,3 +1,41 @@
|
|
1
1
|
3.x用のコードは以下`code-python3`になりますので、以下で試してみてはいかがでしょうか?
|
2
2
|
|
3
3
|
[https://github.com/joelgrus/data-science-from-scratch/blob/master/code-python3/clustering.py](https://github.com/joelgrus/data-science-from-scratch/blob/master/code-python3/clustering.py)
|
4
|
+
|
5
|
+
|
6
|
+
|
7
|
+
#### 実行結果について
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
まず、Warningについては
|
12
|
+
|
13
|
+
[Runtime Warning overflow encountered in ubyte_scalars]((https://stackoverflow.com/questions/32927821/runtime-warning-overflow-encountered-in-ubyte-scalars)
|
14
|
+
|
15
|
+
> You shouldn't worry about these, what they are essentially telling you is that the range for the uint_8 (unsigned integer) type defined by numpy and generally used for image files, has simply exceeded its acceptable range.
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
と回答あるので、実行結果には影響ないと思われます。
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
また、コードの実行結果についてですが
|
26
|
+
|
27
|
+
`img = mpimg.imread(path_to_png_file)`を`img = mpimg.imread(input_file)`と修正し
|
28
|
+
|
29
|
+
[lena](https://www.cosy.sbg.ac.at/~pmeerw/Watermarking/lena.html)のカラー画像を64x64に縮小したpng画像で試したところ、以下のような結果を得られました。正常に動作しているようです。
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
![イメージ説明](244f29f4fd388a3ac39391689b4073d3.png)
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
コード詳細は私には説明できませんが、画像サイズや色数などに制限はないでしょうか?
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
|