@@ -227,18 +227,20 @@ stMorph::kernelDecompInfo ftr_decomp(InputArray kernel)
227
227
Mat VisualizeCovering (Mat& kernel, const stMorph::kernelDecompInfo& kdi)
228
228
{
229
229
const int rate = 20 ;
230
- const int fluct = 5 ;
230
+ const int fluct = 3 ;
231
231
const int colors = 20 ;
232
232
resize (kernel * 255 , kernel, Size (), rate, rate, InterpolationFlags::INTER_NEAREST);
233
233
cvtColor (kernel, kernel, cv::COLOR_GRAY2BGR);
234
234
Scalar color[colors]{
235
- Scalar (83 , 89 , 73 ), Scalar (49 , 238 , 73 ), Scalar (220 , 192 , 189 ), Scalar (174 , 207 , 34 ),
236
- Scalar (144 , 169 , 187 ), Scalar (137 , 94 , 76 ), Scalar (42 , 11 , 215 ), Scalar (113 , 11 , 204 ),
237
- Scalar (71 , 124 , 8 ), Scalar (192 , 38 , 8 ), Scalar (82 , 201 , 8 ), Scalar (70 , 7 , 112 ),
238
- Scalar (166 , 219 , 201 ), Scalar (154 , 173 , 0 ), Scalar (132 , 127 , 139 ), Scalar (154 , 1 , 68 ),
239
- Scalar (231 , 131 , 56 ), Scalar (206 , 238 , 136 ), Scalar (188 , 78 , 173 ), Scalar (27 , 178 , 206 )
235
+ Scalar (255 , 127 , 127 ), Scalar (255 , 127 , 191 ), Scalar (255 , 127 , 255 ), Scalar (191 , 127 , 255 ),
236
+ Scalar (127 , 127 , 255 ), Scalar (127 , 191 , 255 ), Scalar (127 , 255 , 255 ), Scalar (127 , 255 , 191 ),
237
+ Scalar (127 , 255 , 127 ), Scalar (191 , 255 , 127 ), Scalar (255 , 255 , 127 ), Scalar (255 , 191 , 127 )
240
238
};
241
239
int i = 0 ;
240
+ for (int r = 0 ; r < kdi.rows ; r++)
241
+ cv::line (kernel, Point (0 , r * rate), Point (kdi.cols * rate, r * rate), Scalar (0 ));
242
+ for (int c = 0 ; c < kdi.cols ; c++)
243
+ cv::line (kernel, Point (c * rate, 0 ), Point (c * rate, kdi.rows * rate), Scalar (0 ));
242
244
for (int r = 0 ; r < kdi.stRects .size (); r++)
243
245
{
244
246
for (int c = 0 ; c < kdi.stRects [r].size (); c++)
@@ -247,10 +249,10 @@ Mat VisualizeCovering(Mat& kernel, const stMorph::kernelDecompInfo& kdi)
247
249
for (Point p : kdi.stRects [r][c])
248
250
{
249
251
Rect rect (p, s);
250
- int l = (rect.x ) * rate + i % fluct;
251
- int t = (rect.y ) * rate + i % fluct;
252
- int r = (rect.x + rect.width ) * rate - fluct + i % fluct;
253
- int b = (rect.y + rect.height ) * rate - fluct + i % fluct;
252
+ int l = (rect.x ) * rate + i % fluct + 2 ;
253
+ int t = (rect.y ) * rate + i % fluct + 2 ;
254
+ int r = (rect.x + rect.width ) * rate - fluct + i % fluct - 1 ;
255
+ int b = (rect.y + rect.height ) * rate - fluct + i % fluct - 1 ;
254
256
Point lt (l, t);
255
257
Point lb (l, b);
256
258
Point rb (r, b);
@@ -280,6 +282,8 @@ Mat VisualizePlanning(stMorph::kernelDecompInfo kdi)
280
282
Rect nodeRect (col * g + g / 2 - 5 , row * g + g / 2 - 5 , 11 , 11 );
281
283
if (kdi.stRects [row][col].size () > 0 )
282
284
cv::rectangle (m, nodeRect, vCol, -1 );
285
+ else
286
+ cv::rectangle (m, nodeRect, vCol, 1 );
283
287
}
284
288
}
285
289
for (int r = 0 ; r < rows; r++)
@@ -309,7 +313,7 @@ TEST(ximgproc_StMorph_decomp, feature_rnd50) { ftr_decomp(knRnd(1000, 50)); }
309
313
TEST (ximgproc_StMorph_decomp, feature_rnd80) { ftr_decomp (knRnd (1000 , 80 )); }
310
314
TEST (ximgproc_StMorph_decomp, feature_rnd90) { ftr_decomp (knRnd (1000 , 90 )); }
311
315
TEST (ximgproc_StMorph_decomp, feature_visualize) {
312
- Mat kernel = getStructuringElement (MORPH_ELLIPSE, Size (21 , 21 ));
316
+ Mat kernel = getStructuringElement (MORPH_ELLIPSE, Size (5 , 5 ));
313
317
auto kdi = ftr_decomp (kernel);
314
318
Mat covering = VisualizeCovering (kernel, kdi);
315
319
Mat plan = VisualizePlanning (kdi);
@@ -366,7 +370,7 @@ TEST(ximgproc_StMorph_eval, pdi)
366
370
367
371
// cv-ellipse
368
372
kn = getStructuringElement (MORPH_ELLIPSE, sz);
369
- if (i <= 41 )
373
+ if (i <= 23 )
370
374
{
371
375
meter.start ();
372
376
cv::erode (img, dst, kn);
@@ -449,7 +453,7 @@ TEST(ximgproc_StMorph_eval, integrated)
449
453
450
454
// cv-ellipse
451
455
kn = getStructuringElement (MORPH_ELLIPSE, sz);
452
- if (i <= 41 )
456
+ if (i <= 23 )
453
457
{
454
458
meter.start ();
455
459
cv::erode (img, dst, kn);
0 commit comments