mirror of
https://github.com/opencv/opencv.git
synced 2024-11-29 22:00:25 +08:00
correct upper bound for maximum number of labels for 8-way connectivity
This commit is contained in:
parent
bb4bf7a1f9
commit
88b2fe9dbb
@ -195,11 +195,9 @@ namespace cv{
|
|||||||
CV_Assert(connectivity == 8 || connectivity == 4);
|
CV_Assert(connectivity == 8 || connectivity == 4);
|
||||||
const int rows = L.rows;
|
const int rows = L.rows;
|
||||||
const int cols = L.cols;
|
const int cols = L.cols;
|
||||||
size_t Plength = (size_t(rows + 3 - 1)/3) * (size_t(cols + 3 - 1)/3);
|
//A quick and dirty upper bound for the maximimum number of labels. The 4 comes from
|
||||||
if(connectivity == 4){
|
//the fact that a 3x3 block can never have more than 4 unique labels for both 4 & 8-way
|
||||||
Plength = 4 * Plength;//a quick and dirty upper bound, an exact answer exists if you want to find it
|
const size_t Plength = 4 * (size_t(rows + 3 - 1)/3) * (size_t(cols + 3 - 1)/3);
|
||||||
//the 4 comes from the fact that a 3x3 block can never have more than 4 unique labels
|
|
||||||
}
|
|
||||||
LabelT *P = (LabelT *) fastMalloc(sizeof(LabelT) * Plength);
|
LabelT *P = (LabelT *) fastMalloc(sizeof(LabelT) * Plength);
|
||||||
P[0] = 0;
|
P[0] = 0;
|
||||||
LabelT lunique = 1;
|
LabelT lunique = 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user