回答編集履歴
1
実行結果を追記
answer
CHANGED
@@ -1,2 +1,20 @@
|
|
1
1
|
3.x用のコードは以下`code-python3`になりますので、以下で試してみてはいかがでしょうか?
|
2
|
-
[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)
|
2
|
+
[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)
|
3
|
+
|
4
|
+
#### 実行結果について
|
5
|
+
|
6
|
+
まず、Warningについては
|
7
|
+
[Runtime Warning overflow encountered in ubyte_scalars]((https://stackoverflow.com/questions/32927821/runtime-warning-overflow-encountered-in-ubyte-scalars)
|
8
|
+
> 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.
|
9
|
+
|
10
|
+
と回答あるので、実行結果には影響ないと思われます。
|
11
|
+
|
12
|
+
|
13
|
+
また、コードの実行結果についてですが
|
14
|
+
`img = mpimg.imread(path_to_png_file)`を`img = mpimg.imread(input_file)`と修正し
|
15
|
+
[lena](https://www.cosy.sbg.ac.at/~pmeerw/Watermarking/lena.html)のカラー画像を64x64に縮小したpng画像で試したところ、以下のような結果を得られました。正常に動作しているようです。
|
16
|
+
|
17
|
+

|
18
|
+
|
19
|
+
コード詳細は私には説明できませんが、画像サイズや色数などに制限はないでしょうか?
|
20
|
+
|