Added missing assert and made minor refinements to spec.

This commit is contained in:
Davis King 2011-09-25 11:36:36 -04:00
parent d7debab691
commit 552196b01e
2 changed files with 16 additions and 2 deletions

View File

@ -120,11 +120,21 @@ namespace dlib
label_image_type& label_img
)
{
// make sure requires clause is not broken
DLIB_ASSERT(is_same_object(img, label_img) == false,
"\t unsigned long label_connected_blobs()"
<< "\n\t The input image and output label image can't be the same object."
);
std::stack<point> neighbors;
label_img.set_size(img.nr(), img.nc());
assign_all_pixels(label_img, 0);
unsigned long next = 1;
if (img.size() == 0)
return 0;
const rectangle area = get_rect(img);
std::vector<point> window;

View File

@ -153,6 +153,7 @@ namespace dlib
- get_neighbors(point(c,r), neighbors) is a legal expression where neighbors
is of type std::vector<point>.
- is_connected(img, point(c,r), point(c2,r2)) is a valid expression.
- is_same_object(img, label_img) == false
ensures
- This function labels each of the connected blobs in img with a unique integer
label.
@ -175,8 +176,11 @@ namespace dlib
- #label_img[r][c] == 0
- else
- #label_img[r][c] != 0
- if (img.size() != 0) then
- returns max(array_to_matrix(label_img))+1
(i.e. returns a number one greater than the maximum blob id number)
- else
- returns 0
- blob labels are contiguous, therefore, the number returned by this function is
the number of blobs in the image (including the background blob).
- It is guaranteed that is_connected() and is_background() will never be