回答編集履歴
1
書式の改善
answer
CHANGED
@@ -1,11 +1,15 @@
|
|
1
1
|
fourteenlengthさんが上げてくれた画像を使ってやってみたら、「B mode:4」と表示されました
|
2
|
+
```python
|
2
3
|
import numpy as np
|
3
4
|
import cv2
|
4
5
|
from scipy import stats
|
5
6
|
Brow = cv2.cvtColor(cv2.imread("./img.png"), cv2.COLOR_BGR2GRAY)
|
6
7
|
Bmode = stats.mode(Brow[Brow>0])[0][0]
|
7
8
|
print("B mode:"+str(Bmode))
|
9
|
+
```
|
8
10
|
|
9
11
|
確認したら、0を除外したら、やはり4が個数最大でした
|
12
|
+
```python
|
10
13
|
histogram, _ = np.histogram(Brow.flatten(), bins=np.arange(np.max(Brow)+2))
|
11
|
-
print(histogram)
|
14
|
+
print(histogram)
|
15
|
+
```
|