回答編集履歴

2

d

2019/08/07 08:42

投稿

tiitoi
tiitoi

スコア21956

test CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
 
8
8
 
9
- 1. [src.min(), src.max()] -> [0, 65535] にスケールする。
9
+ 1. [src.min(), src.max()] -> [0, 2000] にスケールする。
10
10
 
11
11
  2. uint16 にキャストする。
12
12
 
@@ -30,7 +30,7 @@
30
30
 
31
31
 
32
32
 
33
- # [src.min(), src.max()] -> [0, 65535] にスケールする。
33
+ # [src.min(), src.max()] -> [0, 2000] にスケールする。
34
34
 
35
35
  dst = np.interp(src, (src.min(), src.max()), (0, 2000))
36
36
 

1

d

2019/08/07 08:42

投稿

tiitoi
tiitoi

スコア21956

test CHANGED
@@ -32,11 +32,7 @@
32
32
 
33
33
  # [src.min(), src.max()] -> [0, 65535] にスケールする。
34
34
 
35
- dst = np.interp(
36
-
37
- src, (src.min(), src.max()), (np.iinfo(np.uint16).min, np.iinfo(np.uint16).max)
35
+ dst = np.interp(src, (src.min(), src.max()), (0, 2000))
38
-
39
- )
40
36
 
41
37
  dst = dst.astype(np.uint16) # float -> uint16
42
38
 
@@ -54,4 +50,8 @@
54
50
 
55
51
  print(src.dtype, src.shape) # uint16 (100, 100)
56
52
 
53
+
54
+
55
+ print(dst.min(), dst.max())
56
+
57
57
  ```