@@ -275,24 +275,18 @@ void ERFilterNM::er_tree_extract( InputArray image )
275275 // the component stack
276276 vector<ERStat*> er_stack;
277277
278- // the quads for euler number calculation
279- unsigned char quads[3 ][4 ];
280- quads[0 ][0 ] = 1 << 3 ;
281- quads[0 ][1 ] = 1 << 2 ;
282- quads[0 ][2 ] = 1 << 1 ;
283- quads[0 ][3 ] = 1 ;
284- quads[1 ][0 ] = (1 <<2 )|(1 <<1 )|(1 );
285- quads[1 ][1 ] = (1 <<3 )|(1 <<1 )|(1 );
286- quads[1 ][2 ] = (1 <<3 )|(1 <<2 )|(1 );
287- quads[1 ][3 ] = (1 <<3 )|(1 <<2 )|(1 <<1 );
288- quads[2 ][0 ] = (1 <<2 )|(1 <<1 );
289- quads[2 ][1 ] = (1 <<3 )|(1 );
290- // quads[2][2] and quads[2][3] are never used so no need to initialize them.
278+ // the quads for euler number calculation
279+ // quads[2][2] and quads[2][3] are never used.
291280 // The four lowest bits in each quads[i][j] correspond to the 2x2 binary patterns
292281 // Q_1, Q_2, Q_3 in the Neumann and Matas CVPR 2012 paper
293282 // (see in page 4 at the end of first column).
294283 // Q_1 and Q_2 have four patterns, while Q_3 has only two.
295-
284+ const int quads[3 ][4 ] =
285+ {
286+ { 1 <<3 , 1 <<2 , 1 <<1 , 1 <<0 },
287+ { (1 <<2 )|(1 <<1 )|(1 ), (1 <<3 )| (1 <<1 )|(1 ), (1 <<3 )|(1 <<2 )| (1 ), (1 <<3 )|(1 <<2 )|(1 <<1 ) },
288+ { (1 <<2 )|(1 <<1 ) , (1 <<3 )| (1 ), /* unused*/ -1 , /* unused*/ -1 }
289+ };
296290
297291 // masks to know if a pixel is accessible and if it has been already added to some region
298292 vector<bool > accessible_pixel_mask (width * height);
@@ -392,8 +386,8 @@ void ERFilterNM::er_tree_extract( InputArray image )
392386 int non_boundary_neighbours = 0 ;
393387 int non_boundary_neighbours_horiz = 0 ;
394388
395- unsigned char quad_before[4 ] = {0 ,0 ,0 ,0 };
396- unsigned char quad_after[4 ] = {0 ,0 ,0 ,0 };
389+ int quad_before[4 ] = {0 ,0 ,0 ,0 };
390+ int quad_after[4 ] = {0 ,0 ,0 ,0 };
397391 quad_after[0 ] = 1 <<1 ;
398392 quad_after[1 ] = 1 <<3 ;
399393 quad_after[2 ] = 1 <<2 ;
@@ -542,9 +536,9 @@ void ERFilterNM::er_tree_extract( InputArray image )
542536 current_edge = boundary_edges[threshold_level].back ();
543537 boundary_edges[threshold_level].erase (boundary_edges[threshold_level].end ()-1 );
544538
545- while (boundary_pixes[threshold_level]. empty () && ( threshold_level < (255 /thresholdDelta)+1 ) )
546- threshold_level++;
547-
539+ for (; threshold_level < (255 /thresholdDelta)+1 ; threshold_level++ )
540+ if (!boundary_pixes[ threshold_level]. empty ())
541+ break ;
548542
549543 int new_level = image_data[current_pixel];
550544
0 commit comments