on lti::fastRelabeling;
I think its behavior is strange (because of poor
documentation?)
I try the following two samples.
1.
channel8 srcImg; // some image
channel8 destImg; // result image
fastRelabeling::parameters labelParam;
labelParam.sortSize = true; // sorting & [0] is background
labelParam.minimumObjectSize = 50; // for example
fastRelabeling label(labelParam);
ivector numPixels;
std::vector< areaPoints > areaPixels;
label(srcImg, destImg, numPixels, areaPixels);
then, numPixels.size() >= areaPixels.size()
because labels smaller than minimumObjectSize is
deleted in areaPixels. BY THE WAY, numPixels[i] MAY OR
MAY NOT correspond to areaPixels[i] for i <
areaPixels.size() (I'm not sure).
2. Next, turn the sortSize to false.
labelParam.sortSize = false;
then, numPixels.size() >= areaPixels.size(), AND
numPixels[i] NEVER correspond to areaPixels[i] (I'm sure).
To get the number of pixels in a label i, I shuould
always use areaPixel[i].size() instead numPixels[i].
Is this correct? or is lti::fastRelabeling wrong?
Logged In: YES
user_id=499803
I cheked the sample 1.
numPixels[i] corresponds to areaPixels[i] for 1 < i <
areaPixels.size(), but numPixels[0] and areaPixels[0].size()
are different (only i=0).
Logged In: YES
user_id=430480
It is indeed a bug in fastRelabeling. I'll try to take a deeper look
to the problem later.
Logged In: YES
user_id=1167797
Just found exactly this problem.
This really has to be fixed, the results should correspond
to each other.
The problem might be (without looking at the code), that the
pixels are set to zero (if region size < minimumObjectSize),
but the ivector is not updated.
Keep in mind, that the background is always the first
element. From the documentation:
There is an exception. The label 0 has a special meaning and
it will always be assigned to the background (everything
outside the given interval between minThreshold and
maxThreshold) independently of its size. This means the
regions will be sorted decreasingly but begining with the
second element. The first one is always the background. If
you set minThreshold to zero, the first element is always empty.