回答編集履歴

2

2020/12/15 10:30

投稿

kirara0048
kirara0048

スコア1399

test CHANGED
@@ -24,6 +24,6 @@
24
24
 
25
25
  x, y = (2, 2)
26
26
 
27
- view_as_blocks(img, (x, y, 3)).std((2, 3, 4))
27
+ view_as_blocks(img, (x, y, 1)).std((3, 4, 5))
28
28
 
29
29
  ```

1

修正

2020/12/15 10:30

投稿

kirara0048
kirara0048

スコア1399

test CHANGED
@@ -1,5 +1,29 @@
1
+ ## 1. Numpyの`.reshape()`を用いる方法
2
+
3
+
4
+
1
5
  ```python
2
6
 
7
+ x, y = (2, 2)
8
+
3
- arr.reshape(arr.shape[0]//2, 2, arr.shape[1]//2, 2, 3).std((0, 2))
9
+ img.reshape(img.shape[0]//x, x, img.shape[1]//y, y, 3).std((1, 3))
4
10
 
5
11
  ```
12
+
13
+
14
+
15
+ ## 2. Scikit-imageの`view_as_blocks()`を用いる方法
16
+
17
+
18
+
19
+ ```python
20
+
21
+ from skimage.util import view_as_blocks
22
+
23
+
24
+
25
+ x, y = (2, 2)
26
+
27
+ view_as_blocks(img, (x, y, 3)).std((2, 3, 4))
28
+
29
+ ```