diff --git a/Dataset/test/akahara_0009.jpg b/Dataset/test/akahara_0009.jpg
new file mode 100755
index 00000000..b291186f
Binary files /dev/null and b/Dataset/test/akahara_0009.jpg differ
diff --git a/Dataset/test/akahara_0010.jpg b/Dataset/test/akahara_0010.jpg
new file mode 100755
index 00000000..e2e5b8f4
Binary files /dev/null and b/Dataset/test/akahara_0010.jpg differ
diff --git a/Dataset/test/akahara_0011.jpg b/Dataset/test/akahara_0011.jpg
new file mode 100755
index 00000000..ed1cad94
Binary files /dev/null and b/Dataset/test/akahara_0011.jpg differ
diff --git a/Dataset/test/madara_0009.jpg b/Dataset/test/madara_0009.jpg
new file mode 100755
index 00000000..add74ae0
Binary files /dev/null and b/Dataset/test/madara_0009.jpg differ
diff --git a/Dataset/test/madara_0010.jpg b/Dataset/test/madara_0010.jpg
new file mode 100755
index 00000000..544f4b36
Binary files /dev/null and b/Dataset/test/madara_0010.jpg differ
diff --git a/Dataset/test/madara_0011.jpg b/Dataset/test/madara_0011.jpg
new file mode 100755
index 00000000..c8766851
Binary files /dev/null and b/Dataset/test/madara_0011.jpg differ
diff --git a/Dataset/train/akahara_0004.jpg b/Dataset/train/akahara_0004.jpg
new file mode 100755
index 00000000..029490ae
Binary files /dev/null and b/Dataset/train/akahara_0004.jpg differ
diff --git a/Dataset/train/akahara_0005.jpg b/Dataset/train/akahara_0005.jpg
new file mode 100755
index 00000000..7591003b
Binary files /dev/null and b/Dataset/train/akahara_0005.jpg differ
diff --git a/Dataset/train/akahara_0007.jpg b/Dataset/train/akahara_0007.jpg
new file mode 100755
index 00000000..a2cce618
Binary files /dev/null and b/Dataset/train/akahara_0007.jpg differ
diff --git a/Dataset/train/madara_0001.jpg b/Dataset/train/madara_0001.jpg
new file mode 100755
index 00000000..cf9b8e5c
Binary files /dev/null and b/Dataset/train/madara_0001.jpg differ
diff --git a/Dataset/train/madara_0003.jpg b/Dataset/train/madara_0003.jpg
new file mode 100755
index 00000000..b00783ab
Binary files /dev/null and b/Dataset/train/madara_0003.jpg differ
diff --git a/Dataset/train/madara_0006.jpg b/Dataset/train/madara_0006.jpg
new file mode 100755
index 00000000..c375456b
Binary files /dev/null and b/Dataset/train/madara_0006.jpg differ
diff --git a/Question_01_10/README.md b/Question_01_10/README.md
index fe6c84c6..434acf09 100644
--- a/Question_01_10/README.md
+++ b/Question_01_10/README.md
@@ -14,11 +14,11 @@ img = cv2.imread("imori.jpg")
red = img[:, :, 2].copy()
```
-|入力 (imori.jpg)|出力 (answer_1.jpg)|
+|入力 (imori.jpg)|出力 (answers/answer_1.jpg)|
|:---:|:---:|
-|||
+|||
-答え >> [answer_1.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_01_10/answer_1.py)
+答え >> [answers/answer_1.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_01_10/answers/answer_1.py)
## Q.2. グレースケール化
@@ -27,11 +27,11 @@ red = img[:, :, 2].copy()
Y = 0.2126 R + 0.7152 G + 0.0722 B
-|入力 (imori.jpg)|出力 (answer_2.jpg)|
+|入力 (imori.jpg)|出力 (answers/answer_2.jpg)|
|:---:|:---:|
-|||
+|||
-答え >> [answer_2.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_01_10/answer_2.py)
+答え >> [answers/answer_2.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_01_10/answers/answer_2.py)
## Q.3. 二値化
@@ -44,11 +44,11 @@ y = { 0 (if y < 128)
255 (else)
```
-|入力 (imori.jpg)|出力 (answer_3.jpg)|
+|入力 (imori.jpg)|出力 (answers/answer_3.jpg)|
|:---:|:---:|
-|||
+|||
-答え >> [answer_3.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_01_10/answer_3.py)
+答え >> [answers/answer_3.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_01_10/answers/answer_3.py)
## Q.4. 大津の二値化
@@ -79,11 +79,11 @@ argmax_{t} X = argmax_{t} Sb^2
```
となる。すなわち、Sb^2 = w0 * w1 * (M0 - M1) ^2 が最大となる、閾値tを二値化の閾値とすれば良い。
-|入力 (imori.jpg)|出力 (th = 127) (answer_4.jpg)|
+|入力 (imori.jpg)|出力 (th = 127) (answers/answer_4.jpg)|
|:---:|:---:|
-|||
+|||
-答え >> [answer_4.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_01_10/answer_4.py)
+答え >> [answers/answer_4.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_01_10/answers/answer_4.py)
## Q.5. HSV変換
@@ -139,11 +139,11 @@ X = C (1 - |H' mod 2 - 1|)
```
ここでは色相Hを反転(180を加算)し、RGBに直し画像を表示せよ。
-|入力 (imori.jpg)|出力 (answer_5.jpg)|
+|入力 (imori.jpg)|出力 (answers/answer_5.jpg)|
|:---:|:---:|
-|||
+|||
-答え >> [answer_5.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_01_10/answer_5.py)
+答え >> [answers/answer_5.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_01_10/answers/answer_5.py)
## Q.6. 減色処理
@@ -157,11 +157,11 @@ val = { 32 ( 0 <= val < 64)
160 (128 <= val < 192)
224 (192 <= val < 256)
```
-|入力 (imori.jpg)|出力 (answer_6.jpg)|
+|入力 (imori.jpg)|出力 (answers/answer_6.jpg)|
|:---:|:---:|
-|||
+|||
-答え >> [answer_6.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_01_10/answer_6.py)
+答え >> [answers/answer_6.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_01_10/answers/answer_6.py)
## Q.7. 平均プーリング
@@ -177,20 +177,20 @@ v = 1/|R| * Sum_{i in R} v_i
ここではimori.jpgは128x128なので、8x8にグリッド分割し、平均プーリングせよ。
-|入力 (imori.jpg)|出力 (answer_7.jpg)|
+|入力 (imori.jpg)|出力 (answers/answer_7.jpg)|
|:---:|:---:|
-|||
+|||
-答え >> [answer_7.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_01_10/answer_7.py)
+答え >> [answers/answer_7.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_01_10/answers/answer_7.py)
## Q.8. Maxプーリング
ここでは平均値でなく最大値でプーリングせよ。
-|入力 (imori.jpg)|出力 (answer_8.jpg)|
+|入力 (imori.jpg)|出力 (answers/answer_8.jpg)|
|:---:|:---:|
-|||
+|||
-答え >> [answer_8.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_01_10/answer_8.py)
+答え >> [answers/answer_8.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_01_10/answers/answer_8.py)
## Q.9. ガウシアンフィルタ
@@ -214,11 +214,11 @@ K = 1/16 [ 2 4 2 ]
1 2 1
```
-|入力 (imori_noise.jpg)|出力 (answer_9.jpg)|
+|入力 (imori_noise.jpg)|出力 (answers/answer_9.jpg)|
|:---:|:---:|
-|||
+|||
-答え >> [answer_9.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_01_10/answer_9.py)
+答え >> [answers/answer_9.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_01_10/answers/answer_9.py)
## Q.10 メディアンフィルタ
@@ -229,8 +229,8 @@ K = 1/16 [ 2 4 2 ]
これは注目画素の3x3の領域内の、メディアン値(中央値)を出力するフィルタである。
これもゼロパディングせよ。
-|入力 (imori_noise.jpg)|出力 (answer_10.jpg)|
+|入力 (imori_noise.jpg)|出力 (answers/answer_10.jpg)|
|:---:|:---:|
-|||
+|||
-答え >> [answer_10.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_01_10/answer_10.py)
+答え >> [answers/answer_10.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_01_10/answers/answer_10.py)
diff --git a/Question_01_10/answer_1.jpg b/Question_01_10/answers/answer_1.jpg
similarity index 100%
rename from Question_01_10/answer_1.jpg
rename to Question_01_10/answers/answer_1.jpg
diff --git a/Question_01_10/answer_1.py b/Question_01_10/answers/answer_1.py
similarity index 100%
rename from Question_01_10/answer_1.py
rename to Question_01_10/answers/answer_1.py
diff --git a/Question_01_10/answer_10.jpg b/Question_01_10/answers/answer_10.jpg
similarity index 100%
rename from Question_01_10/answer_10.jpg
rename to Question_01_10/answers/answer_10.jpg
diff --git a/Question_01_10/answer_10.py b/Question_01_10/answers/answer_10.py
similarity index 100%
rename from Question_01_10/answer_10.py
rename to Question_01_10/answers/answer_10.py
diff --git a/Question_01_10/answer_2.jpg b/Question_01_10/answers/answer_2.jpg
similarity index 100%
rename from Question_01_10/answer_2.jpg
rename to Question_01_10/answers/answer_2.jpg
diff --git a/Question_01_10/answer_2.py b/Question_01_10/answers/answer_2.py
similarity index 100%
rename from Question_01_10/answer_2.py
rename to Question_01_10/answers/answer_2.py
diff --git a/Question_01_10/answer_3.jpg b/Question_01_10/answers/answer_3.jpg
similarity index 100%
rename from Question_01_10/answer_3.jpg
rename to Question_01_10/answers/answer_3.jpg
diff --git a/Question_01_10/answer_3.py b/Question_01_10/answers/answer_3.py
similarity index 100%
rename from Question_01_10/answer_3.py
rename to Question_01_10/answers/answer_3.py
diff --git a/Question_01_10/answer_4.jpg b/Question_01_10/answers/answer_4.jpg
similarity index 100%
rename from Question_01_10/answer_4.jpg
rename to Question_01_10/answers/answer_4.jpg
diff --git a/Question_01_10/answer_4.py b/Question_01_10/answers/answer_4.py
similarity index 100%
rename from Question_01_10/answer_4.py
rename to Question_01_10/answers/answer_4.py
diff --git a/Question_01_10/answer_5.jpg b/Question_01_10/answers/answer_5.jpg
similarity index 100%
rename from Question_01_10/answer_5.jpg
rename to Question_01_10/answers/answer_5.jpg
diff --git a/Question_01_10/answer_5.py b/Question_01_10/answers/answer_5.py
similarity index 100%
rename from Question_01_10/answer_5.py
rename to Question_01_10/answers/answer_5.py
diff --git a/Question_01_10/answer_6.jpg b/Question_01_10/answers/answer_6.jpg
similarity index 100%
rename from Question_01_10/answer_6.jpg
rename to Question_01_10/answers/answer_6.jpg
diff --git a/Question_01_10/answer_6.py b/Question_01_10/answers/answer_6.py
similarity index 100%
rename from Question_01_10/answer_6.py
rename to Question_01_10/answers/answer_6.py
diff --git a/Question_01_10/answer_7.jpg b/Question_01_10/answers/answer_7.jpg
similarity index 100%
rename from Question_01_10/answer_7.jpg
rename to Question_01_10/answers/answer_7.jpg
diff --git a/Question_01_10/answer_7.py b/Question_01_10/answers/answer_7.py
similarity index 100%
rename from Question_01_10/answer_7.py
rename to Question_01_10/answers/answer_7.py
diff --git a/Question_01_10/answer_8.jpg b/Question_01_10/answers/answer_8.jpg
similarity index 100%
rename from Question_01_10/answer_8.jpg
rename to Question_01_10/answers/answer_8.jpg
diff --git a/Question_01_10/answer_8.py b/Question_01_10/answers/answer_8.py
similarity index 100%
rename from Question_01_10/answer_8.py
rename to Question_01_10/answers/answer_8.py
diff --git a/Question_01_10/answer_9.jpg b/Question_01_10/answers/answer_9.jpg
similarity index 100%
rename from Question_01_10/answer_9.jpg
rename to Question_01_10/answers/answer_9.jpg
diff --git a/Question_01_10/answer_9.py b/Question_01_10/answers/answer_9.py
similarity index 100%
rename from Question_01_10/answer_9.py
rename to Question_01_10/answers/answer_9.py
diff --git a/Question_11_20/README.md b/Question_11_20/README.md
index cb49874f..94e0d816 100644
--- a/Question_11_20/README.md
+++ b/Question_11_20/README.md
@@ -6,11 +6,11 @@
平滑化フィルタはフィルタ内の画素の平均値を出力するフィルタである。
-|入力 (imori.jpg)|出力 (answer_11.jpg)|
+|入力 (imori.jpg)|出力 (answers/answer_11.jpg)|
|:---:|:---:|
-|||
+|||
-答え >> [answer_11.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_11_20/answer_11.py)
+答え >> [answers/answer_11.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_11_20/answers/answer_11.py)
## Q.12. モーションフィルタ
@@ -25,11 +25,11 @@
0 0 1/3
```
-|入力 (imori.jpg)|出力 (answer_12.jpg)|
+|入力 (imori.jpg)|出力 (answers/answer_12.jpg)|
|:---:|:---:|
-|||
+|||
-答え >> [answer_12.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_11_20/answer_12.py)
+答え >> [answers/answer_12.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_11_20/answers/answer_12.py)
## Q.13. MAX-MINフィルタ
@@ -39,11 +39,11 @@ MAX-MINフィルタとはフィルタ内の画素の最大値と最小値の差
エッジ検出とは画像内の線を検出るすることであり、このような画像内の情報を抜き出す操作を**特徴抽出**と呼ぶ。
エッジ検出では多くの場合、グレースケール画像に対してフィルタリングを行う。
-|入力 (imori.jpg)|出力 (answer_13.jpg)|
+|入力 (imori.jpg)|出力 (answers/answer_13.jpg)|
|:---:|:---:|
-|||
+|||
-答え >> [answer_13.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_11_20/answer_13.py)
+答え >> [answers/answer_13.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_11_20/answers/answer_13.py)
## Q.14. 微分フィルタ
@@ -59,11 +59,11 @@ K = [ 0 1 0 ] K = [ -1 1 0 ]
0 0 0 0 0 0
```
-|入力 (imori.jpg)|出力・縦方向 (answer_14_v.jpg)|出力・横方向 (answer_14_h.jpg)|
+|入力 (imori.jpg)|出力・縦方向 (answers/answer_14_v.jpg)|出力・横方向 (answers/answer_14_h.jpg)|
|:---:|:---:|:---:|
-||||
+||||
-答え >>[ answer_14.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_11_20/answer_14.py)
+答え >>[ answers/answer_14.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_11_20/answers/answer_14.py)
## Q.15. Sobelフィルタ
@@ -78,11 +78,11 @@ K = [ 2 0 -2 ] K = [ 0 0 0 ]
1 0 -1 -1 -2 -1
```
-|入力 (imori.jpg)|出力・縦方向 (answer_15_v.jpg)|出力・横方向 (answer_15_h.jpg)|
+|入力 (imori.jpg)|出力・縦方向 (answers/answer_15_v.jpg)|出力・横方向 (answers/answer_15_h.jpg)|
|:---:|:---:|:---:|
-||||
+||||
-答え >> [answer_15.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_11_20/answer_15.py)
+答え >> [answers/answer_15.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_11_20/answers/answer_15.py)
## Q.16. Prewittフィルタ
@@ -97,11 +97,11 @@ K = [ 0 0 0 ] K = [ -1 0 1 ]
1 1 1 -1 0 1
```
-|入力 (imori.jpg)|出力・縦方向 (answer_16_v.jpg)|出力・横方向 (answer_16_h.jpg)|
+|入力 (imori.jpg)|出力・縦方向 (answers/answer_16_v.jpg)|出力・横方向 (answers/answer_16_h.jpg)|
|:---:|:---:|:---:|
-||||
+||||
-答え >> [answer_16.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_11_20/answer_16.py)
+答え >> [answers/answer_16.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_11_20/answers/answer_16.py)
## Q.17. Laplacianフィルタ
@@ -141,11 +141,11 @@ K = [ 1 -4 1 ]
0 1 0
```
-|入力 (imori.jpg)|出力(answer_17.jpg)|
+|入力 (imori.jpg)|出力(answers/answer_17.jpg)|
|:---:|:---:|
-||||
+||||
-答え >> [answer_17.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_11_20/answer_17.py)
+答え >> [answers/answer_17.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_11_20/answers/answer_17.py)
## Q.18. Embossフィルタ
@@ -159,11 +159,11 @@ K = [ -1 1 1 ]
0 1 2
```
-|入力 (imori.jpg)|出力(answer_18.jpg)|
+|入力 (imori.jpg)|出力(answers/answer_18.jpg)|
|:---:|:---:|
-|||
+|||
-答え >> [answer_18.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_11_20/answer_18.py)
+答え >> [answers/answer_18.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_11_20/answers/answer_18.py)
## Q.19. LoGフィルタ
@@ -179,11 +179,11 @@ LoGフィルタは次式で定義される。
LoG(x,y) = (x^2 + y^2 - s^2) / (2 * pi * s^6) * exp(-(x^2+y^2) / (2*s^2))
```
-|入力 (imori_noise.jpg)|出力 (answer_19.jpg) |
+|入力 (imori_noise.jpg)|出力 (answers/answer_19.jpg) |
|:---:|:---:|
-|||
+|||
-答え >> [answer_19.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_11_20/answer_19.py)
+答え >> [answers/answer_19.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_11_20/answers/answer_19.py)
## Q.20. ヒストグラム表示
@@ -192,9 +192,9 @@ matplotlibを用いて*imori_dark.jpg*のヒストグラムを表示せよ。
ヒストグラムとは画素の出現回数をグラフにしたものである。
matplotlibではhist()という関数がすでにあるので、それを利用する。
-|入力 (imori_dark.jpg)|出力 (answer_20.png) |
+|入力 (imori_dark.jpg)|出力 (answers/answer_20.png) |
|:---:|:---:|
-|||
+|||
-答え >> [answer_20.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_11_20/answer_20.py)
+答え >> [answers/answer_20.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_11_20/answers/answer_20.py)
diff --git a/Question_11_20/answer_11.jpg b/Question_11_20/answers/answer_11.jpg
similarity index 100%
rename from Question_11_20/answer_11.jpg
rename to Question_11_20/answers/answer_11.jpg
diff --git a/Question_11_20/answer_11.py b/Question_11_20/answers/answer_11.py
similarity index 100%
rename from Question_11_20/answer_11.py
rename to Question_11_20/answers/answer_11.py
diff --git a/Question_11_20/answer_12.jpg b/Question_11_20/answers/answer_12.jpg
similarity index 100%
rename from Question_11_20/answer_12.jpg
rename to Question_11_20/answers/answer_12.jpg
diff --git a/Question_11_20/answer_12.py b/Question_11_20/answers/answer_12.py
similarity index 100%
rename from Question_11_20/answer_12.py
rename to Question_11_20/answers/answer_12.py
diff --git a/Question_11_20/answer_13.jpg b/Question_11_20/answers/answer_13.jpg
similarity index 100%
rename from Question_11_20/answer_13.jpg
rename to Question_11_20/answers/answer_13.jpg
diff --git a/Question_11_20/answer_13.py b/Question_11_20/answers/answer_13.py
similarity index 100%
rename from Question_11_20/answer_13.py
rename to Question_11_20/answers/answer_13.py
diff --git a/Question_11_20/answer_14.py b/Question_11_20/answers/answer_14.py
similarity index 100%
rename from Question_11_20/answer_14.py
rename to Question_11_20/answers/answer_14.py
diff --git a/Question_11_20/answer_14_h.jpg b/Question_11_20/answers/answer_14_h.jpg
similarity index 100%
rename from Question_11_20/answer_14_h.jpg
rename to Question_11_20/answers/answer_14_h.jpg
diff --git a/Question_11_20/answer_14_v.jpg b/Question_11_20/answers/answer_14_v.jpg
similarity index 100%
rename from Question_11_20/answer_14_v.jpg
rename to Question_11_20/answers/answer_14_v.jpg
diff --git a/Question_11_20/answer_15.py b/Question_11_20/answers/answer_15.py
similarity index 100%
rename from Question_11_20/answer_15.py
rename to Question_11_20/answers/answer_15.py
diff --git a/Question_11_20/answer_15_h.jpg b/Question_11_20/answers/answer_15_h.jpg
similarity index 100%
rename from Question_11_20/answer_15_h.jpg
rename to Question_11_20/answers/answer_15_h.jpg
diff --git a/Question_11_20/answer_15_v.jpg b/Question_11_20/answers/answer_15_v.jpg
similarity index 100%
rename from Question_11_20/answer_15_v.jpg
rename to Question_11_20/answers/answer_15_v.jpg
diff --git a/Question_11_20/answer_16.py b/Question_11_20/answers/answer_16.py
similarity index 100%
rename from Question_11_20/answer_16.py
rename to Question_11_20/answers/answer_16.py
diff --git a/Question_11_20/answer_16_h.jpg b/Question_11_20/answers/answer_16_h.jpg
similarity index 100%
rename from Question_11_20/answer_16_h.jpg
rename to Question_11_20/answers/answer_16_h.jpg
diff --git a/Question_11_20/answer_16_v.jpg b/Question_11_20/answers/answer_16_v.jpg
similarity index 100%
rename from Question_11_20/answer_16_v.jpg
rename to Question_11_20/answers/answer_16_v.jpg
diff --git a/Question_11_20/answer_17.jpg b/Question_11_20/answers/answer_17.jpg
similarity index 100%
rename from Question_11_20/answer_17.jpg
rename to Question_11_20/answers/answer_17.jpg
diff --git a/Question_11_20/answer_17.py b/Question_11_20/answers/answer_17.py
similarity index 100%
rename from Question_11_20/answer_17.py
rename to Question_11_20/answers/answer_17.py
diff --git a/Question_11_20/answer_18.jpg b/Question_11_20/answers/answer_18.jpg
similarity index 100%
rename from Question_11_20/answer_18.jpg
rename to Question_11_20/answers/answer_18.jpg
diff --git a/Question_11_20/answer_18.py b/Question_11_20/answers/answer_18.py
similarity index 100%
rename from Question_11_20/answer_18.py
rename to Question_11_20/answers/answer_18.py
diff --git a/Question_11_20/answer_19.jpg b/Question_11_20/answers/answer_19.jpg
similarity index 100%
rename from Question_11_20/answer_19.jpg
rename to Question_11_20/answers/answer_19.jpg
diff --git a/Question_11_20/answer_19.py b/Question_11_20/answers/answer_19.py
similarity index 100%
rename from Question_11_20/answer_19.py
rename to Question_11_20/answers/answer_19.py
diff --git a/Question_11_20/answer_20.png b/Question_11_20/answers/answer_20.png
similarity index 100%
rename from Question_11_20/answer_20.png
rename to Question_11_20/answers/answer_20.png
diff --git a/Question_11_20/answer_20.py b/Question_11_20/answers/answer_20.py
similarity index 100%
rename from Question_11_20/answer_20.py
rename to Question_11_20/answers/answer_20.py
diff --git a/Question_21_30/README.md b/Question_21_30/README.md
index c79cfe25..d2f44027 100644
--- a/Question_21_30/README.md
+++ b/Question_21_30/README.md
@@ -19,11 +19,11 @@ xout = { a (xin < c)
b (d < xin)
```
-|入力 (imori_dark.jpg)|出力 (answer_21_1.jpg) |ヒストグラム(answer_21_2.png)|
+|入力 (imori_dark.jpg)|出力 (answers/answer_21_1.jpg) |ヒストグラム(answers/answer_21_2.png)|
|:---:|:---:|:---:|
-||||
+||||
-答え >> [answer_21.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_21_30/answer_21.py)
+答え >> [answers/answer_21.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_21_30/answers/answer_21.py)
## Q.22. ヒストグラム操作
@@ -37,11 +37,11 @@ xout = { a (xin < c)
xout = s0 / s * (xin - m) + m0
```
-|入力 (imori_dark.jpg)|出力 (answer_22_1.jpg) |ヒストグラム(answer_22_2.png)|
+|入力 (imori_dark.jpg)|出力 (answers/answer_22_1.jpg) |ヒストグラム(answers/answer_22_2.png)|
|:---:|:---:|:---:|
-||||
+||||
-答え >> [answer_22.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_21_30/answer_22.py)
+答え >> [answers/answer_22.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_21_30/answers/answer_22.py)
## Q.23. ヒストグラム平坦化
@@ -56,11 +56,11 @@ xout = s0 / s * (xin - m) + m0
Z' = Zmax / S * Sum{i=0:z} h(z)
```
-|入力 (imori.jpg)|出力 (answer_23_1.jpg) |ヒストグラム(answer_23_2.png)|
+|入力 (imori.jpg)|出力 (answers/answer_23_1.jpg) |ヒストグラム(answers/answer_23_2.png)|
|:---:|:---:|:---:|
-||||
+||||
-答え >> [answer_23.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_21_30/answer_23.py)
+答え >> [answers/answer_23.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_21_30/answers/answer_23.py)
## Q.24. ガンマ補正
@@ -86,11 +86,11 @@ Iout = (1/c * Iin) ^ (1/g)
 
-|入力 (imori_gamma.jpg)|出力 (answer_24.jpg)|
+|入力 (imori_gamma.jpg)|出力 (answers/answer_24.jpg)|
|:---:|:---:|
-|||
+|||
-答え >> [answer_24.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_21_30/answer_24.py)
+答え >> [answers/answer_24.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_21_30/answers/answer_24.py)
## Q.25. 最近傍補間
@@ -106,11 +106,11 @@ I' ... 拡大後の画像、 I ... 拡大前の画像、a ... 拡大率、[ ] ..
```bash
I'(x,y) = I([x/a], [y/a])
```
-|入力 (imori.jpg)|出力 (answer_25.jpg)|
+|入力 (imori.jpg)|出力 (answers/answer_25.jpg)|
|:---:|:---:|
-|||
+|||
-答え >> [answer_25.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_21_30/answer_25.py)
+答え >> [answers/answer_25.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_21_30/answers/answer_25.py)
## Q.26. Bi-linear補間
@@ -135,11 +135,11 @@ dx = x'/a - x , dy = y'/a - y
I'(x',y') = (1-dx)(1-dy)I(x,y) + dx(1-dy)I(x+1,y) + (1-dx)dyI(x,y+1) + dxdyI(x+1,y+1)
```
-|入力 (imori.jpg)|出力 (answer_26.jpg)|
+|入力 (imori.jpg)|出力 (answers/answer_26.jpg)|
|:---:|:---:|
-|||
+|||
-答え >> [answer_26.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_21_30/answer_26.py)
+答え >> [answers/answer_26.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_21_30/answers/answer_26.py)
## Q.27. Bi-cubic補間
@@ -177,11 +177,11 @@ h(t) = { (a+2)|t|^3 - (a+3)|t|^2 + 1 (when |t|<=1)
I'(x', y') = (Sum{i=-1:2}{j=-1:2} I(x+i,y+j) * wxi * wyj) / Sum{i=-1:2}{j=-1:2} wxi * wyj
```
-|入力 (imori.jpg)|出力 (answer_27.jpg)|
+|入力 (imori.jpg)|出力 (answers/answer_27.jpg)|
|:---:|:---:|
-|||
+|||
-答え >> [answer_27.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_21_30/answer_27.py)
+答え >> [answers/answer_27.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_21_30/answers/answer_27.py)
## Q.28. アフィン変換(平行移動)
@@ -222,11 +222,11 @@ I'(x', y') = (Sum{i=-1:2}{j=-1:2} I(x+i,y+j) * wxi * wyj) / Sum{i=-1:2}{j=-1:2}
1 0 0 1 1
```
-|入力 (imori.jpg)|出力 (answer_28.jpg)|
+|入力 (imori.jpg)|出力 (answers/answer_28.jpg)|
|:---:|:---:|
-|||
+|||
-答え >> [answer_28.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_21_30/answer_28.py)
+答え >> [answers/answer_28.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_21_30/answers/answer_28.py)
## Q.29. アフィン変換(拡大縮小)
@@ -234,11 +234,11 @@ I'(x', y') = (Sum{i=-1:2}{j=-1:2} I(x+i,y+j) * wxi * wyj) / Sum{i=-1:2}{j=-1:2}
また、(2) (1)の条件に加えて、x方向に+30、y方向に-30だけ平行移動を同時に実現せよ。
-|入力 (imori.jpg)|出力 (1) (answer_29_1.jpg)|出力 (2) (answer_29_2.jpg)|
+|入力 (imori.jpg)|出力 (1) (answers/answer_29_1.jpg)|出力 (2) (answers/answer_29_2.jpg)|
|:---:|:---:|:---:|
-||||
+||||
-答え >> [answer_29.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_21_30/answer_29.py)
+答え >> [answers/answer_29.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_21_30/answers/answer_29.py)
## Q.30. アフィン変換(回転)
@@ -255,8 +255,8 @@ I'(x', y') = (Sum{i=-1:2}{j=-1:2} I(x+i,y+j) * wxi * wyj) / Sum{i=-1:2}{j=-1:2}
1 0 0 1 1
```
-|入力 (imori.jpg)|出力 (1) (answer_30_1.jpg)|出力 (2) (answer_30_2.jpg)|
+|入力 (imori.jpg)|出力 (1) (answers/answer_30_1.jpg)|出力 (2) (answers/answer_30_2.jpg)|
|:---:|:---:|:---:|
-||||
+||||
-答え >> [answer_30_1.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_21_30/answer_30_1.py) , [answer_30_2.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_21_30/answer_30_2.py)
+答え >> [answers/answer_30_1.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_21_30/answers/answer_30_1.py) , [answers/answer_30_2.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_21_30/answers/answer_30_2.py)
diff --git a/Question_21_30/answer_21.py b/Question_21_30/answers/answer_21.py
similarity index 100%
rename from Question_21_30/answer_21.py
rename to Question_21_30/answers/answer_21.py
diff --git a/Question_21_30/answer_21_1.jpg b/Question_21_30/answers/answer_21_1.jpg
similarity index 100%
rename from Question_21_30/answer_21_1.jpg
rename to Question_21_30/answers/answer_21_1.jpg
diff --git a/Question_21_30/answer_21_2.png b/Question_21_30/answers/answer_21_2.png
similarity index 100%
rename from Question_21_30/answer_21_2.png
rename to Question_21_30/answers/answer_21_2.png
diff --git a/Question_21_30/answer_22.py b/Question_21_30/answers/answer_22.py
similarity index 100%
rename from Question_21_30/answer_22.py
rename to Question_21_30/answers/answer_22.py
diff --git a/Question_21_30/answer_22_1.jpg b/Question_21_30/answers/answer_22_1.jpg
similarity index 100%
rename from Question_21_30/answer_22_1.jpg
rename to Question_21_30/answers/answer_22_1.jpg
diff --git a/Question_21_30/answer_22_2.png b/Question_21_30/answers/answer_22_2.png
similarity index 100%
rename from Question_21_30/answer_22_2.png
rename to Question_21_30/answers/answer_22_2.png
diff --git a/Question_21_30/answer_23.py b/Question_21_30/answers/answer_23.py
similarity index 100%
rename from Question_21_30/answer_23.py
rename to Question_21_30/answers/answer_23.py
diff --git a/Question_21_30/answer_23_1.jpg b/Question_21_30/answers/answer_23_1.jpg
similarity index 100%
rename from Question_21_30/answer_23_1.jpg
rename to Question_21_30/answers/answer_23_1.jpg
diff --git a/Question_21_30/answer_23_2.png b/Question_21_30/answers/answer_23_2.png
similarity index 100%
rename from Question_21_30/answer_23_2.png
rename to Question_21_30/answers/answer_23_2.png
diff --git a/Question_21_30/answer_24.jpg b/Question_21_30/answers/answer_24.jpg
similarity index 100%
rename from Question_21_30/answer_24.jpg
rename to Question_21_30/answers/answer_24.jpg
diff --git a/Question_21_30/answer_24.py b/Question_21_30/answers/answer_24.py
similarity index 100%
rename from Question_21_30/answer_24.py
rename to Question_21_30/answers/answer_24.py
diff --git a/Question_21_30/answer_25.jpg b/Question_21_30/answers/answer_25.jpg
similarity index 100%
rename from Question_21_30/answer_25.jpg
rename to Question_21_30/answers/answer_25.jpg
diff --git a/Question_21_30/answer_25.py b/Question_21_30/answers/answer_25.py
similarity index 100%
rename from Question_21_30/answer_25.py
rename to Question_21_30/answers/answer_25.py
diff --git a/Question_21_30/answer_26.jpg b/Question_21_30/answers/answer_26.jpg
similarity index 100%
rename from Question_21_30/answer_26.jpg
rename to Question_21_30/answers/answer_26.jpg
diff --git a/Question_21_30/answer_26.py b/Question_21_30/answers/answer_26.py
similarity index 100%
rename from Question_21_30/answer_26.py
rename to Question_21_30/answers/answer_26.py
diff --git a/Question_21_30/answer_27.jpg b/Question_21_30/answers/answer_27.jpg
similarity index 100%
rename from Question_21_30/answer_27.jpg
rename to Question_21_30/answers/answer_27.jpg
diff --git a/Question_21_30/answer_27.py b/Question_21_30/answers/answer_27.py
similarity index 100%
rename from Question_21_30/answer_27.py
rename to Question_21_30/answers/answer_27.py
diff --git a/Question_21_30/answer_28.jpg b/Question_21_30/answers/answer_28.jpg
similarity index 100%
rename from Question_21_30/answer_28.jpg
rename to Question_21_30/answers/answer_28.jpg
diff --git a/Question_21_30/answer_28.py b/Question_21_30/answers/answer_28.py
similarity index 100%
rename from Question_21_30/answer_28.py
rename to Question_21_30/answers/answer_28.py
diff --git a/Question_21_30/answer_29.py b/Question_21_30/answers/answer_29.py
similarity index 100%
rename from Question_21_30/answer_29.py
rename to Question_21_30/answers/answer_29.py
diff --git a/Question_21_30/answer_29_1.jpg b/Question_21_30/answers/answer_29_1.jpg
similarity index 100%
rename from Question_21_30/answer_29_1.jpg
rename to Question_21_30/answers/answer_29_1.jpg
diff --git a/Question_21_30/answer_29_2.jpg b/Question_21_30/answers/answer_29_2.jpg
similarity index 100%
rename from Question_21_30/answer_29_2.jpg
rename to Question_21_30/answers/answer_29_2.jpg
diff --git a/Question_21_30/answer_30_1.jpg b/Question_21_30/answers/answer_30_1.jpg
similarity index 100%
rename from Question_21_30/answer_30_1.jpg
rename to Question_21_30/answers/answer_30_1.jpg
diff --git a/Question_21_30/answer_30_1.py b/Question_21_30/answers/answer_30_1.py
similarity index 100%
rename from Question_21_30/answer_30_1.py
rename to Question_21_30/answers/answer_30_1.py
diff --git a/Question_21_30/answer_30_2.jpg b/Question_21_30/answers/answer_30_2.jpg
similarity index 100%
rename from Question_21_30/answer_30_2.jpg
rename to Question_21_30/answers/answer_30_2.jpg
diff --git a/Question_21_30/answer_30_2.py b/Question_21_30/answers/answer_30_2.py
similarity index 100%
rename from Question_21_30/answer_30_2.py
rename to Question_21_30/answers/answer_30_2.py
diff --git a/Question_31_40/README.md b/Question_31_40/README.md
index ddbac780..3d032d3d 100644
--- a/Question_31_40/README.md
+++ b/Question_31_40/README.md
@@ -26,11 +26,11 @@
1 0 0 1 1 1 0 0 1 1
```
-|入力 (imori.jpg)|出力 (1) (answer_31_1.jpg)|出力 (2) (answer_31_2.jpg)|出力 (3) (answer_31_3.jpg)|
+|入力 (imori.jpg)|出力 (1) (answers/answer_31_1.jpg)|出力 (2) (answers/answer_31_2.jpg)|出力 (3) (answers/answer_31_3.jpg)|
|:---:|:---:|:---:|:---:|
-|||||
+|||||
-答え >> [answer_31.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_31_40/answer_31.py)
+答え >> [answers/answer_31.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_31_40/answers/answer_31.py)
## Q.32. フーリエ変換
@@ -62,11 +62,11 @@ x = 0:W, y = 0:H として
I(x,y) = Sum_{l=0:H-1, k=0:W-1} G(k,l) exp( 2pi * j * (kx/W + ly/H)) / sqrt(H * W)
```
-|入力 (imori.jpg)|グレースケール (imori_gray.jpg)|出力 (answer_32.jpg)|パワースペクトル (answer_32_ps.py)
+|入力 (imori.jpg)|グレースケール (imori_gray.jpg)|出力 (answers/answer_32.jpg)|パワースペクトル (answers/answer_32_ps.py)
|:---:|:---:|:---:|:---:|
-|||||
+|||||
-答え >> [answer_32.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_31_40/answer_32.py)
+答え >> [answers/answer_32.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_31_40/answers/answer_32.py)
## Q.33. フーリエ変換 ローパスフィルタ
@@ -79,11 +79,11 @@ DFTによって得られた周波数成分は左上、右上、左下、右下
ここでは低周波数の中心から高周波までの距離をrとすると0.5rまでの成分を通すとする。
-|入力 (imori.jpg)|グレースケール (imori_gray.jpg)|出力 (answer_33.jpg)|
+|入力 (imori.jpg)|グレースケール (imori_gray.jpg)|出力 (answers/answer_33.jpg)|
|:---:|:---:|:---:|
-||||
+||||
-答え >> [answer_33.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_31_40/answer_33.py)
+答え >> [answers/answer_33.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_31_40/answers/answer_33.py)
## Q.34. フーリエ変換 ハイパスフィルタ
@@ -93,11 +93,11 @@ DFTによって得られた周波数成分は左上、右上、左下、右下
ここでは低周波数の中心から高周波までの距離をrとすると0.2rからの成分を通すとする。
-|入力 (imori.jpg)|グレースケール (imori_gray.jpg)|出力 (answer_34.jpg)|
+|入力 (imori.jpg)|グレースケール (imori_gray.jpg)|出力 (answers/answer_34.jpg)|
|:---:|:---:|:---:|
-||||
+||||
-答え >> [answer_34.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_31_40/answer_34.py)
+答え >> [answers/answer_34.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_31_40/answers/answer_34.py)
## Q.35. フーリエ変換 バンドパスフィルタ
@@ -107,11 +107,11 @@ DFTによって得られた周波数成分は左上、右上、左下、右下
ここでは低周波数の中心から高周波までの距離をrとすると0.1rから0.5rまでの成分を通すとする。
-|入力 (imori.jpg)|グレースケール (imori_gray.jpg)|出力 (answer_35.jpg)|
+|入力 (imori.jpg)|グレースケール (imori_gray.jpg)|出力 (answers/answer_35.jpg)|
|:---:|:---:|:---:|
-||||
+||||
-答え >> [answer_35.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_31_40/answer_35.py)
+答え >> [answers/answer_35.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_31_40/answers/answer_35.py)
## Q.36. JPEG圧縮 (Step.1)離散コサイン変換
@@ -133,11 +133,11 @@ f(x,y) = 1 / T * C(x)C(y) * Sum_{u=0:T-1} Sum_{v=0:T-1} F(u,v) cos((2x+1)u*pi/2T
ここでは画像を8x8ずつの領域に分割して、各領域で以上のDCT, IDCTを繰り返すことで、jpeg符号に応用される。
今回も同様に8x8の領域に分割して、DCT, IDCTを行え。
-|入力 (imori.jpg)|グレースケール (imori_gray.jpg)|出力 (1) (answer_36.jpg)|
+|入力 (imori.jpg)|グレースケール (imori_gray.jpg)|出力 (1) (answers/answer_36.jpg)|
|:---:|:---:|:---:|
-||||
+||||
-答え >> [answer_36.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_31_40/answer_36.py)
+答え >> [answers/answer_36.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_31_40/answers/answer_36.py)
## Q.37. PSNR
@@ -162,11 +162,11 @@ MSE = Sum_{y=0:H-1} Sum_{x=0:W-1} (I1(x,y) - I2(x,y))^2 / (HW)
bitrate = 8 * K^2 / 8^2
```
-|入力 (imori.jpg)|グレースケール|出力 (answer_37.jpg) (PSNR = 27.62, Bitrate=2.0)|
+|入力 (imori.jpg)|グレースケール|出力 (answers/answer_37.jpg) (PSNR = 27.62, Bitrate=2.0)|
|:---:|:---:|:---:|
-||||
+||||
-答え >> [answer_37.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_31_40/answer_37.py)
+答え >> [answers/answer_37.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_31_40/answers/answer_37.py)
## Q.38. JPEG圧縮 (Step.2)DCT+量子化|
@@ -194,11 +194,11 @@ Q = np.array(((16, 11, 10, 16, 24, 40, 51, 61),
量子化を行うと画像の容量が減っていることから、データ量が削減されたことが伺える。
-|入力 (imori.jpg)|グレースケール(9kb)|出力 (answer_38.jpg) (7kb)|
+|入力 (imori.jpg)|グレースケール(9kb)|出力 (answers/answer_38.jpg) (7kb)|
|:---:|:---:|:---:|
-||||
+||||
-答え >> [answer_38.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_31_40/answer_38.py)
+答え >> [answers/answer_38.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_31_40/answers/answer_38.py)
## Q.39. JPEG圧縮 (Step.3)YCbCr表色系
@@ -224,11 +224,11 @@ G = Y - (Cb - 128) * 0.3441 - (Cr - 128) * 0.7139
B = Y + (Cb - 128) * 1.7718
```
-|入力 (imori.jpg)|出力 (answer_39.jpg) |
+|入力 (imori.jpg)|出力 (answers/answer_39.jpg) |
|:---:|:---:|
-|||
+|||
-答え >> [answer_39.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_31_40/answer_39.py)
+答え >> [answers/answer_39.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_31_40/answers/answer_39.py)
## Q.40. JPEG圧縮 (Step.4)YCbCr+DCT+量子化
@@ -257,9 +257,9 @@ Q2 = np.array(((17, 18, 24, 47, 99, 99, 99, 99),
(99, 99, 99, 99, 99, 99, 99, 99)), dtype=np.float32)
```
-|入力 (imori.jpg) (13kb)|出力 (answer_40.jpg) (8kb)|
+|入力 (imori.jpg) (13kb)|出力 (answers/answer_40.jpg) (8kb)|
|:---:|:---:|
-|||
+|||
-答え >> [answer_40.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_31_40/answer_40.py)
+答え >> [answers/answer_40.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_31_40/answers/answer_40.py)
diff --git a/Question_31_40/answer_31.py b/Question_31_40/answers/answer_31.py
similarity index 100%
rename from Question_31_40/answer_31.py
rename to Question_31_40/answers/answer_31.py
diff --git a/Question_31_40/answer_31_1.jpg b/Question_31_40/answers/answer_31_1.jpg
similarity index 100%
rename from Question_31_40/answer_31_1.jpg
rename to Question_31_40/answers/answer_31_1.jpg
diff --git a/Question_31_40/answer_31_2.jpg b/Question_31_40/answers/answer_31_2.jpg
similarity index 100%
rename from Question_31_40/answer_31_2.jpg
rename to Question_31_40/answers/answer_31_2.jpg
diff --git a/Question_31_40/answer_31_3.jpg b/Question_31_40/answers/answer_31_3.jpg
similarity index 100%
rename from Question_31_40/answer_31_3.jpg
rename to Question_31_40/answers/answer_31_3.jpg
diff --git a/Question_31_40/answer_32.jpg b/Question_31_40/answers/answer_32.jpg
similarity index 100%
rename from Question_31_40/answer_32.jpg
rename to Question_31_40/answers/answer_32.jpg
diff --git a/Question_31_40/answer_32.py b/Question_31_40/answers/answer_32.py
similarity index 100%
rename from Question_31_40/answer_32.py
rename to Question_31_40/answers/answer_32.py
diff --git a/Question_31_40/answer_32_ps.jpg b/Question_31_40/answers/answer_32_ps.jpg
similarity index 100%
rename from Question_31_40/answer_32_ps.jpg
rename to Question_31_40/answers/answer_32_ps.jpg
diff --git a/Question_31_40/answer_33.jpg b/Question_31_40/answers/answer_33.jpg
similarity index 100%
rename from Question_31_40/answer_33.jpg
rename to Question_31_40/answers/answer_33.jpg
diff --git a/Question_31_40/answer_33.py b/Question_31_40/answers/answer_33.py
similarity index 100%
rename from Question_31_40/answer_33.py
rename to Question_31_40/answers/answer_33.py
diff --git a/Question_31_40/answer_34.jpg b/Question_31_40/answers/answer_34.jpg
similarity index 100%
rename from Question_31_40/answer_34.jpg
rename to Question_31_40/answers/answer_34.jpg
diff --git a/Question_31_40/answer_34.py b/Question_31_40/answers/answer_34.py
similarity index 100%
rename from Question_31_40/answer_34.py
rename to Question_31_40/answers/answer_34.py
diff --git a/Question_31_40/answer_35.jpg b/Question_31_40/answers/answer_35.jpg
similarity index 100%
rename from Question_31_40/answer_35.jpg
rename to Question_31_40/answers/answer_35.jpg
diff --git a/Question_31_40/answer_35.py b/Question_31_40/answers/answer_35.py
similarity index 100%
rename from Question_31_40/answer_35.py
rename to Question_31_40/answers/answer_35.py
diff --git a/Question_31_40/answer_36.jpg b/Question_31_40/answers/answer_36.jpg
similarity index 100%
rename from Question_31_40/answer_36.jpg
rename to Question_31_40/answers/answer_36.jpg
diff --git a/Question_31_40/answer_36.py b/Question_31_40/answers/answer_36.py
similarity index 100%
rename from Question_31_40/answer_36.py
rename to Question_31_40/answers/answer_36.py
diff --git a/Question_31_40/answer_37.jpg b/Question_31_40/answers/answer_37.jpg
similarity index 100%
rename from Question_31_40/answer_37.jpg
rename to Question_31_40/answers/answer_37.jpg
diff --git a/Question_31_40/answer_37.py b/Question_31_40/answers/answer_37.py
similarity index 100%
rename from Question_31_40/answer_37.py
rename to Question_31_40/answers/answer_37.py
diff --git a/Question_31_40/answer_38.jpg b/Question_31_40/answers/answer_38.jpg
similarity index 100%
rename from Question_31_40/answer_38.jpg
rename to Question_31_40/answers/answer_38.jpg
diff --git a/Question_31_40/answer_38.py b/Question_31_40/answers/answer_38.py
similarity index 100%
rename from Question_31_40/answer_38.py
rename to Question_31_40/answers/answer_38.py
diff --git a/Question_31_40/answer_39.jpg b/Question_31_40/answers/answer_39.jpg
similarity index 100%
rename from Question_31_40/answer_39.jpg
rename to Question_31_40/answers/answer_39.jpg
diff --git a/Question_31_40/answer_39.py b/Question_31_40/answers/answer_39.py
similarity index 100%
rename from Question_31_40/answer_39.py
rename to Question_31_40/answers/answer_39.py
diff --git a/Question_31_40/answer_40.jpg b/Question_31_40/answers/answer_40.jpg
similarity index 100%
rename from Question_31_40/answer_40.jpg
rename to Question_31_40/answers/answer_40.jpg
diff --git a/Question_31_40/answer_40.py b/Question_31_40/answers/answer_40.py
similarity index 100%
rename from Question_31_40/answer_40.py
rename to Question_31_40/answers/answer_40.py
diff --git a/Question_41_50/README.md b/Question_41_50/README.md
index 9853a4fa..6dab8751 100644
--- a/Question_41_50/README.md
+++ b/Question_41_50/README.md
@@ -35,11 +35,11 @@ angle = { 0 (if -0.4142 < tan <= 0.4142)
ただし、フィルタリングをパディングする際は、numpy.pad()を用いて、エッジの値でパディングせよ。
-|入力 (imori.jpg) |出力(勾配強度) (answer_41_1.jpg)|出力(勾配角度) (answer_41_2.jpg)|
+|入力 (imori.jpg) |出力(勾配強度) (answers/answer_41_1.jpg)|出力(勾配角度) (answers/answer_41_2.jpg)|
|:---:|:---:|:---:|
-||||
+||||
-答え >> [answer_41.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_41_50/answer_41.py)
+答え >> [answers/answer_41.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_41_50/answers/answer_41.py)
## Q.42. Cannyエッジ検出 (Step.2) 細線化
@@ -68,11 +68,11 @@ if angle(x,y) = 135
then edge(x,y) = 0
```
-|入力 (imori.jpg) |出力 (answer_42.jpg)|
+|入力 (imori.jpg) |出力 (answers/answer_42.jpg)|
|:---:|:---:|
-|||
+|||
-答え >> [answer_42.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_41_50/answer_42.py)
+答え >> [answers/answer_42.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_41_50/answers/answer_42.py)
## Q.43. Cannyエッジ検出 (Step.3) ヒステリシス閾処理
@@ -89,11 +89,11 @@ if angle(x,y) = 135
以上のアルゴリズムによって、Canny法が行われる。
-|入力 (imori.jpg) |出力 (answer_43.jpg)|
+|入力 (imori.jpg) |出力 (answers/answer_43.jpg)|
|:---:|:---:|
-|||
+|||
-答え >> [answer_43.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_41_50/answer_43.py)
+答え >> [answers/answer_43.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_41_50/answers/answer_43.py)
## Q.44. Hough変換・直線検出 (Step.1) Hough変換
@@ -127,11 +127,11 @@ r = x * cos(t) + y * sin(t)
今回は*torino.jpg*を用いて、ボーディングした表を図示せよ。
Cannyのパラメータは, gaussian filter(5x5, s=1.4), HT = 100, LT = 30で使用せよ。
-|入力 (thorino.jpg) |出力 (answer_44.jpg)|
+|入力 (thorino.jpg) |出力 (answers/answer_44.jpg)|
|:---:|:---:|
-|||
+|||
-答え >> [answer_44.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_41_50/answer_44.py)
+答え >> [answers/answer_44.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_41_50/answers/answer_44.py)
## Q.45. Hough変換・直線検出 (Step.2) NMS
@@ -146,11 +146,11 @@ NMSのアルゴリズムは、
1. 表において、周囲8マス(8近傍)より注目ピクセルの得票数が多ければそのまま。
2. 注目ピクセルの値が少なければ0にする。
-|入力 (thorino.jpg) |出力 (answer_45.jpg)|
+|入力 (thorino.jpg) |出力 (answers/answer_45.jpg)|
|:---:|:---:|
-|||
+|||
-答え >> [answer_45.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_41_50/answer_45.py)
+答え >> [answers/answer_45.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_41_50/answers/answer_45.py)
## Q.46. Hough変換・直線検出 (Step.3) Hough逆変換
@@ -167,11 +167,11 @@ x = - sin(t) / cos(t) * y + r / cos(t)
2. 1の逆変換を極大点ごとにy = 0 - H-1, x = 0 - W-1 で行い、入力画像に検出した直線を描画せよ。
ただし、描画するのは赤線(R,G,B) = (255, 0, 0)とする。
-|入力 (thorino.jpg) |出力 (answer_46.jpg)|
+|入力 (thorino.jpg) |出力 (answers/answer_46.jpg)|
|:---:|:---:|
-|||
+|||
-答え >> [answer_46.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_41_50/answer_46.py)
+答え >> [answers/answer_46.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_41_50/answers/answer_46.py)
## Q.47. モルフォロジー処理(膨張)
@@ -189,11 +189,11 @@ x = - sin(t) / cos(t) * y + r / cos(t)
例えば、[[0,1,0], [1,0,1], [0,1,0]] のフィルタを掛けた和が255を超えれば膨張である、と考える。
-|入力 (imori.jpg) |大津の二値化(answer_4.jpg)|出力 (answer_47.jpg)|
+|入力 (imori.jpg) |大津の二値化(answers/answer_4.jpg)|出力 (answers/answer_47.jpg)|
|:---:|:---:|:---:|
-||||
+||||
-答え >> [answer_47.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_41_50/answer_47.py)
+答え >> [answers/answer_47.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_41_50/answers/answer_47.py)
## Q.48. モルフォロジー処理(収縮)
@@ -204,11 +204,11 @@ x = - sin(t) / cos(t) * y + r / cos(t)
例えば、[[0,1,0], [1,0,1], [0,1,0]] のフィルタを掛けた和が255*4未満なら収縮である、と考える。
-|入力 (imori.jpg) |大津の二値化(answer_4.jpg)|出力 (answer_48.jpg)|
+|入力 (imori.jpg) |大津の二値化(answers/answer_4.jpg)|出力 (answers/answer_48.jpg)|
|:---:|:---:|:---:|
-||||
+||||
-答え >> [answer_48.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_41_50/answer_48.py)
+答え >> [answers/answer_48.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_41_50/answers/answer_48.py)
## Q.49. オープニング処理
@@ -218,11 +218,11 @@ x = - sin(t) / cos(t) * y + r / cos(t)
クロージング処理により、一つだけ余分に存在する画素などを削除できる。
-|入力 (imori.jpg) |大津の二値化(answer_4.jpg)|出力 (answer_49.jpg)|
+|入力 (imori.jpg) |大津の二値化(answers/answer_4.jpg)|出力 (answers/answer_49.jpg)|
|:---:|:---:|:---:|
-||||
+||||
-答え >> [answer_49.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_41_50/answer_49.py)
+答え >> [answers/answer_49.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_41_50/answers/answer_49.py)
## Q.50. クロージング処理
@@ -232,8 +232,8 @@ x = - sin(t) / cos(t) * y + r / cos(t)
クロージング処理により、途中で途切れた画素を結合することができる。
-|入力 (imori.jpg) |Canny(answer_43.jpg)|出力 (answer_50.jpg)|
+|入力 (imori.jpg) |Canny(answers/answer_43.jpg)|出力 (answers/answer_50.jpg)|
|:---:|:---:|:---:|
-||||
+||||
-答え >> [answer_50.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_41_50/answer_50.py)
+答え >> [answers/answer_50.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_41_50/answers/answer_50.py)
diff --git a/Question_41_50/answer_4.jpg b/Question_41_50/answers/answer_4.jpg
similarity index 100%
rename from Question_41_50/answer_4.jpg
rename to Question_41_50/answers/answer_4.jpg
diff --git a/Question_41_50/answer_41.py b/Question_41_50/answers/answer_41.py
similarity index 100%
rename from Question_41_50/answer_41.py
rename to Question_41_50/answers/answer_41.py
diff --git a/Question_41_50/answer_41_1.jpg b/Question_41_50/answers/answer_41_1.jpg
similarity index 100%
rename from Question_41_50/answer_41_1.jpg
rename to Question_41_50/answers/answer_41_1.jpg
diff --git a/Question_41_50/answer_41_2.jpg b/Question_41_50/answers/answer_41_2.jpg
similarity index 100%
rename from Question_41_50/answer_41_2.jpg
rename to Question_41_50/answers/answer_41_2.jpg
diff --git a/Question_41_50/answer_42.jpg b/Question_41_50/answers/answer_42.jpg
similarity index 100%
rename from Question_41_50/answer_42.jpg
rename to Question_41_50/answers/answer_42.jpg
diff --git a/Question_41_50/answer_42.py b/Question_41_50/answers/answer_42.py
similarity index 100%
rename from Question_41_50/answer_42.py
rename to Question_41_50/answers/answer_42.py
diff --git a/Question_41_50/answer_43.jpg b/Question_41_50/answers/answer_43.jpg
similarity index 100%
rename from Question_41_50/answer_43.jpg
rename to Question_41_50/answers/answer_43.jpg
diff --git a/Question_41_50/answer_43.py b/Question_41_50/answers/answer_43.py
similarity index 100%
rename from Question_41_50/answer_43.py
rename to Question_41_50/answers/answer_43.py
diff --git a/Question_41_50/answer_44.jpg b/Question_41_50/answers/answer_44.jpg
similarity index 100%
rename from Question_41_50/answer_44.jpg
rename to Question_41_50/answers/answer_44.jpg
diff --git a/Question_41_50/answer_44.py b/Question_41_50/answers/answer_44.py
similarity index 100%
rename from Question_41_50/answer_44.py
rename to Question_41_50/answers/answer_44.py
diff --git a/Question_41_50/answer_45.jpg b/Question_41_50/answers/answer_45.jpg
similarity index 100%
rename from Question_41_50/answer_45.jpg
rename to Question_41_50/answers/answer_45.jpg
diff --git a/Question_41_50/answer_45.py b/Question_41_50/answers/answer_45.py
similarity index 100%
rename from Question_41_50/answer_45.py
rename to Question_41_50/answers/answer_45.py
diff --git a/Question_41_50/answer_46.jpg b/Question_41_50/answers/answer_46.jpg
similarity index 100%
rename from Question_41_50/answer_46.jpg
rename to Question_41_50/answers/answer_46.jpg
diff --git a/Question_41_50/answer_46.py b/Question_41_50/answers/answer_46.py
similarity index 100%
rename from Question_41_50/answer_46.py
rename to Question_41_50/answers/answer_46.py
diff --git a/Question_41_50/answer_47.jpg b/Question_41_50/answers/answer_47.jpg
similarity index 100%
rename from Question_41_50/answer_47.jpg
rename to Question_41_50/answers/answer_47.jpg
diff --git a/Question_41_50/answer_47.py b/Question_41_50/answers/answer_47.py
similarity index 100%
rename from Question_41_50/answer_47.py
rename to Question_41_50/answers/answer_47.py
diff --git a/Question_41_50/answer_48.jpg b/Question_41_50/answers/answer_48.jpg
similarity index 100%
rename from Question_41_50/answer_48.jpg
rename to Question_41_50/answers/answer_48.jpg
diff --git a/Question_41_50/answer_48.py b/Question_41_50/answers/answer_48.py
similarity index 100%
rename from Question_41_50/answer_48.py
rename to Question_41_50/answers/answer_48.py
diff --git a/Question_41_50/answer_49.jpg b/Question_41_50/answers/answer_49.jpg
similarity index 100%
rename from Question_41_50/answer_49.jpg
rename to Question_41_50/answers/answer_49.jpg
diff --git a/Question_41_50/answer_49.py b/Question_41_50/answers/answer_49.py
similarity index 100%
rename from Question_41_50/answer_49.py
rename to Question_41_50/answers/answer_49.py
diff --git a/Question_41_50/answer_50.jpg b/Question_41_50/answers/answer_50.jpg
similarity index 100%
rename from Question_41_50/answer_50.jpg
rename to Question_41_50/answers/answer_50.jpg
diff --git a/Question_41_50/answer_50.py b/Question_41_50/answers/answer_50.py
similarity index 100%
rename from Question_41_50/answer_50.py
rename to Question_41_50/answers/answer_50.py
diff --git a/Question_51_60/README.md b/Question_51_60/README.md
index 84804331..97d9b95c 100644
--- a/Question_51_60/README.md
+++ b/Question_51_60/README.md
@@ -8,11 +8,11 @@
ここではモルフォロジー処理のN=1とする。
-|入力 (imori.jpg) |出力(answer_51.jpg)|
+|入力 (imori.jpg) |出力(answers/answer_51.jpg)|
|:---:|:---:|
-|||
+|||
-答え >> [answer_51.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_51_60/answer_51.py)
+答え >> [answers/answer_51.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_51_60/answers/answer_51.py)
## Q.52. トップハット変換
@@ -24,11 +24,11 @@
*ここの問題だと効果が分かりにくいので、他の画像があればそのうち訂正します。
-|入力 (imori.jpg) |大津の二値化(answer_4.jpg)|出力(answer_52.jpg)|
+|入力 (imori.jpg) |大津の二値化(answers/answer_4.jpg)|出力(answers/answer_52.jpg)|
|:---:|:---:|:---:|
-||||
+||||
-答え >> [answer_52.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_51_60/answer_52.py)
+答え >> [answers/answer_52.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_51_60/answers/answer_52.py)
## Q.53. ブラックハット変換
@@ -40,11 +40,11 @@
*ここの問題だと効果が分かりにくいので、他の画像があればそのうち訂正します。
-|入力 (imori.jpg) |大津の二値化(answer_4.jpg)|出力(answer_53.jpg)|
+|入力 (imori.jpg) |大津の二値化(answers/answer_4.jpg)|出力(answers/answer_53.jpg)|
|:---:|:---:|:---:|
-||||
+||||
-答え >> [answer_53.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_51_60/answer_53.py)
+答え >> [answers/answer_53.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_51_60/answers/answer_53.py)
## Q.54. テンプレートマッチング SSD
@@ -71,11 +71,11 @@ S = Sum_{x=0:w, y=0:h} (I(i+x, j+y) - T(x, y) )^2
矩形の描画には*cv2.rectangle()*を用いると良い。
ちなみにimori_part.jpgは若干色味を変えています。
-|入力 (imori.jpg) |テンプレート画像(imori_part.jpg)|出力(answer_54.jpg)|
+|入力 (imori.jpg) |テンプレート画像(imori_part.jpg)|出力(answers/answer_54.jpg)|
|:---:|:---:|:---:|
-||||
+||||
-答え >> [answer_54.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_51_60/answer_54.py)
+答え >> [answers/answer_54.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_51_60/answers/answer_54.py)
## Q.55. テンプレートマッチング SAD
@@ -87,11 +87,11 @@ SAD(Sum of Absolute Difference)とは画素値の差分の絶対値の和を類
S = Sum_{x=0:w, y=0:h} |I(i+x, j+y) - T(x, y)|
```
-|入力 (imori.jpg) |テンプレート画像(imori_part.jpg)|出力(answer_55.jpg)|
+|入力 (imori.jpg) |テンプレート画像(imori_part.jpg)|出力(answers/answer_55.jpg)|
|:---:|:---:|:---:|
-||||
+||||
-答え >> [answer_55.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_51_60/answer_55.py)
+答え >> [answers/answer_55.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_51_60/answers/answer_55.py)
## Q.56. テンプレートマッチング NCC
@@ -108,11 +108,11 @@ S = ----------------------------------------------------------------------------
このSは、-1<=S<=1をとる。
NCCは証明変化に強いと言われる。
-|入力 (imori.jpg) |テンプレート画像(imori_part.jpg)|出力(answer_56.jpg)|
+|入力 (imori.jpg) |テンプレート画像(imori_part.jpg)|出力(answers/answer_56.jpg)|
|:---:|:---:|:---:|
-||||
+||||
-答え >> [answer_56.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_51_60/answer_56.py)
+答え >> [answers/answer_56.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_51_60/answers/answer_56.py)
## Q.57. テンプレートマッチング ZNCC
@@ -131,11 +131,11 @@ S = ----------------------------------------------------------------------------
このSは、-1<=S<=1をとる。
ZNCCは平均値を引くことでNCCよりも証明変化に強いと言われる。(だが今回は検出が失敗する。)
-|入力 (imori.jpg) |テンプレート画像(imori_part.jpg)|出力(answer_57.jpg)|
+|入力 (imori.jpg) |テンプレート画像(imori_part.jpg)|出力(answers/answer_57.jpg)|
|:---:|:---:|:---:|
-||||
+||||
-答え >> [answer_57.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_51_60/answer_57.py)
+答え >> [answers/answer_57.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_51_60/answers/answer_57.py)
## Q.58. ラベリング 4近傍
@@ -180,11 +180,11 @@ ZNCCは平均値を引くことでNCCよりも証明変化に強いと言われ
以上により隣接ピクセル同士に同じラベルを割り当てる。
4近傍としているが、ラスタスキャンのため、上画素と左画素の2画素に注目すればいい。
-|入力 (seg.png) |出力(answer_58.png)|
+|入力 (seg.png) |出力(answers/answer_58.png)|
|:---:|:---:|
-|||
+|||
-答え >> [answer_58.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_51_60/answer_58.py)
+答え >> [answers/answer_58.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_51_60/answers/answer_58.py)
## Q.59. ラベリング 8近傍
@@ -192,11 +192,11 @@ ZNCCは平均値を引くことでNCCよりも証明変化に強いと言われ
8近傍とは、i(x-1,y-1), i(x, y-1), i(x+1,y-1), i(x-1,y)の4画素に注目すればよい。
-|入力 (seg.png) |出力(answer_59.png)|
+|入力 (seg.png) |出力(answers/answer_59.png)|
|:---:|:---:|
-|||
+|||
-答え >> [answer_59.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_51_60/answer_59.py)
+答え >> [answers/answer_59.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_51_60/answers/answer_59.py)
## Q.60. アルファブレンド
@@ -216,8 +216,8 @@ alpha = 0.5
out = img1 * alpha + img2 * (1 - alpha)
```
-|入力 (imori.jpg) |入力2 (thorino.jpg) |出力(answer_60.jpg)|
+|入力 (imori.jpg) |入力2 (thorino.jpg) |出力(answers/answer_60.jpg)|
|:---:|:---:|:---:|
-||||
+||||
-答え >> [answer_60.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_51_60/answer_60.py)
+答え >> [answers/answer_60.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_51_60/answers/answer_60.py)
diff --git a/Question_51_60/answer_4.jpg b/Question_51_60/answers/answer_4.jpg
similarity index 100%
rename from Question_51_60/answer_4.jpg
rename to Question_51_60/answers/answer_4.jpg
diff --git a/Question_51_60/answer_51.jpg b/Question_51_60/answers/answer_51.jpg
similarity index 100%
rename from Question_51_60/answer_51.jpg
rename to Question_51_60/answers/answer_51.jpg
diff --git a/Question_51_60/answer_51.py b/Question_51_60/answers/answer_51.py
similarity index 100%
rename from Question_51_60/answer_51.py
rename to Question_51_60/answers/answer_51.py
diff --git a/Question_51_60/answer_52.jpg b/Question_51_60/answers/answer_52.jpg
similarity index 100%
rename from Question_51_60/answer_52.jpg
rename to Question_51_60/answers/answer_52.jpg
diff --git a/Question_51_60/answer_52.py b/Question_51_60/answers/answer_52.py
similarity index 100%
rename from Question_51_60/answer_52.py
rename to Question_51_60/answers/answer_52.py
diff --git a/Question_51_60/answer_53.jpg b/Question_51_60/answers/answer_53.jpg
similarity index 100%
rename from Question_51_60/answer_53.jpg
rename to Question_51_60/answers/answer_53.jpg
diff --git a/Question_51_60/answer_53.py b/Question_51_60/answers/answer_53.py
similarity index 100%
rename from Question_51_60/answer_53.py
rename to Question_51_60/answers/answer_53.py
diff --git a/Question_51_60/answer_54.jpg b/Question_51_60/answers/answer_54.jpg
similarity index 100%
rename from Question_51_60/answer_54.jpg
rename to Question_51_60/answers/answer_54.jpg
diff --git a/Question_51_60/answer_54.py b/Question_51_60/answers/answer_54.py
similarity index 100%
rename from Question_51_60/answer_54.py
rename to Question_51_60/answers/answer_54.py
diff --git a/Question_51_60/answer_55.jpg b/Question_51_60/answers/answer_55.jpg
similarity index 100%
rename from Question_51_60/answer_55.jpg
rename to Question_51_60/answers/answer_55.jpg
diff --git a/Question_51_60/answer_55.py b/Question_51_60/answers/answer_55.py
similarity index 100%
rename from Question_51_60/answer_55.py
rename to Question_51_60/answers/answer_55.py
diff --git a/Question_51_60/answer_56.jpg b/Question_51_60/answers/answer_56.jpg
similarity index 100%
rename from Question_51_60/answer_56.jpg
rename to Question_51_60/answers/answer_56.jpg
diff --git a/Question_51_60/answer_56.py b/Question_51_60/answers/answer_56.py
similarity index 100%
rename from Question_51_60/answer_56.py
rename to Question_51_60/answers/answer_56.py
diff --git a/Question_51_60/answer_57.jpg b/Question_51_60/answers/answer_57.jpg
similarity index 100%
rename from Question_51_60/answer_57.jpg
rename to Question_51_60/answers/answer_57.jpg
diff --git a/Question_51_60/answer_57.py b/Question_51_60/answers/answer_57.py
similarity index 100%
rename from Question_51_60/answer_57.py
rename to Question_51_60/answers/answer_57.py
diff --git a/Question_51_60/answer_58.png b/Question_51_60/answers/answer_58.png
similarity index 100%
rename from Question_51_60/answer_58.png
rename to Question_51_60/answers/answer_58.png
diff --git a/Question_51_60/answer_58.py b/Question_51_60/answers/answer_58.py
similarity index 100%
rename from Question_51_60/answer_58.py
rename to Question_51_60/answers/answer_58.py
diff --git a/Question_51_60/answer_59.png b/Question_51_60/answers/answer_59.png
similarity index 100%
rename from Question_51_60/answer_59.png
rename to Question_51_60/answers/answer_59.png
diff --git a/Question_51_60/answer_59.py b/Question_51_60/answers/answer_59.py
similarity index 100%
rename from Question_51_60/answer_59.py
rename to Question_51_60/answers/answer_59.py
diff --git a/Question_51_60/answer_60.jpg b/Question_51_60/answers/answer_60.jpg
similarity index 100%
rename from Question_51_60/answer_60.jpg
rename to Question_51_60/answers/answer_60.jpg
diff --git a/Question_51_60/answer_60.py b/Question_51_60/answers/answer_60.py
similarity index 100%
rename from Question_51_60/answer_60.py
rename to Question_51_60/answers/answer_60.py
diff --git a/Question_61_70/README.md b/Question_61_70/README.md
index db081be1..4b84a4f5 100644
--- a/Question_61_70/README.md
+++ b/Question_61_70/README.md
@@ -27,11 +27,11 @@ S = [0,4]の範囲をとり、
- S = 4 は交差点
を示す。
-|入力 (renketsu.png) |出力(answer_61.png)|
+|入力 (renketsu.png) |出力(answers/answer_61.png)|
|:---:|:---:|
-|
|
|
+|
|
|
-答え >> [answer_61.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_61_70/answer_61.py)
+答え >> [answers/answer_61.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_61_70/answers/answer_61.py)
## Q.62. 8-連結数
@@ -44,11 +44,11 @@ S = (x1 - x1 x2 x3) + (x3 - x3 x4 x5) + (x5 - x5 x6 x7) + (x7 - x7 x8 x1)
```
において各x¥*の値の0と1を反転させた値を用いる。
-|入力 (renketsu.png) |出力(answer_62.png)|
+|入力 (renketsu.png) |出力(answers/answer_62.png)|
|:---:|:---:|
-|
|
|
+|
|
|
-答え >> [answer_62.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_61_70/answer_62.py)
+答え >> [answers/answer_62.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_61_70/answers/answer_62.py)
## Q.63. 細線化処理
@@ -65,11 +65,11 @@ S = (x1 - x1 x2 x3) + (x3 - x3 x4 x5) + (x5 - x5 x6 x7) + (x7 - x7 x8 x1)
細線化にはヒルディッチのアルゴリズム(Q.64)や、Zhang-Suenのアルゴリズム(Q.65)、田村のアルゴリズムなどが存在する。
-|入力 (gazo.png) |出力(answer_63.png)|
+|入力 (gazo.png) |出力(answers/answer_63.png)|
|:---:|:---:|
-|||
+|||
-答え >> [answer_63.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_61_70/answer_63.py)
+答え >> [answers/answer_63.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_61_70/answers/answer_63.py)
## Q.64. ヒルディッチの細線化
@@ -113,11 +113,11 @@ Step.2
Step1, 2で変更する点がなくなるまで交互に繰り返す。
-|入力 (gazo.png) |出力(answer_65.png)|
+|入力 (gazo.png) |出力(answers/answer_65.png)|
|:---:|:---:|
-|||
+|||
-答え >> [answer_65.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_61_70/answer_65.py)
+答え >> [answers/answer_65.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_61_70/answers/answer_65.py)
## Q.66. HOG (Step.1) 勾配強度・勾配角度
@@ -159,11 +159,11 @@ h(t) = h(t) / sqrt(Sum h(t) + epsilon)
解答例はみやすくするため、graは色付けしてある。またmagは[0, 255]に正規化してある。
-|入力 (imori.jpg) |勾配強度(answer_66_mag.jpg)|勾配角度(answer_66_gra.jpg)|
+|入力 (imori.jpg) |勾配強度(answers/answer_66_mag.jpg)|勾配角度(answers/answer_66_gra.jpg)|
|:---:|:---:|:---:|
-||||
+||||
-答え >> [answer_66.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_61_70/answer_66.py)
+答え >> [answers/answer_66.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_61_70/answers/answer_66.py)
## Q.67. HOG (Step.2) 勾配ヒストグラム
@@ -179,11 +179,11 @@ N=8として、8x8の領域を1セルとして、勾配角度のインデック
```
の順に量子化したインデックスに対応するヒストグラムを示す。
-|入力 (imori.jpg) |出力(answer_67.png)|
+|入力 (imori.jpg) |出力(answers/answer_67.png)|
|:---:|:---:|
-||
|
+||
|
-答え >> [answer_67.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_61_70/answer_67.py)
+答え >> [answers/answer_67.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_61_70/answers/answer_67.py)
## Q.68. HOG (Step.3) ヒストグラム正規化
@@ -198,11 +198,11 @@ h(t) = h(t) / sqrt(Sum h(t) + epsilon)
これでHOG特徴量が得られた。
-|入力 (imori.jpg) |出力(answer_68.png)|
+|入力 (imori.jpg) |出力(answers/answer_68.png)|
|:---:|:---:|
-||
|
+||
|
-答え >> [answer_68.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_61_70/answer_68.py)
+答え >> [answers/answer_68.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_61_70/answers/answer_68.py)
## Q.69. HOG (Step.4) 特徴量の描画
@@ -214,11 +214,11 @@ h(t) = h(t) / sqrt(Sum h(t) + epsilon)
解答例
-|入力 (imori.jpg) |出力(answer_69.jpg)|
+|入力 (imori.jpg) |出力(answers/answer_69.jpg)|
|:---:|:---:|
-|||
+|||
-答え >> [answer_69.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_61_70/answer_69.py)
+答え >> [answers/answer_69.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_61_70/answers/answer_69.py)
## Q.70. カラートラッキング
@@ -241,8 +241,8 @@ HSV変換とは Q.5で用いた処理であるが、RGBをH(色相)、S(彩度)
つまり、青色のカラートラッキングを行うにはHSV変換を行い、180<=H<=260となる位置が255となるような二値画像を出力すればよい。
-|入力 (imori.jpg) |出力(answer_70.png)|
+|入力 (imori.jpg) |出力(answers/answer_70.png)|
|:---:|:---:|
-|||
+|||
-答え >> [answer_70.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_61_70/answer_70.py)
+答え >> [answers/answer_70.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_61_70/answers/answer_70.py)
diff --git a/Question_61_70/answer_61.png b/Question_61_70/answers/answer_61.png
similarity index 100%
rename from Question_61_70/answer_61.png
rename to Question_61_70/answers/answer_61.png
diff --git a/Question_61_70/answer_61.py b/Question_61_70/answers/answer_61.py
similarity index 100%
rename from Question_61_70/answer_61.py
rename to Question_61_70/answers/answer_61.py
diff --git a/Question_61_70/answer_62.png b/Question_61_70/answers/answer_62.png
similarity index 100%
rename from Question_61_70/answer_62.png
rename to Question_61_70/answers/answer_62.png
diff --git a/Question_61_70/answer_62.py b/Question_61_70/answers/answer_62.py
similarity index 100%
rename from Question_61_70/answer_62.py
rename to Question_61_70/answers/answer_62.py
diff --git a/Question_61_70/answer_63.png b/Question_61_70/answers/answer_63.png
similarity index 100%
rename from Question_61_70/answer_63.png
rename to Question_61_70/answers/answer_63.png
diff --git a/Question_61_70/answer_63.py b/Question_61_70/answers/answer_63.py
similarity index 100%
rename from Question_61_70/answer_63.py
rename to Question_61_70/answers/answer_63.py
diff --git a/Question_61_70/answer_64.py b/Question_61_70/answers/answer_64.py
similarity index 100%
rename from Question_61_70/answer_64.py
rename to Question_61_70/answers/answer_64.py
diff --git a/Question_61_70/answer_64_a.py b/Question_61_70/answers/answer_64_a.py
similarity index 100%
rename from Question_61_70/answer_64_a.py
rename to Question_61_70/answers/answer_64_a.py
diff --git a/Question_61_70/answer_65.png b/Question_61_70/answers/answer_65.png
similarity index 100%
rename from Question_61_70/answer_65.png
rename to Question_61_70/answers/answer_65.png
diff --git a/Question_61_70/answer_65.py b/Question_61_70/answers/answer_65.py
similarity index 100%
rename from Question_61_70/answer_65.py
rename to Question_61_70/answers/answer_65.py
diff --git a/Question_61_70/answer_66.py b/Question_61_70/answers/answer_66.py
similarity index 100%
rename from Question_61_70/answer_66.py
rename to Question_61_70/answers/answer_66.py
diff --git a/Question_61_70/answer_66_gra.jpg b/Question_61_70/answers/answer_66_gra.jpg
similarity index 100%
rename from Question_61_70/answer_66_gra.jpg
rename to Question_61_70/answers/answer_66_gra.jpg
diff --git a/Question_61_70/answer_66_mag.jpg b/Question_61_70/answers/answer_66_mag.jpg
similarity index 100%
rename from Question_61_70/answer_66_mag.jpg
rename to Question_61_70/answers/answer_66_mag.jpg
diff --git a/Question_61_70/answer_67.png b/Question_61_70/answers/answer_67.png
similarity index 100%
rename from Question_61_70/answer_67.png
rename to Question_61_70/answers/answer_67.png
diff --git a/Question_61_70/answer_67.py b/Question_61_70/answers/answer_67.py
similarity index 100%
rename from Question_61_70/answer_67.py
rename to Question_61_70/answers/answer_67.py
diff --git a/Question_61_70/answer_68.png b/Question_61_70/answers/answer_68.png
similarity index 100%
rename from Question_61_70/answer_68.png
rename to Question_61_70/answers/answer_68.png
diff --git a/Question_61_70/answer_68.py b/Question_61_70/answers/answer_68.py
similarity index 100%
rename from Question_61_70/answer_68.py
rename to Question_61_70/answers/answer_68.py
diff --git a/Question_61_70/answer_69.jpg b/Question_61_70/answers/answer_69.jpg
similarity index 100%
rename from Question_61_70/answer_69.jpg
rename to Question_61_70/answers/answer_69.jpg
diff --git a/Question_61_70/answer_69.py b/Question_61_70/answers/answer_69.py
similarity index 100%
rename from Question_61_70/answer_69.py
rename to Question_61_70/answers/answer_69.py
diff --git a/Question_61_70/answer_70.png b/Question_61_70/answers/answer_70.png
similarity index 100%
rename from Question_61_70/answer_70.png
rename to Question_61_70/answers/answer_70.png
diff --git a/Question_61_70/answer_70.py b/Question_61_70/answers/answer_70.py
similarity index 100%
rename from Question_61_70/answer_70.py
rename to Question_61_70/answers/answer_70.py
diff --git a/Question_71_80/README.md b/Question_71_80/README.md
index b56cc854..5eb4add6 100644
--- a/Question_71_80/README.md
+++ b/Question_71_80/README.md
@@ -10,11 +10,11 @@
これによりある程度のイモリの部分の抽出ができる。
-|入力 (imori.jpg) |マスク(answer_70.png)|出力(answer_71.jpg)|
+|入力 (imori.jpg) |マスク(answers/answer_70.png)|出力(answers/answer_71.jpg)|
|:---:|:---:|:---:|
-||||
+||||
-答え >> [answer_71.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_71_80/answer_71.py)
+答え >> [answers/answer_71.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_71_80/answers/answer_71.py)
## Q.72. マスキング(カラートラッキング+モルフォロジー)
@@ -22,11 +22,11 @@ Q.71ではマスクが雑になってしまっていたので、イモリの目
よってマスク画像にN=5のクロージング処理(Q.50)とオープニング処理(Q.49)を施してマスク画像を正確にして、マスキングを行え。
-|入力 (imori.jpg) |マスク(answer_72_mask.png)|出力(answer_72.jpg)|
+|入力 (imori.jpg) |マスク(answers/answer_72_mask.png)|出力(answers/answer_72.jpg)|
|:---:|:---:|:---:|
-||||
+||||
-答え >> [answer_72.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_71_80/answer_72.py)
+答え >> [answers/answer_72.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_71_80/answers/answer_72.py)
## Q.73. 縮小と拡大
@@ -35,11 +35,11 @@ Q.71ではマスクが雑になってしまっていたので、イモリの目
拡大縮小にはbi-linear補間を用いよ。bi-linear補間をメソッド(関数)化すると、プログラムが簡潔にできる。
-|入力 (imori.jpg) |出力(answer_73.jpg)|
+|入力 (imori.jpg) |出力(answers/answer_73.jpg)|
|:---:|:---:|
-|||
+|||
-答え >> [answer_73.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_71_80/answer_73.py)
+答え >> [answers/answer_73.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_71_80/answers/answer_73.py)
## Q.74. ピラミッド差分による高周波成分の抽出
@@ -47,11 +47,11 @@ Q.73で求めた画像と元画像の差分を求め、[0,255]に正規化せよ
ここで求めた画像はエッジとなっている。つまり、画像中の高周波成分をとったことになる。
-|入力 (imori.jpg) |出力(answer_74.jpg)|
+|入力 (imori.jpg) |出力(answers/answer_74.jpg)|
|:---:|:---:|
-|||
+|||
-答え >> [answer_74.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_71_80/answer_74.py)
+答え >> [answers/answer_74.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_71_80/answers/answer_74.py)
## Q.75. ガウシアンピラミッド
@@ -61,11 +61,11 @@ Q.73で求めた画像と元画像の差分を求め、[0,255]に正規化せよ
このガウシアンピラミッドの概念は現在でも有効であり、画像をきれいにする超解像を行うディープラーニングの手法でもガウシアンピラミッドの概念が用いられる。
-|入力 (imori.jpg) |1/1(answer_75_1.jpg)|1/2|1/4|1/8|1/16|1/32|
+|入力 (imori.jpg) |1/1(answers/answer_75_1.jpg)|1/2|1/4|1/8|1/16|1/32|
|:---:|:---:|:---:|:---:|:---:|:---:|:---:|
-||||||||
+||||||||
-答え >> [answer_75.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_71_80/answer_75.py)
+答え >> [answers/answer_75.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_71_80/answers/answer_75.py)
## Q.76. 顕著性マップ
@@ -88,11 +88,11 @@ Q.73で求めた画像と元画像の差分を求め、[0,255]に正規化せよ
解答例( (0,1), (0,3), (0,5), (1,4), (2,3), (3,5) を使用)
-|入力 (imori.jpg) |出力(answer_76.jpg)|
+|入力 (imori.jpg) |出力(answers/answer_76.jpg)|
|:---:|:---:|
-|||
+|||
-答え >> [answer_76.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_71_80/answer_76.py)
+答え >> [answers/answer_76.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_71_80/answers/answer_76.py)
## Q.77. ガボールフィルタ
@@ -124,11 +124,11 @@ A ... フィルタの回転 抽出したい角度を指定する。
答えでは可視化のためにフィルタの値を[0,255]に正規化している。
-|出力(answer_77.jpg)|
+|出力(answers/answer_77.jpg)|
|:---:|
-||
+||
-答え >> [answer_77.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_71_80/answer_77.py)
+答え >> [answers/answer_77.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_71_80/answers/answer_77.py)
## Q.78. ガボールフィルタの回転
@@ -137,11 +137,11 @@ A ... フィルタの回転 抽出したい角度を指定する。
ここではガボールフィルタをメソッド化すれば簡単に実装できる。
-|出力(answer_78.png)|
+|出力(answers/answer_78.png)|
|:---:|
-||
+||
-答え >> [answer_78.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_71_80/answer_78.py)
+答え >> [answers/answer_78.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_71_80/answers/answer_78.py)
## Q.79. ガボールフィルタによるエッジ抽出
@@ -156,11 +156,11 @@ A ... フィルタの回転 抽出したい角度を指定する。
**ディープラーニング**のConvolutional層はガボールフィルタの働きに近いとも考えられている。しかし、ディープラーニングではフィルタの係数が機械学習によって自動的に決定される。機械学習の結果、ガボールフィルタに近い働きが生じると言われる。
-入力 (imori.jpg) |出力(answer_79.png)|
+入力 (imori.jpg) |出力(answers/answer_79.png)|
|:---:|:---:|
-|||
+|||
-答え >> [answer_79.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_71_80/answer_79.py)
+答え >> [answers/answer_79.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_71_80/answers/answer_79.py)
## Q.80. ガボールフィルタによる特徴抽出
@@ -170,8 +170,8 @@ Q.79で求めた4枚の画像を足し合わせることで、画像の特徴
ディープラーニングのCNN(Convolutional Neural Network)では、最初に画像の特徴を抽出する働きが備わっているが、その特徴抽出の計算はこの問で行ったような操作を延々と繰り返している。ディープラーニングではこのようにして画像の特徴を自動的に抽出している。
-入力 (imori.jpg) |出力(answer_80.jpg)|
+入力 (imori.jpg) |出力(answers/answer_80.jpg)|
|:---:|:---:|
-|||
+|||
-答え >> [answer_80.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_71_80/answer_80.py)
+答え >> [answers/answer_80.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_71_80/answers/answer_80.py)
diff --git a/Question_71_80/answer_70.png b/Question_71_80/answers/answer_70.png
similarity index 100%
rename from Question_71_80/answer_70.png
rename to Question_71_80/answers/answer_70.png
diff --git a/Question_71_80/answer_71.jpg b/Question_71_80/answers/answer_71.jpg
similarity index 100%
rename from Question_71_80/answer_71.jpg
rename to Question_71_80/answers/answer_71.jpg
diff --git a/Question_71_80/answer_71.py b/Question_71_80/answers/answer_71.py
similarity index 100%
rename from Question_71_80/answer_71.py
rename to Question_71_80/answers/answer_71.py
diff --git a/Question_71_80/answer_72.jpg b/Question_71_80/answers/answer_72.jpg
similarity index 100%
rename from Question_71_80/answer_72.jpg
rename to Question_71_80/answers/answer_72.jpg
diff --git a/Question_71_80/answer_72.py b/Question_71_80/answers/answer_72.py
similarity index 100%
rename from Question_71_80/answer_72.py
rename to Question_71_80/answers/answer_72.py
diff --git a/Question_71_80/answer_72_mask.png b/Question_71_80/answers/answer_72_mask.png
similarity index 100%
rename from Question_71_80/answer_72_mask.png
rename to Question_71_80/answers/answer_72_mask.png
diff --git a/Question_71_80/answer_73.jpg b/Question_71_80/answers/answer_73.jpg
similarity index 100%
rename from Question_71_80/answer_73.jpg
rename to Question_71_80/answers/answer_73.jpg
diff --git a/Question_71_80/answer_73.py b/Question_71_80/answers/answer_73.py
similarity index 100%
rename from Question_71_80/answer_73.py
rename to Question_71_80/answers/answer_73.py
diff --git a/Question_71_80/answer_74.jpg b/Question_71_80/answers/answer_74.jpg
similarity index 100%
rename from Question_71_80/answer_74.jpg
rename to Question_71_80/answers/answer_74.jpg
diff --git a/Question_71_80/answer_74.py b/Question_71_80/answers/answer_74.py
similarity index 100%
rename from Question_71_80/answer_74.py
rename to Question_71_80/answers/answer_74.py
diff --git a/Question_71_80/answer_75.py b/Question_71_80/answers/answer_75.py
similarity index 100%
rename from Question_71_80/answer_75.py
rename to Question_71_80/answers/answer_75.py
diff --git a/Question_71_80/answer_75_1.jpg b/Question_71_80/answers/answer_75_1.jpg
similarity index 100%
rename from Question_71_80/answer_75_1.jpg
rename to Question_71_80/answers/answer_75_1.jpg
diff --git a/Question_71_80/answer_75_16.jpg b/Question_71_80/answers/answer_75_16.jpg
similarity index 100%
rename from Question_71_80/answer_75_16.jpg
rename to Question_71_80/answers/answer_75_16.jpg
diff --git a/Question_71_80/answer_75_2.jpg b/Question_71_80/answers/answer_75_2.jpg
similarity index 100%
rename from Question_71_80/answer_75_2.jpg
rename to Question_71_80/answers/answer_75_2.jpg
diff --git a/Question_71_80/answer_75_32.jpg b/Question_71_80/answers/answer_75_32.jpg
similarity index 100%
rename from Question_71_80/answer_75_32.jpg
rename to Question_71_80/answers/answer_75_32.jpg
diff --git a/Question_71_80/answer_75_4.jpg b/Question_71_80/answers/answer_75_4.jpg
similarity index 100%
rename from Question_71_80/answer_75_4.jpg
rename to Question_71_80/answers/answer_75_4.jpg
diff --git a/Question_71_80/answer_75_8.jpg b/Question_71_80/answers/answer_75_8.jpg
similarity index 100%
rename from Question_71_80/answer_75_8.jpg
rename to Question_71_80/answers/answer_75_8.jpg
diff --git a/Question_71_80/answer_76.jpg b/Question_71_80/answers/answer_76.jpg
similarity index 100%
rename from Question_71_80/answer_76.jpg
rename to Question_71_80/answers/answer_76.jpg
diff --git a/Question_71_80/answer_76.py b/Question_71_80/answers/answer_76.py
similarity index 100%
rename from Question_71_80/answer_76.py
rename to Question_71_80/answers/answer_76.py
diff --git a/Question_71_80/answer_77.jpg b/Question_71_80/answers/answer_77.jpg
similarity index 100%
rename from Question_71_80/answer_77.jpg
rename to Question_71_80/answers/answer_77.jpg
diff --git a/Question_71_80/answer_77.py b/Question_71_80/answers/answer_77.py
similarity index 100%
rename from Question_71_80/answer_77.py
rename to Question_71_80/answers/answer_77.py
diff --git a/Question_71_80/answer_78.png b/Question_71_80/answers/answer_78.png
similarity index 100%
rename from Question_71_80/answer_78.png
rename to Question_71_80/answers/answer_78.png
diff --git a/Question_71_80/answer_78.py b/Question_71_80/answers/answer_78.py
similarity index 100%
rename from Question_71_80/answer_78.py
rename to Question_71_80/answers/answer_78.py
diff --git a/Question_71_80/answer_79.png b/Question_71_80/answers/answer_79.png
similarity index 100%
rename from Question_71_80/answer_79.png
rename to Question_71_80/answers/answer_79.png
diff --git a/Question_71_80/answer_79.py b/Question_71_80/answers/answer_79.py
similarity index 100%
rename from Question_71_80/answer_79.py
rename to Question_71_80/answers/answer_79.py
diff --git a/Question_71_80/answer_80.jpg b/Question_71_80/answers/answer_80.jpg
similarity index 100%
rename from Question_71_80/answer_80.jpg
rename to Question_71_80/answers/answer_80.jpg
diff --git a/Question_71_80/answer_80.py b/Question_71_80/answers/answer_80.py
similarity index 100%
rename from Question_71_80/answer_80.py
rename to Question_71_80/answers/answer_80.py
diff --git a/Question_81_90/README.md b/Question_81_90/README.md
index 659cae02..fb5c7575 100644
--- a/Question_81_90/README.md
+++ b/Question_81_90/README.md
@@ -23,11 +23,11 @@ H = [ Ix^2 IxIy]
解答ではdet(H)が極大点かつ、max(H)*0.1以上である点をコーナーとしている。
-|入力 (thorino.jpg) |出力(answer_81.jpg)|
+|入力 (thorino.jpg) |出力(answers/answer_81.jpg)|
|:---:|:---:|
-|||
+|||
-答え >> [answer_81.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_81_90/answer_81.py)
+答え >> [answers/answer_81.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_81_90/answers/answer_81.py)
## Q.82. Harrisのコーナー検出 (Step.1) Sobel + Gauusian
@@ -50,11 +50,11 @@ Q.82-83においての各パラメータは以下の通り。
ここでは1-3までを実装せよ。
-|入力 (thorino.jpg) |出力(answer_82.png)|
+|入力 (thorino.jpg) |出力(answers/answer_82.png)|
|:---:|:---:|
-|||
+|||
-答え >> [answer_82.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_81_90/answer_82.py)
+答え >> [answers/answer_82.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_81_90/answers/answer_82.py)
## Q.83. Harrisのコーナー検出 (Step.2) コーナー検出
@@ -62,11 +62,11 @@ Q.82-83においての各パラメータは以下の通り。
4における k = 0.04、5におけるth = 0.1
-|入力 (thorino.jpg) |出力(answer_83.jpg)|
+|入力 (thorino.jpg) |出力(answers/answer_83.jpg)|
|:---:|:---:|
-|||
+|||
-答え >> [answer_83.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_81_90/answer_83.py)
+答え >> [answers/answer_83.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_81_90/answers/answer_83.py)
## Q.84. 簡単な画像認識 (Step.1) 減色化 + ヒストグラム
@@ -89,18 +89,18 @@ CNNが流行る以前はこのアプローチがよく取られたが、CNNは
5. ヒストグラムの差の合計で、最小となった画像が予測となるクラスである。つまり、色が近い画像と同じクラスになると考えられる。
ここでは1-3を実装し、ヒストグラムを可視化せよ。
-学習データは train_akahara_@@@.jpg (クラス1)と train_madara_@@@.jpg(クラス2) を用いる。(計10枚)
+学習データはdatasetフォルダにあり train_akahara_@@@.jpg (クラス1)と train_madara_@@@.jpg(クラス2) を用いる。(計10枚)
akaharaとはアカハライモリ、madaraはマダライモリである。
このような予め特徴量を保存しておくデータベース型は人工知能第一世代の手法である。ようは、全部のパターンを暗記しておけばOKという考え方である。ただし、そうするとメモリを大量に消費するので使用が限られる手法である。
-|出力(answer_84.png)|
+|出力(answers/answer_84.png)|
|:---:|
-||
+||
-答え >> [answer_84.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_81_90/answer_84.py)
+答え >> [answers/answer_84.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_81_90/answers/answer_84.py)
```bash
格納されるヒストグラムの中身
@@ -133,7 +133,7 @@ test_akahara_2.jpg is similar >> train_akahara_1.jpg Pred >> akahara
test_madara_1.jpg is similar >> train_madara_2.jpg Pred >> madara
test_madara_2.jpg is similar >> train_akahara_2.jpg Pred >> akahara
```
-答え >> [answer_85.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_81_90/answer_85.py)
+答え >> [answers/answer_85.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_81_90/answers/answer_85.py)
## Q.86. 簡単な画像認識 (Step.3) 評価(Accuracy)
@@ -152,7 +152,7 @@ Accuracy = (正解した画像数) / (テストした画像の総数)
```bash
Accuracy >> 0.75 (3/4)
```
-答え >> [answer_86.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_81_90/answer_86.py)
+答え >> [answers/answer_86.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_81_90/answers/answer_86.py)
## Q.87. 簡単な画像認識 (Step.4) k-NN
@@ -178,7 +178,7 @@ test_madara_2.jpg is similar >> train_akahara_2.jpg, train_madara_3.jpg, train_m
Accuracy >> 1.0 (4/4)
```
-答え >> [answer_87.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_81_90/answer_87.py)
+答え >> [answers/answer_87.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_81_90/answers/answer_87.py)
## Q.88. K-means (Step.1) 重心作成
@@ -219,7 +219,7 @@ Grabity
2247. 1338. 434. 10822. 4506. 622. ]]
```
-答え >> [answer_88.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_81_90/answer_88.py)
+答え >> [answers/answer_88.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_81_90/answers/answer_88.py)
## Q.89. K-means (Step.2) クラスタリング
@@ -241,7 +241,7 @@ test_madara_1.jpg Pred: 0
test_madara_2.jpg Pred: 0
```
-答え >> [answer_89.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_81_90/answer_89.py)
+答え >> [answers/answer_89.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_81_90/answers/answer_89.py)
## Q.90. K-means (Step.3) 初期ラベルの変更
@@ -267,4 +267,4 @@ train_madara_4.jpg Pred: 0
train_madara_5.jpg Pred: 0
```
-答え >> [answer_90.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_81_90/answer_90.py)
+答え >> [answers/answer_90.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_81_90/answers/answer_90.py)
diff --git a/Question_81_90/answer_81.jpg b/Question_81_90/answers/answer_81.jpg
similarity index 100%
rename from Question_81_90/answer_81.jpg
rename to Question_81_90/answers/answer_81.jpg
diff --git a/Question_81_90/answer_81.py b/Question_81_90/answers/answer_81.py
similarity index 100%
rename from Question_81_90/answer_81.py
rename to Question_81_90/answers/answer_81.py
diff --git a/Question_81_90/answer_82.png b/Question_81_90/answers/answer_82.png
similarity index 100%
rename from Question_81_90/answer_82.png
rename to Question_81_90/answers/answer_82.png
diff --git a/Question_81_90/answer_82.py b/Question_81_90/answers/answer_82.py
similarity index 100%
rename from Question_81_90/answer_82.py
rename to Question_81_90/answers/answer_82.py
diff --git a/Question_81_90/answer_83.jpg b/Question_81_90/answers/answer_83.jpg
similarity index 100%
rename from Question_81_90/answer_83.jpg
rename to Question_81_90/answers/answer_83.jpg
diff --git a/Question_81_90/answer_83.py b/Question_81_90/answers/answer_83.py
similarity index 100%
rename from Question_81_90/answer_83.py
rename to Question_81_90/answers/answer_83.py
diff --git a/Question_81_90/answer_84.png b/Question_81_90/answers/answer_84.png
similarity index 100%
rename from Question_81_90/answer_84.png
rename to Question_81_90/answers/answer_84.png
diff --git a/Question_81_90/answer_84.py b/Question_81_90/answers/answer_84.py
similarity index 96%
rename from Question_81_90/answer_84.py
rename to Question_81_90/answers/answer_84.py
index e72c2a96..b0462bd6 100644
--- a/Question_81_90/answer_84.py
+++ b/Question_81_90/answers/answer_84.py
@@ -10,7 +10,7 @@ def dic_color(img):
return img
## Database
-train = glob("train_*")
+train = glob("dataset/train_*")
train.sort()
db = np.zeros((len(train), 13), dtype=np.int32)
diff --git a/Question_81_90/answer_85.py b/Question_81_90/answers/answer_85.py
similarity index 95%
rename from Question_81_90/answer_85.py
rename to Question_81_90/answers/answer_85.py
index 93636156..9926ba7b 100644
--- a/Question_81_90/answer_85.py
+++ b/Question_81_90/answers/answer_85.py
@@ -10,7 +10,7 @@ def dic_color(img):
return img
## Database
-train = glob("train_*")
+train = glob("dataset/train_*")
train.sort()
db = np.zeros((len(train), 13), dtype=np.int32)
@@ -33,7 +33,7 @@ def dic_color(img):
pdb.append(path)
## test
-test = glob("test_*")
+test = glob("dataset/test_*")
test.sort()
success_num = 0.
diff --git a/Question_81_90/answer_86.py b/Question_81_90/answers/answer_86.py
similarity index 96%
rename from Question_81_90/answer_86.py
rename to Question_81_90/answers/answer_86.py
index 697568ce..4eb112d2 100644
--- a/Question_81_90/answer_86.py
+++ b/Question_81_90/answers/answer_86.py
@@ -10,7 +10,7 @@ def dic_color(img):
return img
## Database
-train = glob("train_*")
+train = glob("dataset/train_*")
train.sort()
db = np.zeros((len(train), 13), dtype=np.int32)
@@ -33,7 +33,7 @@ def dic_color(img):
pdb.append(path)
## test
-test = glob("test_*")
+test = glob("dataset/test_*")
test.sort()
success_num = 0.
diff --git a/Question_81_90/answer_87.py b/Question_81_90/answers/answer_87.py
similarity index 96%
rename from Question_81_90/answer_87.py
rename to Question_81_90/answers/answer_87.py
index 18cdd4ec..a37a18d8 100644
--- a/Question_81_90/answer_87.py
+++ b/Question_81_90/answers/answer_87.py
@@ -10,7 +10,7 @@ def dic_color(img):
return img
## Database
-train = glob("train_*")
+train = glob("dataset/train_*")
train.sort()
db = np.zeros((len(train), 13), dtype=np.int32)
@@ -33,7 +33,7 @@ def dic_color(img):
pdb.append(path)
## test
-test = glob("test_*")
+test = glob("dataset/test_*")
test.sort()
success_num = 0.
diff --git a/Question_81_90/answer_88.py b/Question_81_90/answers/answer_88.py
similarity index 97%
rename from Question_81_90/answer_88.py
rename to Question_81_90/answers/answer_88.py
index 48f79f45..45b5af64 100644
--- a/Question_81_90/answer_88.py
+++ b/Question_81_90/answers/answer_88.py
@@ -10,7 +10,7 @@ def dic_color(img):
return img
## Database
-train = glob("test_*")
+train = glob("dataset/test_*")
train.sort()
db = np.zeros((len(train), 13), dtype=np.int32)
diff --git a/Question_81_90/answer_89.py b/Question_81_90/answers/answer_89.py
similarity index 97%
rename from Question_81_90/answer_89.py
rename to Question_81_90/answers/answer_89.py
index 9469c39c..15bb663a 100644
--- a/Question_81_90/answer_89.py
+++ b/Question_81_90/answers/answer_89.py
@@ -10,7 +10,7 @@ def dic_color(img):
return img
## Database
-train = glob("test_*")
+train = glob("dataset/test_*")
train.sort()
db = np.zeros((len(train), 13), dtype=np.int32)
diff --git a/Question_81_90/answer_90.py b/Question_81_90/answers/answer_90.py
similarity index 97%
rename from Question_81_90/answer_90.py
rename to Question_81_90/answers/answer_90.py
index 9dc6c6a8..33390179 100644
--- a/Question_81_90/answer_90.py
+++ b/Question_81_90/answers/answer_90.py
@@ -10,7 +10,7 @@ def dic_color(img):
return img
## Database
-train = glob("train_*")
+train = glob("dataset/train_*")
train.sort()
db = np.zeros((len(train), 13), dtype=np.int32)
diff --git a/Question_81_90/test_akahara_1.jpg b/Question_81_90/dataset/test_akahara_1.jpg
similarity index 100%
rename from Question_81_90/test_akahara_1.jpg
rename to Question_81_90/dataset/test_akahara_1.jpg
diff --git a/Question_81_90/test_akahara_2.jpg b/Question_81_90/dataset/test_akahara_2.jpg
similarity index 100%
rename from Question_81_90/test_akahara_2.jpg
rename to Question_81_90/dataset/test_akahara_2.jpg
diff --git a/Question_81_90/test_madara_1.jpg b/Question_81_90/dataset/test_madara_1.jpg
similarity index 100%
rename from Question_81_90/test_madara_1.jpg
rename to Question_81_90/dataset/test_madara_1.jpg
diff --git a/Question_81_90/test_madara_2.jpg b/Question_81_90/dataset/test_madara_2.jpg
similarity index 100%
rename from Question_81_90/test_madara_2.jpg
rename to Question_81_90/dataset/test_madara_2.jpg
diff --git a/Question_81_90/train_akahara_1.jpg b/Question_81_90/dataset/train_akahara_1.jpg
similarity index 100%
rename from Question_81_90/train_akahara_1.jpg
rename to Question_81_90/dataset/train_akahara_1.jpg
diff --git a/Question_81_90/train_akahara_2.jpg b/Question_81_90/dataset/train_akahara_2.jpg
similarity index 100%
rename from Question_81_90/train_akahara_2.jpg
rename to Question_81_90/dataset/train_akahara_2.jpg
diff --git a/Question_81_90/train_akahara_3.jpg b/Question_81_90/dataset/train_akahara_3.jpg
similarity index 100%
rename from Question_81_90/train_akahara_3.jpg
rename to Question_81_90/dataset/train_akahara_3.jpg
diff --git a/Question_81_90/train_akahara_4.jpg b/Question_81_90/dataset/train_akahara_4.jpg
similarity index 100%
rename from Question_81_90/train_akahara_4.jpg
rename to Question_81_90/dataset/train_akahara_4.jpg
diff --git a/Question_81_90/train_akahara_5.jpg b/Question_81_90/dataset/train_akahara_5.jpg
similarity index 100%
rename from Question_81_90/train_akahara_5.jpg
rename to Question_81_90/dataset/train_akahara_5.jpg
diff --git a/Question_81_90/train_madara_1.jpg b/Question_81_90/dataset/train_madara_1.jpg
similarity index 100%
rename from Question_81_90/train_madara_1.jpg
rename to Question_81_90/dataset/train_madara_1.jpg
diff --git a/Question_81_90/train_madara_2.jpg b/Question_81_90/dataset/train_madara_2.jpg
similarity index 100%
rename from Question_81_90/train_madara_2.jpg
rename to Question_81_90/dataset/train_madara_2.jpg
diff --git a/Question_81_90/train_madara_3.jpg b/Question_81_90/dataset/train_madara_3.jpg
similarity index 100%
rename from Question_81_90/train_madara_3.jpg
rename to Question_81_90/dataset/train_madara_3.jpg
diff --git a/Question_81_90/train_madara_4.jpg b/Question_81_90/dataset/train_madara_4.jpg
similarity index 100%
rename from Question_81_90/train_madara_4.jpg
rename to Question_81_90/dataset/train_madara_4.jpg
diff --git a/Question_81_90/train_madara_5.jpg b/Question_81_90/dataset/train_madara_5.jpg
similarity index 100%
rename from Question_81_90/train_madara_5.jpg
rename to Question_81_90/dataset/train_madara_5.jpg
diff --git a/Question_91_100/README.md b/Question_91_100/README.md
index eaebbc92..75818a9d 100644
--- a/Question_91_100/README.md
+++ b/Question_91_100/README.md
@@ -36,11 +36,11 @@
最初に選ばれた色との色の距離でクラスのインデックスをつけたもの(アルゴリズム2)。
解答では0-4にインデックスの値をx50にして見やすいようにしている。
-|入力 (imori.jpg) |出力(answer_91.jpg)|
+|入力 (imori.jpg) |出力(answers/answer_91.jpg)|
|:---:|:---:|
-|||
+|||
-答え >> [answer_91.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_91_100/answer_91.py)
+答え >> [answers/answer_91.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_91_100/answers/answer_91.py)
## Q.92. K-meansによる減色処理 (Step.2) 減色処理
@@ -59,11 +59,11 @@
また、k=5にして*madara.jpg*にも試してみよ。
-|入力 (imori.jpg) | 出力(answer_92.jpg) | k=10(answer_92_k10.jpg) |入力2 (madara.jpg) |出力(answer_92_m.jpg) |
+|入力 (imori.jpg) | 出力(answers/answer_92.jpg) | k=10(answers/answer_92_k10.jpg) |入力2 (madara.jpg) |出力(answers/answer_92_m.jpg) |
|:---:|:---:|:---:|:---:|:---:|
-||||||
+||||||
-答え >> [answer_92.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_91_100/answer_92.py)
+答え >> [answers/answer_92.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_91_100/answers/answer_92.py)
## Q.93. 機械学習の学習データの用意 (Step.1) IoUの計算
@@ -96,7 +96,7 @@ b = np.array((60, 60, 170, 160), dtype=np.float32)
```bash
0.627907
```
-答え >> [answer_93.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_91_100/answer_93.py)
+答え >> [answers/answer_93.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_91_100/answers/answer_93.py)
## Q.94. 機械学習の学習データの用意 (Step.2) ランダムクラッピング
@@ -111,11 +111,11 @@ b = np.array((60, 60, 170, 160), dtype=np.float32)
答えは、ラベル1の矩形を赤、ラベル0の矩形を青、GTを緑にしている。
これでイモリの顔の画像、それ以外の画像を簡易的に用意できた。
-|入力 (imori_1.jpg) |出力(answer_94.jpg)|
+|入力 (imori_1.jpg) |出力(answers/answer_94.jpg)|
|:---:|:---:|
-|||
+|||
-答え >> [answer_94.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_91_100/answer_94.py)
+答え >> [answers/answer_94.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_91_100/answers/answer_94.py)
## Q.95. ニューラルネットワーク (Step.1) ディープラーニングにする
@@ -191,7 +191,7 @@ in: [1. 0.] pred: [0.9641076]
in: [1. 1.] pred: [0.03937037]
```
-答え >> [answer_95.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_91_100/answer_95.py)
+答え >> [answers/answer_95.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_91_100/answers/answer_95.py)
## Q.96. ニューラルネットワーク (Step.2) 学習
@@ -207,7 +207,7 @@ in: [1. 1.] pred: [0.03937037]
Accuracy >> 1.0 (200.0 / 200)
```
-答え >> [answer_96.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_91_100/answer_96.py)
+答え >> [answers/answer_96.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_91_100/answers/answer_96.py)
## Q.97. 簡単な物体検出 (Step.1) スライディングウィンドウ + HOG
@@ -240,7 +240,7 @@ recs = np.array(((42, 42), (56, 56), (70, 70)), dtype=np.float32)
- 矩形部分を切り抜いたら、その部分を32x32にリサイズする。
- HOG特徴量の取得は8x8を1セルとする。
-答え >> [answer_97.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_91_100/answer_97.py)
+答え >> [answers/answer_97.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_91_100/answers/answer_97.py)
## Q.98. 簡単な物体検出 (Step.2) スライディングウィンドウ + NN
@@ -283,11 +283,11 @@ recs = np.array(((42, 42), (56, 56), (70, 70)), dtype=np.float32)
[ 97. 81. 167. 144. 0.70371708]]
```
-|入力 (imori_many.jpg) |出力(answer_98.jpg)|
+|入力 (imori_many.jpg) |出力(answers/answer_98.jpg)|
|:---:|:---:|
-|||
+|||
-解答 >> [answer_98.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_91_100/answer_98.py)
+解答 >> [answers/answer_98.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_91_100/answers/answer_98.py)
## Q.99. 簡単な物体検出 (Step.3) Non-Maximum Suppression
@@ -308,11 +308,11 @@ Q.98にNMS(閾値t=0.25)を組み込み、出力を描画せよ。
精度はともあれ、これで検出の一連の流れが完了した。
ニューラルネットの学習を増やしたりすることで、検出の精度は更に向上ができる。
-|入力 (imori_many.jpg) |NMS前(answer_98.jpg)|NMS後(answer_99.jpg)|
+|入力 (imori_many.jpg) |NMS前(answers/answer_98.jpg)|NMS後(answers/answer_99.jpg)|
|:---:|:---:|:---:|
-||||
+||||
-解答 >> [answer_99.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_91_100/answer_99.py)
+解答 >> [answers/answer_99.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_91_100/answers/answer_99.py)
## Q.100. 簡単な物体検出 (Step.4) 評価 Precision, Recall, F-score, mAP
@@ -385,8 +385,8 @@ F-score >> 0.4
mAP >> 0.0625
```
-|入力 (imori_many.jpg) |GT(answer_100_gt.jpg)|出力(answer_100.jpg)|
+|入力 (imori_many.jpg) |GT(answers/answer_100_gt.jpg)|出力(answers/answer_100.jpg)|
|:---:|:---:|:---:|
-||||
+||||
-解答 >> [answer_100.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_91_100/answer_100.py)
+解答 >> [answers/answer_100.py](https://github.com/yoyoyo-yo/Gasyori100knock/blob/master/Question_91_100/answers/answer_100.py)
diff --git a/Question_91_100/answer_100.jpg b/Question_91_100/answers/answer_100.jpg
similarity index 100%
rename from Question_91_100/answer_100.jpg
rename to Question_91_100/answers/answer_100.jpg
diff --git a/Question_91_100/answer_100.py b/Question_91_100/answers/answer_100.py
similarity index 100%
rename from Question_91_100/answer_100.py
rename to Question_91_100/answers/answer_100.py
diff --git a/Question_91_100/answer_100_gt.jpg b/Question_91_100/answers/answer_100_gt.jpg
similarity index 100%
rename from Question_91_100/answer_100_gt.jpg
rename to Question_91_100/answers/answer_100_gt.jpg
diff --git a/Question_91_100/answer_91.jpg b/Question_91_100/answers/answer_91.jpg
similarity index 100%
rename from Question_91_100/answer_91.jpg
rename to Question_91_100/answers/answer_91.jpg
diff --git a/Question_91_100/answer_91.py b/Question_91_100/answers/answer_91.py
similarity index 100%
rename from Question_91_100/answer_91.py
rename to Question_91_100/answers/answer_91.py
diff --git a/Question_91_100/answer_92.jpg b/Question_91_100/answers/answer_92.jpg
similarity index 100%
rename from Question_91_100/answer_92.jpg
rename to Question_91_100/answers/answer_92.jpg
diff --git a/Question_91_100/answer_92.py b/Question_91_100/answers/answer_92.py
similarity index 100%
rename from Question_91_100/answer_92.py
rename to Question_91_100/answers/answer_92.py
diff --git a/Question_91_100/answer_92_k10.jpg b/Question_91_100/answers/answer_92_k10.jpg
similarity index 100%
rename from Question_91_100/answer_92_k10.jpg
rename to Question_91_100/answers/answer_92_k10.jpg
diff --git a/Question_91_100/answer_92_m.jpg b/Question_91_100/answers/answer_92_m.jpg
similarity index 100%
rename from Question_91_100/answer_92_m.jpg
rename to Question_91_100/answers/answer_92_m.jpg
diff --git a/Question_91_100/answer_93.py b/Question_91_100/answers/answer_93.py
similarity index 100%
rename from Question_91_100/answer_93.py
rename to Question_91_100/answers/answer_93.py
diff --git a/Question_91_100/answer_94.jpg b/Question_91_100/answers/answer_94.jpg
similarity index 100%
rename from Question_91_100/answer_94.jpg
rename to Question_91_100/answers/answer_94.jpg
diff --git a/Question_91_100/answer_94.py b/Question_91_100/answers/answer_94.py
similarity index 100%
rename from Question_91_100/answer_94.py
rename to Question_91_100/answers/answer_94.py
diff --git a/Question_91_100/answer_95.py b/Question_91_100/answers/answer_95.py
similarity index 100%
rename from Question_91_100/answer_95.py
rename to Question_91_100/answers/answer_95.py
diff --git a/Question_91_100/answer_96.py b/Question_91_100/answers/answer_96.py
similarity index 100%
rename from Question_91_100/answer_96.py
rename to Question_91_100/answers/answer_96.py
diff --git a/Question_91_100/answer_97.py b/Question_91_100/answers/answer_97.py
similarity index 100%
rename from Question_91_100/answer_97.py
rename to Question_91_100/answers/answer_97.py
diff --git a/Question_91_100/answer_98.jpg b/Question_91_100/answers/answer_98.jpg
similarity index 100%
rename from Question_91_100/answer_98.jpg
rename to Question_91_100/answers/answer_98.jpg
diff --git a/Question_91_100/answer_98.py b/Question_91_100/answers/answer_98.py
similarity index 100%
rename from Question_91_100/answer_98.py
rename to Question_91_100/answers/answer_98.py
diff --git a/Question_91_100/answer_99.jpg b/Question_91_100/answers/answer_99.jpg
similarity index 100%
rename from Question_91_100/answer_99.jpg
rename to Question_91_100/answers/answer_99.jpg
diff --git a/Question_91_100/answer_99.py b/Question_91_100/answers/answer_99.py
similarity index 100%
rename from Question_91_100/answer_99.py
rename to Question_91_100/answers/answer_99.py
diff --git a/README.md b/README.md
index 7999a7e3..f1c90f81 100644
--- a/README.md
+++ b/README.md
@@ -11,7 +11,10 @@ English is here >> https://github.com/KuKuXia/Image_Processing_100_Questions Ku
- 【注意】このページを利用して、または関して生じた事に関しては、私は一切責任を負いません。すべて**自己責任**でお願い致します。
+**ディープラーニングのノックはこっち** >> https://github.com/yoyoyo-yo/DeepLearningMugenKnock
+
## Recent
+- 2019.3.5 各Questionの答えをanswersディレクトリに収納
- 2019.3.3 Q.18-22. 一部修正
- 2019.2.26 Q.10. メディアンフィルタの解答を一部修正
- 2019.2.25 Q.9. ガウシアンフィルタの解答を一部修正
@@ -86,7 +89,7 @@ https://qiita.com/karaage0703/items/e0b57b63dbebed908b2f
次に画像処理に関するnumpyの扱い方のために**Tutorial**フォルダを見てみて下さい。(もう知ってるという人はスキップして下さい。)
-あとは問題を解いていってください。それぞれのフォルダに問題内容が入っています。問題では assets/imori.jpg を使用して下さい。各フォルダのREADME.mdに問題、解答プログラムがあります。python answer_@@.py とすると解答が出ます。
+あとは問題を解いていってください。それぞれのフォルダに問題内容が入っています。問題では assets/imori.jpg を使用して下さい。各フォルダのREADME.mdに問題、解答プログラムがあります。```python answers/answer_@@.py``` とすると解答が出ます。
## 問題
diff --git a/answer_adaptive2.py b/answer_adaptive2.py
new file mode 100644
index 00000000..5931604e
--- /dev/null
+++ b/answer_adaptive2.py
@@ -0,0 +1,29 @@
+import cv2
+import numpy as np
+import matplotlib.pyplot as plt
+
+# Read image
+img = cv2.imread("imori2.jpg").astype(np.float32)
+H, W, C = img.shape
+
+# Grayscale
+gray = 0.2126 * img[..., 2] + 0.7152 * img[..., 1] + 0.0722 * img[..., 0]
+
+# Magnitude and gradient
+#gray = np.pad(gray, (1, 1), 'edge')
+out = np.zeros_like(gray)
+
+N = 9
+D = N // 2
+for y in range(H):
+ for x in range(W):
+ th = np.mean(gray[max(y-D,0):min(y+1+D,H), max(x-D,0):min(x+1+D,W)])
+ out[y,x] = 255 if gray[y,x] > th else 0
+
+out = out.astype(np.uint8)
+
+# Save result
+cv2.imwrite("out.jpg", out)
+cv2.imshow("result", out)
+cv2.waitKey(0)
+cv2.destroyAllWindows()
diff --git a/trace.py b/trace.py
new file mode 100644
index 00000000..3eeb67b6
--- /dev/null
+++ b/trace.py
@@ -0,0 +1,104 @@
+import cv2
+import numpy as np
+import matplotlib.pyplot as plt
+
+# Read image
+img = cv2.imread("gazo.png").astype(np.float32)
+H, W, C = img.shape
+
+tmp = np.zeros((H, W), dtype=np.int)
+tmp[img[..., 0] > 0] = 255
+
+out = np.zeros_like(tmp)
+
+flag = False
+for y in range(H):
+ for x in range(W):
+ if flag:
+ continue
+ if tmp[y, x] == 255:
+ tx = x
+ ty = y
+ pre = 7
+ while True:
+ print(tx, ty)
+
+ if tmp[min(ty+1, H-1), max(tx-1,0)] == 255 and out[min(ty+1, H-1), max(tx-1,0)] == 0:
+ tx = max(tx-1, 0)
+ ty = min(ty+1, H-1)
+ out[ty, tx] = 255
+ pre = 0
+ if tx == x and ty == y:
+ flag = True
+ break
+ continue
+ if tmp[min(ty+1, H-1), tx] == 255 and out[min(ty+1, H-1), tx] == 0:
+ tx = tx
+ ty = min(ty+1, H-1)
+ out[ty, tx] = 255
+ pre = 1
+ if tx == x and ty == y:
+ flag = True
+ break
+ continue
+ if tmp[min(ty+1, H-1), min(tx+1, W-1)] == 255 and out[min(ty+1, H-1), min(tx+1, W-1)] == 0:
+ tx = min(tx+1, W-1)
+ ty = min(ty+1, H-1)
+ out[ty, tx] = 255
+ pre = 2
+ if tx == x and ty == y:
+ flag = True
+ break
+ continue
+ if tmp[ty, min(tx+1, W-1)] == 255 and out[ty, min(tx+1, W-1)] == 0:
+ tx = min(tx+1, W-1)
+ ty = ty
+ out[ty, tx] = 255
+ pre = 3
+ if tx == x and ty == y:
+ flag = True
+ break
+ continue
+ if tmp[max(ty-1, 0), min(tx+1, W-1)] == 255 and out[max(ty-1, 0), min(tx+1, W-1)] == 0:
+ tx = min(tx+1, W-1)
+ ty = max(ty-1, 0)
+ out[ty, tx] = 255
+ pre = 4
+ if tx == x and ty == y:
+ flag = True
+ break
+ continue
+ if tmp[max(ty-1, 0), tx] == 255 and out[max(ty-1, 0), tx] == 0:
+ tx = tx
+ ty = max(ty-1, 0)
+ out[ty, tx] = 255
+ pre = 5
+ if tx == x and ty == y:
+ flag = True
+ break
+ continue
+ if tmp[max(ty-1, 0), max(tx-1, 0)] == 255 and out[max(ty-1, 0), max(tx-1, 0)] == 0:
+ tx = max(tx-1, 0)
+ ty = max(ty-1, 0)
+ out[ty, tx] = 255
+ pre = 6
+ if tx == x and ty == y:
+ flag = True
+ break
+ continue
+ if tmp[ty, max(tx-1, 0)] == 255 and out[ty, max(tx-1, 0)] == 0:
+ tx = max(tx-1, 0)
+ ty = ty
+ out[ty, tx] = 255
+ pre = 7
+ if tx == x and ty == y:
+ flag = True
+ break
+ continue
+
+out = out.astype(np.uint8)
+
+# Save result
+cv2.imshow("result", out)
+cv2.waitKey(0)
+cv2.imwrite("out.jpg", out)
diff --git a/yobi/crop.py b/yobi/crop.py
new file mode 100644
index 00000000..d06be275
--- /dev/null
+++ b/yobi/crop.py
@@ -0,0 +1,46 @@
+import cv2
+import numpy as np
+
+# read image
+img = cv2.imread("imori_1.jpg")
+H, W, C = img.shape
+
+gt = np.array((47, 41, 129, 103), dtype=np.float32)
+cv2.rectangle(img, (gt[0], gt[1]), (gt[2], gt[3]), (0,255,255), 1)
+
+def iou(a, b):
+ area_a = (a[2] - a[0]) * (a[3] - a[1])
+ area_b = (b[2] - b[0]) * (b[3] - b[1])
+ iou_x1 = np.maximum(a[0], b[0])
+ iou_y1 = np.maximum(a[1], b[1])
+ iou_x2 = np.minimum(a[2], b[2])
+ iou_y2 = np.minimum(a[3], b[3])
+ iou_w = max(iou_x2 - iou_x1, 0)
+ iou_h = max(iou_y2 - iou_y1, 0)
+ area_iou = iou_w * iou_h
+ iou = area_iou / (area_a + area_b - area_iou)
+ return iou
+
+np.random.seed(0)
+
+Crop_num = 100
+L = 56
+
+for _ in range(Crop_num):
+
+ x1 = np.random.randint(W-L)
+ y1 = np.random.randint(H-L)
+ x2 = x1 + L
+ y2 = y1 + L
+
+ crop = np.array((x1, y1, x2, y2))
+
+ _iou = iou(gt, crop)
+
+ if _iou >= 0.5:
+ cv2.rectangle(img, (x1, y1), (x2, y2), (0,0,255), 1)
+ else:
+ cv2.rectangle(img, (x1, y1), (x2, y2), (255,0,0), 1)
+
+cv2.imshow("", img)
+cv2.waitKey(0)
diff --git a/yobi/crop_hog.py b/yobi/crop_hog.py
new file mode 100644
index 00000000..3dc4b7e0
--- /dev/null
+++ b/yobi/crop_hog.py
@@ -0,0 +1,184 @@
+import cv2
+import numpy as np
+
+np.random.seed(0)
+
+# read image
+img = cv2.imread("imori_1.jpg")
+H, W, C = img.shape
+
+# Grayscale
+gray = 0.2126 * img[..., 2] + 0.7152 * img[..., 1] + 0.0722 * img[..., 0]
+
+gt = np.array((47, 41, 129, 103), dtype=np.float32)
+
+#gt = np.array((41, 3, 83, 32), dtype=np.float32)
+#gt2 = np.array((123, 41, 161, 74), dtype=np.float32)
+#gt3 = np.array((97, 83, 137, 113), dtype=np.float32)
+cv2.rectangle(img, (gt[0], gt[1]), (gt[2], gt[3]), (0,255,255), 1)
+#cv2.rectangle(img, (gt2[0], gt2[1]), (gt2[2], gt2[3]), (0,255,255), 1)
+#cv2.rectangle(img, (gt3[0], gt3[1]), (gt3[2], gt3[3]), (0,255,255), 1)
+
+def iou(a, b):
+ area_a = (a[2] - a[0]) * (a[3] - a[1])
+ area_b = (b[2] - b[0]) * (b[3] - b[1])
+ iou_x1 = np.maximum(a[0], b[0])
+ iou_y1 = np.maximum(a[1], b[1])
+ iou_x2 = np.minimum(a[2], b[2])
+ iou_y2 = np.minimum(a[3], b[3])
+ iou_w = max(iou_x2 - iou_x1, 0)
+ iou_h = max(iou_y2 - iou_y1, 0)
+ area_iou = iou_w * iou_h
+ iou = area_iou / (area_a + area_b - area_iou)
+ return iou
+
+
+def hog(gray):
+ h, w = gray.shape
+ # Magnitude and gradient
+ gray = np.pad(gray, (1, 1), 'edge')
+
+ gx = gray[1:h+1, 2:] - gray[1:h+1, :w]
+ gy = gray[2:, 1:w+1] - gray[:h, 1:w+1]
+ gx[gx == 0] = 0.000001
+
+ mag = np.sqrt(gx ** 2 + gy ** 2)
+ gra = np.arctan(gy / gx)
+ gra[gra<0] = np.pi / 2 + gra[gra < 0] + np.pi / 2
+
+ # Gradient histogram
+ gra_n = np.zeros_like(gra, dtype=np.int)
+
+ d = np.pi / 9
+ for i in range(9):
+ gra_n[np.where((gra >= d * i) & (gra <= d * (i+1)))] = i
+
+ N = 8
+ HH = h // N
+ HW = w // N
+ Hist = np.zeros((HH, HW, 9), dtype=np.float32)
+ for y in range(HH):
+ for x in range(HW):
+ for j in range(N):
+ for i in range(N):
+ Hist[y, x, gra_n[y*4+j, x*4+i]] += mag[y*4+j, x*4+i]
+
+ ## Normalization
+ C = 3
+ eps = 1
+ for y in range(HH):
+ for x in range(HW):
+ #for i in range(9):
+ Hist[y, x] /= np.sqrt(np.sum(Hist[max(y-1,0):min(y+2, HH), max(x-1,0):min(x+2, HW)] ** 2) + eps)
+
+ return Hist
+
+def resize(img, h, w):
+ _h, _w = img.shape
+ ah = 1. * h / _h
+ aw = 1. * w / _w
+ y = np.arange(h).repeat(w).reshape(w, -1)
+ x = np.tile(np.arange(w), (h, 1))
+ y = (y / ah)
+ x = (x / aw)
+
+ ix = np.floor(x).astype(np.int32)
+ iy = np.floor(y).astype(np.int32)
+ ix = np.minimum(ix, _w-2)
+ iy = np.minimum(iy, _h-2)
+
+ dx = x - ix
+ dy = y - iy
+
+ out = (1-dx) * (1-dy) * img[iy, ix] + dx * (1 - dy) * img[iy, ix+1] + (1 - dx) * dy * img[iy+1, ix] + dx * dy * img[iy+1, ix+1]
+ out[out>255] = 255
+
+ return out
+
+
+# crop and create database
+
+Crop_num = 300
+L = 60
+
+H_size = 32
+F_n = ((H_size // 8) ** 2) * 9
+
+db = np.zeros((Crop_num, F_n + 1))
+
+for i in range(Crop_num):
+ x1 = np.random.randint(W-L)
+ y1 = np.random.randint(H-L)
+ x2 = x1 + L
+ y2 = y1 + L
+ crop = np.array((x1, y1, x2, y2))
+
+ _iou = np.zeros((3,))
+ _iou[0] = iou(gt, crop)
+ #_iou[1] = iou(gt2, crop)
+ #_iou[2] = iou(gt3, crop)
+
+ if _iou.max() >= 0.5:
+ cv2.rectangle(img, (x1, y1), (x2, y2), (0,0,255), 1)
+ label = 0
+ else:
+ cv2.rectangle(img, (x1, y1), (x2, y2), (255,0,0), 1)
+ label = 1
+
+ crop_area = gray[y1:y2, x1:x2]
+ crop_area = resize(crop_area, H_size, H_size)
+ _hog = hog(crop_area)
+
+ db[i, :F_n] = _hog.ravel()
+ db[i, -1] = label
+
+ #cv2.rectangle(img, (x1, y1), (x2, y2), (255, 0,0), 1)
+
+cv2.imshow("re", img)
+cv2.waitKey(0)
+
+from sklearn import svm
+clf = svm.SVC(kernel='linear')
+clf.fit(X=db[..., :F_n], y=db[..., -1])
+
+
+# read detect target image
+img2 = cv2.imread("imori_many.jpg")
+H2, W2, C2 = img2.shape
+
+# Grayscale
+gray2 = 0.2126 * img2[..., 2] + 0.7152 * img2[..., 1] + 0.0722 * img2[..., 0]
+
+# [h, w]
+recs = np.array(((42, 42), (56, 56), (70, 70)), dtype=np.float32)
+
+# sliding window
+for y in range(0, H2, 4):
+ for x in range(0, W2, 4):
+ for rec in recs:
+ dh = int(rec[0] // 2)
+ dw = int(rec[1] // 2)
+ x1 = max(x-dw, 0)
+ x2 = min(x+dw, W2)
+ y1 = max(y-dh, 0)
+ y2 = min(y+dh, H2)
+ region = gray2[max(y-dh,0):min(y+dh,H2), max(x-dw,0):min(x+dw,W2)]
+ region = resize(region, H_size, H_size)
+ r_hog = hog(region).ravel()
+
+ f_dif = np.sum(np.abs(db[:, :F_n] - r_hog) ** 2)
+ min_arg = np.argsort(f_dif)[:5]
+ pred = db[min_arg, -1]
+
+ #if len(np.where(pred==0)[0]) > 0:
+ # cv2.rectangle(img2, (x1, y1), (x2, y2), (0,0,255), 1)
+
+ pred = clf.predict(r_hog[None, ...])[0]
+ if pred == 0:
+ cv2.rectangle(img2, (x1, y1), (x2, y2), (0,0,255), 1)
+ print(y, x)
+
+
+#print(db)
+cv2.imshow("", img2)
+cv2.waitKey(0)
diff --git a/yobi/crop_hog_nn.py b/yobi/crop_hog_nn.py
new file mode 100644
index 00000000..777330fb
--- /dev/null
+++ b/yobi/crop_hog_nn.py
@@ -0,0 +1,294 @@
+import cv2
+import numpy as np
+
+np.random.seed(0)
+
+# read image
+img = cv2.imread("imori_1.jpg")
+H, W, C = img.shape
+
+# Grayscale
+gray = 0.2126 * img[..., 2] + 0.7152 * img[..., 1] + 0.0722 * img[..., 0]
+
+gt = np.array((47, 41, 129, 103), dtype=np.float32)
+
+#gt = np.array((41, 3, 83, 32), dtype=np.float32)
+#gt2 = np.array((123, 41, 161, 74), dtype=np.float32)
+#gt3 = np.array((97, 83, 137, 113), dtype=np.float32)
+cv2.rectangle(img, (gt[0], gt[1]), (gt[2], gt[3]), (0,255,255), 1)
+#cv2.rectangle(img, (gt2[0], gt2[1]), (gt2[2], gt2[3]), (0,255,255), 1)
+#cv2.rectangle(img, (gt3[0], gt3[1]), (gt3[2], gt3[3]), (0,255,255), 1)
+
+def iou(a, b):
+ area_a = (a[2] - a[0]) * (a[3] - a[1])
+ area_b = (b[2] - b[0]) * (b[3] - b[1])
+ iou_x1 = np.maximum(a[0], b[0])
+ iou_y1 = np.maximum(a[1], b[1])
+ iou_x2 = np.minimum(a[2], b[2])
+ iou_y2 = np.minimum(a[3], b[3])
+ iou_w = max(iou_x2 - iou_x1, 0)
+ iou_h = max(iou_y2 - iou_y1, 0)
+ area_iou = iou_w * iou_h
+ iou = area_iou / (area_a + area_b - area_iou)
+ return iou
+
+
+def hog(gray):
+ h, w = gray.shape
+ # Magnitude and gradient
+ gray = np.pad(gray, (1, 1), 'edge')
+
+ gx = gray[1:h+1, 2:] - gray[1:h+1, :w]
+ gy = gray[2:, 1:w+1] - gray[:h, 1:w+1]
+ gx[gx == 0] = 0.000001
+
+ mag = np.sqrt(gx ** 2 + gy ** 2)
+ gra = np.arctan(gy / gx)
+ gra[gra<0] = np.pi / 2 + gra[gra < 0] + np.pi / 2
+
+ # Gradient histogram
+ gra_n = np.zeros_like(gra, dtype=np.int)
+
+ d = np.pi / 9
+ for i in range(9):
+ gra_n[np.where((gra >= d * i) & (gra <= d * (i+1)))] = i
+
+ N = 8
+ HH = h // N
+ HW = w // N
+ Hist = np.zeros((HH, HW, 9), dtype=np.float32)
+ for y in range(HH):
+ for x in range(HW):
+ for j in range(N):
+ for i in range(N):
+ Hist[y, x, gra_n[y*4+j, x*4+i]] += mag[y*4+j, x*4+i]
+
+ ## Normalization
+ C = 3
+ eps = 1
+ for y in range(HH):
+ for x in range(HW):
+ #for i in range(9):
+ Hist[y, x] /= np.sqrt(np.sum(Hist[max(y-1,0):min(y+2, HH), max(x-1,0):min(x+2, HW)] ** 2) + eps)
+
+ return Hist
+
+def resize(img, h, w):
+ _h, _w = img.shape
+ ah = 1. * h / _h
+ aw = 1. * w / _w
+ y = np.arange(h).repeat(w).reshape(w, -1)
+ x = np.tile(np.arange(w), (h, 1))
+ y = (y / ah)
+ x = (x / aw)
+
+ ix = np.floor(x).astype(np.int32)
+ iy = np.floor(y).astype(np.int32)
+ ix = np.minimum(ix, _w-2)
+ iy = np.minimum(iy, _h-2)
+
+ dx = x - ix
+ dy = y - iy
+
+ out = (1-dx) * (1-dy) * img[iy, ix] + dx * (1 - dy) * img[iy, ix+1] + (1 - dx) * dy * img[iy+1, ix] + dx * dy * img[iy+1, ix+1]
+ out[out>255] = 255
+
+ return out
+
+
+class NN:
+ def __init__(self, ind=2, w=64, w2=64, outd=1, lr=0.1):
+ self.w2 = np.random.randn(ind, w)
+ self.b2 = np.random.randn(w)
+ self.w3 = np.random.randn(w, w2)
+ self.b3 = np.random.randn(w2)
+ self.wout = np.random.randn(w2, outd)
+ self.bout = np.random.randn(outd)
+ self.lr = lr
+
+ def forward(self, x):
+ self.z1 = x
+ self.z2 = self.sigmoid(np.dot(self.z1, self.w2) + self.b2)
+ self.z3 = self.sigmoid(np.dot(self.z2, self.w3) + self.b3)
+ self.out = self.sigmoid(np.dot(self.z3, self.wout) + self.bout)
+ return self.out
+
+ def train(self, x, t):
+ # backpropagation output layer
+ out_d = 2*(self.out - t) * self.out * (1 - self.out)
+ out_dW = np.dot(self.z3.T, out_d)
+ out_dB = np.dot(np.ones([1, out_d.shape[0]]), out_d)
+ self.wout -= self.lr * out_dW
+ self.bout -= self.lr * out_dB[0]
+
+ w3_d = np.dot(out_d, self.wout.T) * self.z3 * (1 - self.z3)
+ w3_dW = np.dot(self.z2.T, w3_d)
+ w3_dB = np.dot(np.ones([1, w3_d.shape[0]]), w3_d)
+ self.w3 -= self.lr * w3_dW
+ self.b3 -= self.lr * w3_dB[0]
+
+ # backpropagation inter layer
+ w2_d = np.dot(w3_d, self.w3.T) * self.z2 * (1 - self.z2)
+ w2_dW = np.dot(self.z1.T, w2_d)
+ w2_dB = np.dot(np.ones([1, w2_d.shape[0]]), w2_d)
+ self.w2 -= self.lr * w2_dW
+ self.b2 -= self.lr * w2_dB[0]
+
+ def sigmoid(self, x):
+ return 1. / (1. + np.exp(-x))
+
+# crop and create database
+
+Crop_num = 200
+L = 60
+H_size = 32
+F_n = ((H_size // 8) ** 2) * 9
+
+db = np.zeros((Crop_num, F_n+1))
+
+for i in range(Crop_num):
+ x1 = np.random.randint(W-L)
+ y1 = np.random.randint(H-L)
+ x2 = x1 + L
+ y2 = y1 + L
+ crop = np.array((x1, y1, x2, y2))
+
+ _iou = np.zeros((3,))
+ _iou[0] = iou(gt, crop)
+ #_iou[1] = iou(gt2, crop)
+ #_iou[2] = iou(gt3, crop)
+
+ if _iou.max() >= 0.5:
+ cv2.rectangle(img, (x1, y1), (x2, y2), (0,0,255), 1)
+ label = 1
+ else:
+ cv2.rectangle(img, (x1, y1), (x2, y2), (255,0,0), 1)
+ label = 0
+
+ crop_area = gray[y1:y2, x1:x2]
+ crop_area = resize(crop_area, H_size, H_size)
+ _hog = hog(crop_area)
+
+ db[i, :F_n] = _hog.ravel()
+ db[i, -1] = label
+
+ #cv2.rectangle(img, (x1, y1), (x2, y2), (255, 0,0), 1)
+
+#cv2.imshow("re", img)
+#cv2.waitKey(0)
+
+#print(db[:, :F_n].shape)
+#print(db[:, -1][..., None].shape)
+
+## training neural network
+nn = NN(ind=F_n, lr=0.01)
+for i in range(10000):
+ nn.forward(db[:, :F_n])
+ nn.train(db[:, :F_n], db[:, -1][..., None])
+
+
+# read detect target image
+img2 = cv2.imread("imori_many.jpg")
+H2, W2, C2 = img2.shape
+
+# Grayscale
+gray2 = 0.2126 * img2[..., 2] + 0.7152 * img2[..., 1] + 0.0722 * img2[..., 0]
+
+# [h, w]
+recs = np.array(((42, 42), (56, 56), (70, 70)), dtype=np.float32)
+
+detects = np.ndarray((0, 5), dtype=np.float32)
+
+# sliding window
+for y in range(0, H2, 4):
+ for x in range(0, W2, 4):
+ for rec in recs:
+ dh = int(rec[0] // 2)
+ dw = int(rec[1] // 2)
+ x1 = max(x-dw, 0)
+ x2 = min(x+dw, W2)
+ y1 = max(y-dh, 0)
+ y2 = min(y+dh, H2)
+ region = gray2[max(y-dh,0):min(y+dh,H2), max(x-dw,0):min(x+dw,W2)]
+ region = resize(region, H_size, H_size)
+ region_hog = hog(region).ravel()
+
+ score = nn.forward(region_hog)
+ if score >= 0.7:
+ cv2.rectangle(img2, (x1, y1), (x2, y2), (0,0,255), 1)
+ detects = np.vstack((detects, np.array((x1, y1, x2, y2, score))))
+ #if pred == 0:
+ # cv2.rectangle(img2, (x1, y1), (x2, y2), (0,0,255), 1)
+ print(y, x)
+
+print(detects)
+
+
+def nms(bboxes, iou_th=0.5, select_num=None, prob_th=None):
+
+ bboxes[:, 2] = bboxes[:, 2] - bboxes[:, 0]
+ bboxes[:, 3] = bboxes[:, 3] - bboxes[:, 1]
+
+ # Sort by bbox's score. High -> Low
+ sort_inds = np.argsort(bboxes[:, -1])[::-1]
+
+ processed_bbox_ind = []
+ return_inds = []
+
+ unselected_inds = sort_inds.copy()
+
+ while len(unselected_inds) > 0:
+ process_bboxes = bboxes[unselected_inds]
+ argmax_score_ind = np.argmax(process_bboxes[::, -1])
+ max_score_ind = unselected_inds[argmax_score_ind]
+ return_inds += [max_score_ind]
+ unselected_inds = np.delete(unselected_inds, argmax_score_ind)
+
+ base_bbox = bboxes[max_score_ind]
+ compare_bboxes = bboxes[unselected_inds]
+
+ base_x1 = base_bbox[0]
+ base_y1 = base_bbox[1]
+ base_x2 = base_bbox[2] + base_x1
+ base_y2 = base_bbox[3] + base_y1
+ base_w = np.maximum(base_bbox[2], 0)
+ base_h = np.maximum(base_bbox[3], 0)
+ base_area = base_w * base_h
+
+ # compute iou-area between base bbox and other bboxes
+ iou_x1 = np.maximum(base_x1, compare_bboxes[:, 0])
+ iou_y1 = np.maximum(base_y1, compare_bboxes[:, 1])
+ iou_x2 = np.minimum(base_x2, compare_bboxes[:, 2] + compare_bboxes[:, 0])
+ iou_y2 = np.minimum(base_y2, compare_bboxes[:, 3] + compare_bboxes[:, 1])
+ iou_w = np.maximum(iou_x2 - iou_x1, 0)
+ iou_h = np.maximum(iou_y2 - iou_y1, 0)
+ iou_area = iou_w * iou_h
+
+ compare_w = np.maximum(compare_bboxes[:, 2], 0)
+ compare_h = np.maximum(compare_bboxes[:, 3], 0)
+ compare_area = compare_w * compare_h
+
+ # bbox's index which iou ratio over threshold is excluded
+ all_area = compare_area + base_area - iou_area
+ iou_ratio = np.zeros((len(unselected_inds)))
+ iou_ratio[all_area < 0.9] = 0.
+ _ind = all_area >= 0.9
+ iou_ratio[_ind] = iou_area[_ind] / all_area[_ind]
+
+ unselected_inds = np.delete(unselected_inds, np.where(iou_ratio >= iou_th)[0])
+
+ if prob_th is not None:
+ preds = bboxes[return_inds][:, -1]
+ return_inds = np.array(return_inds)[np.where(preds >= prob_th)[0]].tolist()
+
+ # pick bbox's index by defined number with higher score
+ if select_num is not None:
+ return_inds = return_inds[:select_num]
+
+ return return_inds
+
+detects = detects[nms(detects, iou_th=0.7)]
+
+#print(db)
+cv2.imshow("", img2)
+cv2.waitKey(0)
diff --git a/yobi/hog.py b/yobi/hog.py
new file mode 100644
index 00000000..36f723b9
--- /dev/null
+++ b/yobi/hog.py
@@ -0,0 +1,84 @@
+import cv2
+import numpy as np
+import matplotlib.pyplot as plt
+from glob import glob
+
+img = cv2.imread("imori.jpg").astype(np.float32)
+H, W, C = img.shape
+
+# Grayscale
+gray = 0.2126 * img[..., 2] + 0.7152 * img[..., 1] + 0.0722 * img[..., 0]
+
+def hog(gray):
+ # Magnitude and gradient
+ gray = np.pad(gray, (1, 1), 'edge')
+
+ gx = gray[1:H+1, 2:] - gray[1:H+1, :W]
+ gy = gray[2:, 1:W+1] - gray[:H, 1:W+1]
+ gx[gx == 0] = 0.000001
+
+ mag = np.sqrt(gx ** 2 + gy ** 2)
+ gra = np.arctan(gy / gx)
+ gra[gra<0] = np.pi / 2 + gra[gra < 0] + np.pi / 2
+
+ # Gradient histogram
+ gra_n = np.zeros_like(gra, dtype=np.int)
+
+ d = np.pi / 9
+ for i in range(9):
+ gra_n[np.where((gra >= d * i) & (gra <= d * (i+1)))] = i
+
+
+ N = 8
+ HH = H // N
+ HW = W // N
+ Hist = np.zeros((HH, HW, 9), dtype=np.float32)
+ for y in range(HH):
+ for x in range(HW):
+ for j in range(N):
+ for i in range(N):
+ Hist[y, x, gra_n[y*4+j, x*4+i]] += mag[y*4+j, x*4+i]
+
+ ## Normalization
+ C = 3
+ eps = 1
+ for y in range(HH):
+ for x in range(HW):
+ #for i in range(9):
+ Hist[y, x] /= np.sqrt(np.sum(Hist[max(y-1,0):min(y+2, HH), max(x-1,0):min(x+2, HW)] ** 2) + eps)
+
+ return Hist
+
+
+train = glob("../Question_81_90/train_*")
+train.sort()
+
+fs = np.zeros((len(train), 16*16*9))
+ls = np.zeros((len(train)))
+
+for i, path in enumerate(train):
+ img = cv2.imread(path).astype(np.float32)
+ # Grayscale
+ gray = 0.2126 * img[..., 2] + 0.7152 * img[..., 1] + 0.0722 * img[..., 0]
+ fs[i] = hog(gray).ravel()
+ ls[i] = 0 if 'akahara' in path else 1
+
+from sklearn import svm
+clf = svm.SVC(kernel='linear')
+clf.fit(X=fs, y=ls)
+
+
+img = cv2.imread("imori.jpg").astype(np.float32)
+gray = 0.2126 * img[..., 2] + 0.7152 * img[..., 1] + 0.0722 * img[..., 0]
+
+f = hog(gray).ravel()
+f = f[None, ...]
+print(clf.predict(f))
+
+
+img = cv2.imread("madara.jpg").astype(np.float32)
+gray = 0.2126 * img[..., 2] + 0.7152 * img[..., 1] + 0.0722 * img[..., 0]
+
+f = hog(gray).ravel()
+f = f[None, ...]
+print(clf.predict(f))
diff --git a/yobi/neural.py b/yobi/neural.py
new file mode 100644
index 00000000..4ddb6411
--- /dev/null
+++ b/yobi/neural.py
@@ -0,0 +1,118 @@
+import numpy
+import math
+import random
+from matplotlib import pyplot
+
+class Neural:
+
+ # constructor
+ def __init__(self, n_input, n_hidden, n_output):
+ self.hidden_weight = numpy.random.random_sample((n_hidden, n_input + 1))
+ self.output_weight = numpy.random.random_sample((n_output, n_hidden + 1))
+ self.hidden_momentum = numpy.zeros((n_hidden, n_input + 1))
+ self.output_momentum = numpy.zeros((n_output, n_hidden + 1))
+
+
+# public method
+ def train(self, X, T, epsilon, mu, epoch):
+ self.error = numpy.zeros(epoch)
+ N = X.shape[0]
+ for epo in range(epoch):
+ for i in range(N):
+ x = X[i, :]
+ t = T[i, :]
+
+ self.__update_weight(x, t, epsilon, mu)
+
+ self.error[epo] = self.__calc_error(X, T)
+
+
+ def predict(self, X):
+ N = X.shape[0]
+ C = numpy.zeros(N).astype('int')
+ Y = numpy.zeros((N, X.shape[1]))
+ for i in range(N):
+ x = X[i, :]
+ z, y = self.__forward(x)
+
+ Y[i] = y
+ C[i] = y.argmax()
+
+ return (C, Y)
+
+
+ def error_graph(self):
+ pyplot.ylim(0.0, 2.0)
+ pyplot.plot(numpy.arange(0, self.error.shape[0]), self.error)
+ pyplot.show()
+
+
+# private method
+ def __sigmoid(self, arr):
+ return numpy.vectorize(lambda x: 1.0 / (1.0 + math.exp(-x)))(arr)
+
+
+ def __forward(self, x):
+ # z: output in hidden layer, y: output in output layer
+ z = self.__sigmoid(self.hidden_weight.dot(numpy.r_[numpy.array([1]), x]))
+ y = self.__sigmoid(self.output_weight.dot(numpy.r_[numpy.array([1]), z]))
+
+ return (z, y)
+
+ def __update_weight(self, x, t, epsilon, mu):
+ z, y = self.__forward(x)
+
+ # update output_weight
+ output_delta = (y - t) * y * (1.0 - y)
+ _output_weight = self.output_weight
+ self.output_weight -= epsilon * output_delta.reshape((-1, 1)) * numpy.r_[numpy.array([1]), z] - mu * self.output_momentum
+ self.output_momentum = self.output_weight - _output_weight
+
+ # update hidden_weight
+ hidden_delta = (self.output_weight[:, 1:].T.dot(output_delta)) * z * (1.0 - z)
+ _hidden_weight = self.hidden_weight
+ self.hidden_weight -= epsilon * hidden_delta.reshape((-1, 1)) * numpy.r_[numpy.array([1]), x]
+ self.hidden_momentum = self.hidden_weight - _hidden_weight
+
+
+ def __calc_error(self, X, T):
+ N = X.shape[0]
+ err = 0.0
+ for i in range(N):
+ x = X[i, :]
+ t = T[i, :]
+
+ z, y = self.__forward(x)
+ err += (y - t).dot((y - t).reshape((-1, 1))) / 2.0
+
+ return err
+
+
+if __name__ == '__main__':
+
+ X = numpy.array([[0, 0], [0, 1], [1, 0], [1, 1]])
+ T = numpy.array([[1, 0], [0, 1], [0, 1], [1, 0]])
+ N = X.shape[0] # number of data
+
+ input_size = X.shape[1]
+ hidden_size = 2
+ output_size = 2
+ epsilon = 0.1
+ mu = 0.9
+ epoch = 10000
+
+ nn = Neural(input_size, hidden_size, output_size)
+ nn.train(X, T, epsilon, mu, epoch)
+ nn.error_graph()
+
+ C, Y = nn.predict(X)
+
+ for i in range(N):
+ x = X[i, :]
+ y = Y[i, :]
+ c = C[i]
+
+ print(x)
+ print(y)
+ print(c)
+ print("")
diff --git a/yobi/neuralnet.py b/yobi/neuralnet.py
new file mode 100644
index 00000000..85a526ed
--- /dev/null
+++ b/yobi/neuralnet.py
@@ -0,0 +1,101 @@
+import numpy as np
+
+np.random.seed(4)
+
+class NN:
+ def __init__(self, ind=2, w=10, outd=1, lr=1):
+ self.w2 = np.random.randn(ind, w)
+ self.w3 = np.random.randn(w, outd)
+ self.b2 = np.random.randn(w)
+ self.b3 = np.random.randn(1)
+ self.lr = lr
+
+ def forward(self, x):
+ self.z1 = x
+ #self.z1 = np.hstack((x, [1]))
+ # add bias
+ self.z2 = sigmoid(np.dot(self.z1, self.w2) + self.b2)
+ # add bias
+ #self.z2 = np.hstack((self.z2, [1]))
+ self.z3 = np.dot(self.z2, self.w3) + self.b3
+ self.out = sigmoid(self.z3)
+ return self.out
+
+ def backward(self, x, t):
+ #w3_d = (self.out * (1 - self.out)) * (self.out - y)
+ #xw3_delta = np.dot(self.w3.T * (self.out - xy), (self.out) * (1 - self.out))
+ #w3_dW = w3_d * self.z2.T[..., None]
+ #w3_dB = w3_d
+
+ w3_d = 2 * (self.out - t) * sigmoid_derivative(self.out)
+ print(self.w3.shape)
+ print(w3_d.shape)
+ print(self.w3.T.shape)
+ w3_dW = np.dot(self.w2.T, w3_d)
+ w3_dB = w3_d
+
+ self.w3 -= self.lr * w3_dW
+ self.b3 -= self.lr * w3_dB
+
+ #w2_d = np.dot((self.z2 * (1 - self.z2))[..., None], (self.z3.T * w3_d))
+ w2_d = np.dot(self.z3.T, w3_d) * (self.z2) * (1 - self.z2)
+ w2_dW = w2_d[..., None] * self.z1
+ w2_dB = w2_d
+
+ self.w2 += self.lr * w2_dW
+ self.b2 += self.lr * w2_dB
+
+ def train(self, x, t):
+ self.forward(x)
+ self.backward(x, t)
+
+
+class NeuralNetwork:
+ def __init__(self, x, y):
+ self.input = x
+ self.weights1 = np.random.rand(self.input.shape[1],4)
+ self.weights2 = np.random.rand(4,1)
+ self.y = y
+ self.output = np.zeros(self.y.shape)
+
+ def feedforward(self):
+ self.layer1 = sigmoid(np.dot(self.input, self.weights1))
+ self.output = sigmoid(np.dot(self.layer1, self.weights2))
+
+ def backprop(self):
+ # application of the chain rule to find derivative of the loss function with respect to weights2 and weights1
+ d_weights2 = np.dot(self.layer1.T, (2*(self.y - self.output) * sigmoid_derivative(self.output)))
+ d_weights1 = np.dot(self.input.T, (np.dot(2*(self.y - self.output) * sigmoid_derivative(self.output), self.weights2.T) * sigmoid_derivative(self.layer1)))
+
+ # update the weights with the derivative (slope) of the loss function
+ self.weights1 += d_weights1
+ self.weights2 += d_weights2
+
+
+def sigmoid(x):
+ return 1. / (1. + np.exp(-x))
+
+def sigmoid_derivative(x):
+ return sigmoid(x) * (1. - sigmoid(x))
+
+trainx = np.array(((0,0), (0,1), (1,0), (1,1)), dtype=np.float32)
+trainy = np.array((0, 1, 1, 0), dtype=np.float32)
+
+nn = NN()
+
+nn2 = NeuralNetwork(trainx, trainy)
+
+for i in range(10000):
+ """
+ for j in range(4):
+ nn.train(trainx[j%4], trainy[j%4])
+ #print("epoch: " , i)
+ for j in range(4):
+ if i == 0 or i == 9999:
+ print(nn.forward(trainx[j]), end=' ')
+ #print()
+ """
+ nn2.feedforward()
+ nn2.backprop()
+
+ print(nn2.output)
diff --git a/yobi/neuralnet2.py b/yobi/neuralnet2.py
new file mode 100644
index 00000000..014fcb60
--- /dev/null
+++ b/yobi/neuralnet2.py
@@ -0,0 +1,43 @@
+import numpy as np
+
+def sigmoid(x):
+ return 1.0/(1+ np.exp(-x))
+
+def sigmoid_derivative(x):
+ return x * (1.0 - x)
+
+class NeuralNetwork:
+ def __init__(self, x, t):
+ self.z1 = x
+ self.w2 = np.random.rand(self.z1.shape[1],3)
+ self.w3 = np.random.rand(3,1)
+ self.t = t
+ self.out = np.zeros(self.t.shape)
+
+ def feedforward(self):
+ self.z2 = sigmoid(np.dot(self.z1, self.w2))
+ self.out = sigmoid(np.dot(self.z2, self.w3))
+
+ def backprop(self):
+ # application of the chain rule to find derivative of the loss function with respect to w3 and w2
+ d_w3 = np.dot(self.z2.T, (2*(self.t - self.out) * sigmoid_derivative(self.out)))
+ d_w2 = np.dot(self.z1.T, (np.dot(2*(self.t - self.out) * sigmoid_derivative(self.out), self.w3.T) * sigmoid_derivative(self.z2)))
+
+ # update the weights with the derivative (slope) of the loss function
+ self.w2 += d_w2
+ self.w3 += d_w3
+
+
+if __name__ == "__main__":
+ X = np.array([[0, 0],
+ [0, 1],
+ [1, 0],
+ [1, 1]])
+ y = np.array([[0],[1],[1],[0]])
+ nn = NeuralNetwork(X,y)
+ print(X.shape, y.shape)
+ for i in range(15000):
+ nn.feedforward()
+ nn.backprop()
+
+ print(nn.out)
diff --git a/yobi/nn.py b/yobi/nn.py
new file mode 100644
index 00000000..485431eb
--- /dev/null
+++ b/yobi/nn.py
@@ -0,0 +1,52 @@
+import numpy as np
+
+np.random.seed(0)
+
+
+class NN:
+ def __init__(self, ind=2, w=64, outd=1, lr=0.1):
+ self.w2 = np.random.randn(ind, w)
+ self.b2 = np.random.randn(w)
+ self.wout = np.random.randn(w, outd)
+ self.bout = np.random.randn(outd)
+ self.lr = lr
+
+ def forward(self, x):
+ self.z1 = x
+ self.z2 = self.sigmoid(np.dot(self.z1, self.w2) + self.b2)
+ self.out = self.sigmoid(np.dot(self.z2, self.wout) + self.bout)
+ return self.out
+
+ def train(self, x, t):
+ # backpropagation output layer
+ out_d = 2*(self.out - t) * self.out * (1 - self.out)
+ out_dW = np.dot(self.z2.T, out_d)
+ out_dB = np.dot(np.ones([1, out_d.shape[0]]), out_d)
+ self.wout -= self.lr * out_dW
+ self.bout -= self.lr * out_dB[0]
+
+ # backpropagation inter layer
+ w2_d = np.dot(out_d, self.wout.T) * self.z2 * (1 - self.z2)
+ w2_dW = np.dot(self.z1.T, w2_d)
+ w2_dB = np.dot(np.ones([1, w2_d.shape[0]]), w2_d)
+ self.w2 -= self.lr * w2_dW
+ self.b2 -= self.lr * w2_dB[0]
+
+ def sigmoid(self, x):
+ return 1. / (1. + np.exp(-x))
+
+train_x = np.array([[0,0], [0,1], [1,0], [1,1]], dtype=np.float32)
+train_t = np.array([[0], [1], [1], [0]], dtype=np.float32)
+
+nn = NN(ind=train_x.shape[1])
+
+# training
+for i in range(1000):
+ nn.forward(train_x)
+ nn.train(train_x, train_t)
+
+# test
+for j in range(4):
+ x = train_x[j]
+ t = train_t[j]
+ print("in:", x, "pred:", nn.forward(x))