質問編集履歴
2
_を.に変更し実行した結果。
title
CHANGED
File without changes
|
body
CHANGED
@@ -70,4 +70,41 @@
|
|
70
70
|
```
|
71
71
|
|
72
72
|
実行結果
|
73
|
-

|
73
|
+

|
74
|
+
|
75
|
+
ーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーー
|
76
|
+
_を.に書き換え実行した結果
|
77
|
+
|
78
|
+
```python3
|
79
|
+
|
80
|
+
import cv2
|
81
|
+
|
82
|
+
img = cv2 . imread ( "person.jpg" )
|
83
|
+
|
84
|
+
cv2 . imshow("window",img )
|
85
|
+
|
86
|
+
cv2 . waitKey ()
|
87
|
+
cv2 . destroyAllWindows()
|
88
|
+
|
89
|
+
cv2 . imwrite ( "person",img)
|
90
|
+
|
91
|
+
|
92
|
+
#%matplotlib inline
|
93
|
+
import cv2
|
94
|
+
import matplotlib . pyplot as plt
|
95
|
+
|
96
|
+
|
97
|
+
img = cv2 . imread ("person",img)
|
98
|
+
# 高さ
|
99
|
+
height = img . shape [ 0 ]
|
100
|
+
# 幅
|
101
|
+
width = img . shape [ 1 ]
|
102
|
+
# 高さ・幅を150pixelずつ取り除く
|
103
|
+
trim.img = img [ 150 : height , 150 : width ]
|
104
|
+
#matplotlibで表示する場合はRGBからBGRに変換
|
105
|
+
trim.img = cv2.cvtColor (trim.img , cv2.COLOR.RGB2BGR)
|
106
|
+
plt . imshow (trim.img)
|
107
|
+
|
108
|
+
plt.show()
|
109
|
+
```出力結果
|
110
|
+

|
1
一部コメントアウト、コードの追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -32,4 +32,42 @@
|
|
32
32
|
|
33
33
|
```
|
34
34
|
|
35
|
-

|
35
|
+

|
36
|
+
|
37
|
+
修正点:
|
38
|
+
|
39
|
+
%matplotlib inlineをコメントアウト、plt.show()を最後の行に追加
|
40
|
+
```python3
|
41
|
+
import cv2
|
42
|
+
|
43
|
+
img = cv2 . imread ( "person.jpg" )
|
44
|
+
|
45
|
+
cv2 . imshow("window",img )
|
46
|
+
|
47
|
+
cv2 . waitKey ()
|
48
|
+
cv2 . destroyAllWindows()
|
49
|
+
|
50
|
+
cv2 . imwrite ( "person",img)
|
51
|
+
|
52
|
+
|
53
|
+
#%matplotlib inline
|
54
|
+
import cv2
|
55
|
+
import matplotlib . pyplot as plt
|
56
|
+
|
57
|
+
|
58
|
+
img = cv2 . imread ("person",img)
|
59
|
+
# 高さ
|
60
|
+
height = img . shape [ 0 ]
|
61
|
+
# 幅
|
62
|
+
width = img . shape [ 1 ]
|
63
|
+
# 高さ・幅を150pixelずつ取り除く
|
64
|
+
trim _ img = img [ 150 : height , 150 : width ]
|
65
|
+
#matplotlibで表示する場合はRGBからBGRに変換
|
66
|
+
trim _ img = cv2 . cvtColor ( trim _ img , cv2 . COLOR _ RGB2BGR )
|
67
|
+
plt . imshow ( trim _ img )
|
68
|
+
|
69
|
+
plt.show()
|
70
|
+
```
|
71
|
+
|
72
|
+
実行結果
|
73
|
+

|