Skip to content

Commit

Permalink
Merge pull request opencv#1863 from nevion:master
Browse files Browse the repository at this point in the history
  • Loading branch information
Roman Donchenko authored and OpenCV Buildbot committed Nov 26, 2013
2 parents e7339ac + 88b2fe9 commit aaf97c4
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions modules/imgproc/src/connectedcomponents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,9 @@ namespace cv{
CV_Assert(connectivity == 8 || connectivity == 4);
const int rows = L.rows;
const int cols = L.cols;
size_t Plength = (size_t(rows + 3 - 1)/3) * (size_t(cols + 3 - 1)/3);
if(connectivity == 4){
Plength = 4 * Plength;//a quick and dirty upper bound, an exact answer exists if you want to find it
//the 4 comes from the fact that a 3x3 block can never have more than 4 unique labels
}
//A quick and dirty upper bound for the maximimum number of labels. The 4 comes from
//the fact that a 3x3 block can never have more than 4 unique labels for both 4 & 8-way
const size_t Plength = 4 * (size_t(rows + 3 - 1)/3) * (size_t(cols + 3 - 1)/3);
LabelT *P = (LabelT *) fastMalloc(sizeof(LabelT) * Plength);
P[0] = 0;
LabelT lunique = 1;
Expand Down

0 comments on commit aaf97c4

Please sign in to comment.