質問編集履歴

2

codeブロックしました

2018/08/06 11:20

投稿

empelt
empelt

スコア6

test CHANGED
File without changes
test CHANGED
@@ -1,4 +1,62 @@
1
+ ```ここに言語を入力
2
+
3
+ import cv2
4
+
5
+ import numpy as np
6
+
7
+
8
+
9
+ image_path = "pisu5.jpg"
10
+
11
+ src = cv2.imread(image_path)
12
+
13
+
14
+
15
+ def skin_detect(src):
16
+
17
+
18
+
19
+ hsv = cv2.cvtColor(src, cv2.COLOR_BGR2HSV)
20
+
21
+
22
+
23
+ hsv_min = np.aray([0, 30, 60])
24
+
25
+ hsv_max = np.array([20, 150, 255])
26
+
27
+ mask = cv2.inRange(hsv, hsv_min, hsv_max)
28
+
29
+ return mask
30
+
31
+
32
+
33
+ def mosaic(src, ratio=0.1):
34
+
35
+ small = cv2.resize(src, None, fx=ratio, fy=ratio, interpolation=cv2.INTER_NEAREST)
36
+
37
+ return cv2.resize(small, src.shape[:2][::-1], interpolation=cv2.INTER_NEAREST)
38
+
39
+
40
+
41
+ def mosaic_area(src, x, y, width, height, ratio=0.02):
42
+
43
+ dst = src.copy()
44
+
45
+ dst[y:y + height , x:x + width] = mosaic(dst[y:y + height, x:x + width], ratio)
46
+
47
+ return dst
48
+
49
+
50
+
51
+
52
+
53
+ for ??????
54
+
55
+ cv2.imwrite("pisu5_detect.jpg", ??????)
56
+
57
+
58
+
1
- ```
59
+ ``````
2
60
 
3
61
  コード
4
62
 

1

codeブロックいたしました

2018/08/06 11:20

投稿

empelt
empelt

スコア6

test CHANGED
File without changes
test CHANGED
@@ -1,4 +1,8 @@
1
+ ```
2
+
3
+ コード
4
+
1
- ### 前提・実現したいこと
5
+ ```### 前提・実現したいこと
2
6
 
3
7
  画像から肌色を検出して検出域にモザイクをかけるプログラムを作っています。
4
8
 
@@ -18,19 +22,19 @@
18
22
 
19
23
  ### 該当のソースコード
20
24
 
21
- import cv2
25
+ import cv2
22
26
 
23
- import numpy as np
27
+ import numpy as np
24
28
 
25
29
 
26
30
 
27
- image_path = "pisu5.jpg"
31
+ image_path = "pisu5.jpg"
28
32
 
29
- src = cv2.imread(image_path)
33
+ src = cv2.imread(image_path)
30
34
 
31
35
 
32
36
 
33
- def skin_detect(src):
37
+ def skin_detect(src):
34
38
 
35
39
 
36
40
 
@@ -48,7 +52,7 @@
48
52
 
49
53
 
50
54
 
51
- def mosaic(src, ratio=0.1):
55
+ def mosaic(src, ratio=0.1):
52
56
 
53
57
  small = cv2.resize(src, None, fx=ratio, fy=ratio, interpolation=cv2.INTER_NEAREST)
54
58
 
@@ -56,7 +60,7 @@
56
60
 
57
61
 
58
62
 
59
- def mosaic_area(src, x, y, width, height, ratio=0.02):
63
+ def mosaic_area(src, x, y, width, height, ratio=0.02):
60
64
 
61
65
  dst = src.copy()
62
66