vil_blob.h
Go to the documentation of this file.
1 #ifndef vil_blob_h_
2 #define vil_blob_h_
3 //:
4 // \file
5 // \brief Finds connected regions in a boolean image.
6 // \author Ian Scott
7 // These functions can be combined to get blobs as images, chorded regions, edge pixels lists, etc.
8 // For example to get an edge pixel list of im_binary
9 // \code
10 // vil_blob_labels(im_binary, vil_blob_4_conn, im_labels);
11 // vil_blob_labels_to_edge_labels(im_binary, vil_blob_4_conn, im_labels);
12 // vil_blob_labels_to_pixel_lists(im_edges, pixel_lists);
13 // \endcode
14 // To get the area of a blob efficiently
15 // \code
16 // vil_blob_labels(im_binary, vil_blob_4_conn, im_labels);
17 // vil_blob_labels_to_regions(im_labels, regions);
18 // unsigned area_of_first_blob = vil_area(regions[0]);
19 // \endcode
20 
21 #include <vector>
22 #include <utility>
23 #ifdef _MSC_VER
24 # include <vcl_msvc_warnings.h>
25 #endif
26 #include <vil/vil_image_view.h>
27 #include <vil/vil_chord.h>
28 
29 //: Specify 4- or 8- neighbour connectivity
31 {
34 };
35 
36 
37 //: Produce a label image that enumerates all disjoint blobs in a binary image
38 void vil_blob_labels(const vil_image_view<bool>& src_binary,
40  vil_image_view<unsigned>& dest_label);
41 
42 //: Set all non-blob-edge pixels in a blob label image to zero.
43 // A 4-conn edge is a 4-conn area itself, and not just those pixels which have dissimilar
44 // 4-conn neighbours.
47  vil_image_view<unsigned>& dest_label);
48 
49 
50 //: A region is a vector of chords that came from a connected blob.
51 typedef std::vector<vil_chord> vil_blob_region;
52 
53 //: Convert a label image into a list of chorded regions.
54 // A blob label value of n will be returned in dest_regions[n-1].
56  std::vector<vil_blob_region>& dest_regions);
57 
58 
59 //: A pixel list is a vector of <i,j> pixel positions.
60 typedef std::vector<std::pair<unsigned, unsigned> > vil_blob_pixel_list;
61 
62 //: Convert a label image into a list of pixel lists.
63 // A blob label value of n will be returned in dest_pixels_lists[n-1].
65  std::vector<vil_blob_pixel_list>& dest_pixel_lists);
66 
67 #endif
void vil_blob_labels_to_regions(const vil_image_view< unsigned > &src_label, std::vector< vil_blob_region > &dest_regions)
Convert a label image into a list of chorded regions.
Definition: vil_blob.cxx:249
vil_blob_connectivity
Specify 4- or 8- neighbour connectivity.
Definition: vil_blob.h:30
void vil_blob_labels_to_edge_labels(const vil_image_view< unsigned > &src_label, vil_blob_connectivity conn, vil_image_view< unsigned > &dest_label)
Set all non-blob-edge pixels in a blob label image to zero.
Definition: vil_blob.cxx:199
void vil_blob_labels_to_pixel_lists(const vil_image_view< unsigned > &src_label, std::vector< vil_blob_pixel_list > &dest_pixel_lists)
Convert a label image into a list of pixel lists.
Definition: vil_blob.cxx:277
void vil_blob_labels(const vil_image_view< bool > &src_binary, vil_blob_connectivity conn, vil_image_view< unsigned > &dest_label)
Produce a label image that enumerates all disjoint blobs in a binary image.
Definition: vil_blob.cxx:84
A base class reference-counting view of some image data.
std::vector< vil_chord > vil_blob_region
A region is a vector of chords that came from a connected blob.
Definition: vil_blob.h:51
Object to store information about position of a row of pixels.
std::vector< std::pair< unsigned, unsigned > > vil_blob_pixel_list
A pixel list is a vector of <i,j> pixel positions.
Definition: vil_blob.h:60