回答編集履歴
2
d
test
CHANGED
@@ -20,13 +20,13 @@
|
|
20
20
|
|
21
21
|
|
22
22
|
|
23
|
-
img = cv2.imread("
|
23
|
+
img = cv2.imread("test.png", cv2.IMREAD_UNCHANGED)
|
24
24
|
|
25
25
|
print(img.shape) # (288, 432, 3)
|
26
26
|
|
27
27
|
|
28
28
|
|
29
|
-
if img.ndim == 3:
|
29
|
+
if img.ndim == 3: # RGBならアルファチャンネル追加
|
30
30
|
|
31
31
|
img = cv2.cvtColor(img, cv2.COLOR_RGB2RGBA)
|
32
32
|
|
1
d
test
CHANGED
@@ -16,20 +16,20 @@
|
|
16
16
|
|
17
17
|
```python
|
18
18
|
|
19
|
-
|
20
|
-
|
21
19
|
import cv2
|
22
20
|
|
23
21
|
|
24
22
|
|
25
|
-
img = cv2.imread("colorbar3.png")
|
23
|
+
img = cv2.imread("colorbar3.png", cv2.IMREAD_UNCHANGED)
|
26
24
|
|
27
25
|
print(img.shape) # (288, 432, 3)
|
28
26
|
|
29
27
|
|
30
28
|
|
31
|
-
|
29
|
+
if img.ndim == 3:
|
32
30
|
|
31
|
+
img = cv2.cvtColor(img, cv2.COLOR_RGB2RGBA)
|
32
|
+
|
33
|
-
print(
|
33
|
+
print(img.shape) # (288, 432, 4)
|
34
34
|
|
35
35
|
```
|