回答編集履歴
2
より適した解決法に変更
test
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
+
cv2.floodFillの使い方及び、表示方法にエラーが出ていました。
|
2
|
+
|
1
|
-
|
3
|
+
下記のように直したところ、無事、ndarrayで読み込んだ画像を使用して色塗ができました。
|
2
4
|
|
3
5
|
|
4
6
|
|
@@ -8,29 +10,45 @@
|
|
8
10
|
|
9
11
|
import cv2
|
10
12
|
|
13
|
+
|
14
|
+
|
15
|
+
# Opening the image (R prefixed to
|
16
|
+
|
17
|
+
# string in order to deal with '\'
|
18
|
+
|
11
|
-
i
|
19
|
+
# in paths)
|
20
|
+
|
21
|
+
img = cv2.imread("sample.png")
|
12
22
|
|
13
23
|
|
14
24
|
|
15
|
-
i
|
25
|
+
# Coordinates of the pixel whose value
|
16
26
|
|
17
|
-
|
27
|
+
# would be used as seed
|
18
28
|
|
19
|
-
|
20
|
-
|
21
|
-
seed = (
|
29
|
+
seed = (263, 70)
|
22
30
|
|
23
31
|
|
24
32
|
|
25
|
-
|
33
|
+
# Pixel Value which would be used for
|
26
34
|
|
27
|
-
|
35
|
+
# replacement
|
28
36
|
|
29
|
-
|
37
|
+
newVal = (255, 255, 255)
|
30
38
|
|
31
39
|
|
32
40
|
|
41
|
+
# Calling the floodfill() function and
|
42
|
+
|
43
|
+
# passing it image, seed, value and
|
44
|
+
|
45
|
+
# thresh as arguments
|
46
|
+
|
47
|
+
cv2.floodFill(img, None, seed, newVal)
|
48
|
+
|
49
|
+
|
50
|
+
|
33
|
-
i
|
51
|
+
# Displaying the image
|
34
52
|
|
35
53
|
cv2.imshow('a',img)
|
36
54
|
|
1
誤字の修正
test
CHANGED
@@ -12,7 +12,7 @@
|
|
12
12
|
|
13
13
|
|
14
14
|
|
15
|
-
img = cv2.imread("C:/
|
15
|
+
img = cv2.imread("C:/aa/a.png")
|
16
16
|
|
17
17
|
img = Image.fromarray(img)
|
18
18
|
|