Skip to content

Commit

Permalink
Fixed bug in cvLabel. First point count twice in blog parameters calc…
Browse files Browse the repository at this point in the history
…ulation.
  • Loading branch information
grendel.ccl committed Mar 22, 2011
1 parent c08bb18 commit c3d48cb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
3 changes: 3 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ Version 0.10.4 (2011/01/26)
* CMakeLists.txt, cvBlobConfig.cmake.in: create "cvBlobConfig.cmake" for
easy integration with CMAKE projects. Thanks to zorzalzilba.

* cvlabel.cpp: fix bug in the function cvLabel by which it calculates area
off by one.

Version 0.10.3 (2010/11/12)

* cvlabel.cpp: a little optimization in "cvLabel".
Expand Down
27 changes: 15 additions & 12 deletions cvBlob/cvlabel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,18 +170,21 @@ namespace cvb
direction=(direction+1)%4;
else
{
imageOut(xx, yy) = label;
numPixels++;

if (xx<blob->minx) blob->minx = xx;
else if (xx>blob->maxx) blob->maxx = xx;
if (yy<blob->miny) blob->miny = yy;
else if (yy>blob->maxy) blob->maxy = yy;

blob->area++;
blob->m10+=xx; blob->m01+=yy;
blob->m11+=xx*yy;
blob->m20+=xx*xx; blob->m02+=yy*yy;
if (imageOut(xx, yy) != label)
{
imageOut(xx, yy) = label;
numPixels++;

if (xx<blob->minx) blob->minx = xx;
else if (xx>blob->maxx) blob->maxx = xx;
if (yy<blob->miny) blob->miny = yy;
else if (yy>blob->maxy) blob->maxy = yy;

blob->area++;
blob->m10+=xx; blob->m01+=yy;
blob->m11+=xx*yy;
blob->m20+=xx*xx; blob->m02+=yy*yy;
}

break;
}
Expand Down

0 comments on commit c3d48cb

Please sign in to comment.