質問編集履歴
2
コードの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -27,3 +27,109 @@
|
|
27
27
|
|
28
28
|
|
29
29
|
よろしくお願いします。
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
```Android(java)
|
36
|
+
|
37
|
+
private void drawing() {
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
//■Matの作成
|
42
|
+
|
43
|
+
Mat mat_original = new Mat();
|
44
|
+
|
45
|
+
Mat mat = new Mat();
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
//■Bitmapをmatに変換
|
50
|
+
|
51
|
+
Utils.bitmapToMat(bitmap_toumei, mat_original);
|
52
|
+
|
53
|
+
Utils.bitmapToMat(bitmap_toumei, mat);
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
//■チャネルの変更(floodfillは透明を扱えないため)
|
58
|
+
|
59
|
+
Imgproc.cvtColor(mat, mat, Imgproc.COLOR_RGBA2GRAY); //変換種類 https://docs.opencv.org/java/2.4.9/org/opencv/imgproc/Imgproc.html
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
org.opencv.core.Point seedPoint = new org.opencv.core.Point(seedCoordinateList.get(seedCoordinateList.size()-1).cX, seedCoordinateList.get(seedCoordinateList.size()-1).cY);
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
//■輝度値/色の差の許容下限値の設定
|
68
|
+
|
69
|
+
double diff = 50.0;
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
//■Maskデータ作成 cv::Mat mask = cv::Mat::zeros(image.rows + 2, image.cols + 2, CV_8UC1);
|
74
|
+
|
75
|
+
Mat mat2 = new Mat(mat.height() + 2 , mat.width() + 2, CV_8UC1);
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
//■色変換
|
80
|
+
|
81
|
+
Imgproc.floodFill(
|
82
|
+
|
83
|
+
mat,
|
84
|
+
|
85
|
+
mat2,
|
86
|
+
|
87
|
+
seedPoint,
|
88
|
+
|
89
|
+
new Scalar(.0, .0, .0, .0),
|
90
|
+
|
91
|
+
new org.opencv.core.Rect(),
|
92
|
+
|
93
|
+
new Scalar(diff),
|
94
|
+
|
95
|
+
new Scalar(diff),
|
96
|
+
|
97
|
+
4 | Imgproc.FLOODFILL_MASK_ONLY | (255 << 8)
|
98
|
+
|
99
|
+
//Imgproc.FLOODFILL_FIXED_RANGE | 4 //種類: FLOODFILL_FIXED_RANGE:http://opencv.jp/opencv-2.1/cpp/miscellaneous_image_transformations.html
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
);
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
//■mask == 255 のピクセルの透過度を 255 にする。
|
108
|
+
|
109
|
+
org.opencv.core.Rect roi = new org.opencv.core.Rect(1, 1, mat.width(), mat.height());
|
110
|
+
|
111
|
+
mat2 = mat2.submat(roi);
|
112
|
+
|
113
|
+
mat_original = mat_original.setTo(new Scalar(.0, .0, .0, .0),mat2);
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
//■■bitmapに変換
|
118
|
+
|
119
|
+
Bitmap output = Bitmap.createBitmap(bitmap_toumei.getWidth(), bitmap_toumei.getHeight(), Bitmap.Config.ARGB_8888);
|
120
|
+
|
121
|
+
Utils.matToBitmap(mat_original ,output,true);
|
122
|
+
|
123
|
+
bitmap_toumei = output;
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
//■再描画
|
128
|
+
|
129
|
+
invalidate();
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
}
|
134
|
+
|
135
|
+
```
|
1
記入ミス
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
floodFillでの塗りつぶしの色を透明に
|
1
|
+
floodFillでの塗りつぶしの色を透明にする方法について
|
test
CHANGED
File without changes
|