c# - Connected component labeling in Emgu / Opencv -


i've been ing method connected component labeling in emgu (c# wrapper opencv). i've failed find direct method such basic cv strategy. however, did come across many suggestions doing using findcontours , drawcontours without code examples. had go @ , seems work okay.

i'm dropping here 2 reasons.

  1. so people searching can find code example.
  2. more importantly, i'm wondering if there suggestions optimization , improvements of function. e.g. chain approximation method findcontours efficient/appropriate?
    public static image<gray, byte> labelconnectedcomponents(this image<gray, byte> binary, int startlabel)     {         contour<point> contours = binary.findcontours(             chain_approx_method.cv_chain_approx_none,              retr_type.cv_retr_ccomp);          int count = startlabel;         (contour<point> cont = contours;                     cont != null;                     cont = cont.hnext)         {             cvinvoke.cvdrawcontours(             binary,             cont,             new mcvscalar(count),             new mcvscalar(0),             2,             -1,             line_type.four_connected,             new point(0, 0));             ++count;         }         return binary;     } 

i use following:

   connected component labeling (aforge / accord.net ?)    (although many cases find same function wrote, give try verify results) 

after step find more regions close , belong same person. can use: implement or search implementation of hierarhical aglomerative clustering (hca) combine close region.

p.s.: chain approximation method findcontours efficient/appropriate

if using no_approx no approximations of chain code used. using can non-smoothed edges (with many small hills , valleys) if not bother parameter value fine.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -