Commit 0a1908d7 authored by Davis King's avatar Davis King

Generalized segment_image() so it works on any pixel type or array of vectors.

I also changed it's interface slightly.  In particular, I removed the min_diff
parameter and replaced it with an explicit min_size parameter.
parent 055d6f56
This diff is collapsed.
......@@ -15,31 +15,34 @@ namespace dlib
void segment_image (
const in_image_type& in_img,
out_image_type& out_img,
const unsigned long k = 200,
const unsigned long min_diff = 0
const double k = 200,
const unsigned long min_size = 10
);
/*!
requires
- in_image_type == an implementation of array2d/array2d_kernel_abstract.h
- out_image_type == an implementation of array2d/array2d_kernel_abstract.h
- in_image_type::type == an unsigned 8-bit or 16bit integer type.
- in_image_type::type == Any pixel type with a pixel_traits specialization or a
dlib matrix object representing a row or column vector.
- out_image_type::type == unsigned integer type
- is_same_object(in_img, out_img) == false
ensures
- Attempts to segment in_img into regions which have some visual consistency to them.
In particular, this function implements the algorithm described in the paper:
Efficient Graph-Based Image Segmentation by Felzenszwalb and Huttenlocher.
- Attempts to segment in_img into regions which have some visual consistency to
them. In particular, this function implements the algorithm described in the
paper: Efficient Graph-Based Image Segmentation by Felzenszwalb and Huttenlocher.
- #out_img.nr() == in_img.nr()
- #out_img.nc() == in_img.nc()
- for all valid r and c:
- #out_img[r][c] == an integer value indicating the identity of the segment
containing the pixel in_img[r][c].
- The k parameter is a measure used to influence how large the segment regions will
be. Larger k generally results in larger segments being produced. For a deeper
discussion of the k parameter you should consult the above referenced paper.
- Any neighboring segments with an edge between them with a pixel difference <= min_diff
will always be merged. So making min_diff bigger makes this algorithm more eager
to merge neighboring segments.
- The k parameter is a measure used to influence how large the segment regions
will be. Larger k generally results in larger segments being produced. For
a deeper discussion of the k parameter you should consult the above
referenced paper.
- min_size is a lower bound on the size of the output segments. That is, it is
guaranteed that all output segments will have at least min_size pixels in
them (unless the whole image contains fewer than min_size pixels, in this
case the entire image will be put into a single segment).
!*/
// ----------------------------------------------------------------------------------------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment