Main Page   Modules   Class Hierarchy   Compound List   File List   Compound Members   Related Pages   Examples  

Morphological operations


Functions

int ConnectedComponents (IntImage &img, CONN_TYPE connectivity, IntImage &out)
int ConnectedComponents (ByteImage &img, CONN_TYPE connectivity, IntImage &out)
int ConnectedComponents (IntImage &img, CONN_TYPE connectivity=FOUR)
void DistanceTransform (ByteImage &input, DM_TYPE dm_type, IntImage &output)
void Erosion (Image< T > &input, ByteKernel &kern, Image< T > &output)
void Dilation (Image< T > &input, ByteKernel &kern, Image< T > &output)
void Opening (Image< T > &input, ByteKernel &kern, Image< T > &output)
void Closing (Image< T > &input, ByteKernel &kern, Image< T > &output)
void FlatErosion (Image< T > &input, ByteKernel &kern, Image< T > &output)
void FlatDilation (Image< T > &input, ByteKernel &kern, Image< T > &output)
void FlatOpening (Image< T > &input, ByteKernel &kern, Image< T > &output)
void FlatClosing (Image< T > &input, ByteKernel &kern, Image< T > &output)
void TopHat (Image< T > &input, ByteKernel &kern, Image< T > &output)
void BottomHat (Image< T > &input, ByteKernel &kern, Image< T > &output)
void HitOrMiss (Image< T > &input, ByteKernel &kern1, ByteKernel &kern2, Image< T > &output)
void TemplateMatch (Image< T > &input, ByteKernel &kern, Image< T > &output)
void Erosion3x3 (Image< T > &input, int iter, CONN_TYPE connect, Image< T > &output)
void Dilation3x3 (Image< T > &input, int iter, CONN_TYPE connect, Image< T > &output)
void Opening3x3 (Image< T > &input, int iter, CONN_TYPE connect, Image< T > &output)
void Closing3x3 (Image< T > &input, int iter, CONN_TYPE connect, Image< T > &output)
void Watershed (ByteImage &im, CONN_TYPE connect, IntImage &out)

Detailed Description

This group contains stand-alone functions implementing morphological operations.

Function Documentation

void BottomHat ( Image< T > & input,
ByteKernel & kern,
Image< T > & output )
 

Performs the bottom-hat transform of the input image using the structuring element kern and stores the result in the output image. The bottom-hat transform is defined by the following formula: ;

Definition at line 345 of file Morphop.cpp.

void Closing ( Image< T > & input,
ByteKernel & kern,
Image< T > & output )
 

Performs the gray level closing (denoted by in formulas) of the input image using the structuring element kern and stores the result in the output image.

Definition at line 326 of file Morphop.cpp.

void Closing3x3 ( Image< T > & input,
int iter,
CONN_TYPE connect,
Image< T > & output )
 

Performs iteratively the closing of the input image using as structural element a cross for 4-connectivity (connect = FOUR) or a disk for 8-connectivity (connect = EIGHT). The parameter iter specifies how many times (i.e. how many iterations) the closing is performed. The result is stored in the output image.

Examples:
test_morphop.cpp.

Definition at line 178 of file Morphop.cpp.

int ConnectedComponents ( IntImage & img,
CONN_TYPE connectivity = FOUR )
 

Labels the image img based on its connected components and returns the number of these connected components. The labeled image is stored in img. The parameter connectivity will determine the type of neighborhood that will be used during the labeling. This can be:

  • FOUR: four-connectivity, in which case only top, bottom, left and right pixels are considered as neighbors;
  • EIGHT: eight-connectivity, in which case also the diagonal pixels are considered as neighbors.

Definition at line 26 of file ConnectedComponents.cpp.

int ConnectedComponents ( ByteImage & img,
CONN_TYPE connectivity,
IntImage & out )
 

Labels the image img based on its connected components and returns the number of these connected components. The labeled image is stored in out. The parameter connectivity will determine the type of neighborhood that will be used during the labeling. This can be:

  • FOUR: four-connectivity, in which case only top, bottom, left and right pixels are considered as neighbors;
  • EIGHT: eight-connectivity, in which case also the diagonal pixels are considered as neighbors.

Definition at line 16 of file ConnectedComponents.cpp.

int ConnectedComponents ( IntImage & img,
CONN_TYPE connectivity,
IntImage & out )
 

Labels the image img based on its connected components and returns the number of these connected components. The labeled image is stored in out. The parameter connectivity will determine the type of neighborhood that will be used during the labeling. This can be:

  • FOUR: four-connectivity, in which case only top, bottom, left and right pixels are considered as neighbors;
  • EIGHT: eight-connectivity, in which case also the diagonal pixels are considered as neighbors.
Examples:
test_conn_comp.cpp.

Definition at line 9 of file ConnectedComponents.cpp.

void Dilation ( Image< T > & input,
ByteKernel & kern,
Image< T > & output )
 

Performs the gray level dilation (denoted by in formulas) of the input image using the structuring element kern and stores the result in the output image.

Definition at line 288 of file Morphop.cpp.

void Dilation3x3 ( Image< T > & input,
int iter,
CONN_TYPE connect,
Image< T > & output )
 

Performs iteratively the dilation of the input image using as structural element a cross for 4-connectivity (connect = FOUR) or a disk for 8-connectivity (connect = EIGHT). The parameter iter specifies how many times (i.e. how many iterations) the dilation is performed. The result is stored in the output image.

Examples:
test_morphop.cpp.

Definition at line 151 of file Morphop.cpp.

void DistanceTransform ( ByteImage & input,
DM_TYPE dm_type,
IntImage & output )
 

Computes the distance transform of the input image using the distance map type given by dm_type and stores the result in the output image. Currently defined distance map types are:

  • EUCLID: the distance function is the Euclidian distance. The implementation uses chamfering with the chamfer mask.
  • EUCLID_1: the distance function is the Euclidian distance. The implementation uses chamfering with the chamfer mask.
  • CITY_BLOCK: the distance function is the city-block distance (only the horizontal and vertical pixels are considered as neighbors, i.e. 4-connectivity).
  • CHESSBOARD: the distance function is of chessboard type (the horizontal, vertical and diagonal pixels are considered as neighbors, i.e. 8-connectivity).
The implementation is based on the algorithm described in "Distance transformation in digital images" by G. Borgefors, Comput. Vision, Graph. Image Process., no. 34, pp. 344-371, 1986.
Examples:
test_dist_trans.cpp.

Definition at line 11 of file DistanceTransform.cpp.

void Erosion ( Image< T > & input,
ByteKernel & kern,
Image< T > & output )
 

Performs the gray level erosion (denoted by in formulas) of the input image using the structuring element kern and stores the result in the output image.

Definition at line 257 of file Morphop.cpp.

void Erosion3x3 ( Image< T > & input,
int iter,
CONN_TYPE connect,
Image< T > & output )
 

Performs iteratively the erosion of the input image using as structural element a cross for 4-connectivity (connect = FOUR) or a disk for 8-connectivity (connect = EIGHT). The parameter iter specifies how many times (i.e. how many iterations) the erosion is performed. The result is stored in the output image.

Examples:
test_morphop.cpp.

Definition at line 107 of file Morphop.cpp.

void FlatClosing ( Image< T > & input,
ByteKernel & kern,
Image< T > & output )
 

Performs the gray level closing of the input image using the flat structuring element kern and stores the result in the output image.

Definition at line 250 of file Morphop.cpp.

void FlatDilation ( Image< T > & input,
ByteKernel & kern,
Image< T > & output )
 

Performs the gray level dilation of the input image using the flat structuring element kern and stores the result in the output image.

Definition at line 214 of file Morphop.cpp.

void FlatErosion ( Image< T > & input,
ByteKernel & kern,
Image< T > & output )
 

Performs the gray level erosion of the input image using the flat structuring element kern and stores the result in the output image.

Examples:
test_morphop.cpp.

Definition at line 185 of file Morphop.cpp.

void FlatOpening ( Image< T > & input,
ByteKernel & kern,
Image< T > & output )
 

Performs the gray level opening of the input image using the flat structuring element kern and stores the result in the output image.

Definition at line 243 of file Morphop.cpp.

void HitOrMiss ( Image< T > & input,
ByteKernel & kern1,
ByteKernel & kern2,
Image< T > & output )
 

Performs the hit-or-miss transform of the input image using the structuring elements kern1 and kern2 and stores the result in the output image. The hit-or-miss transform is defined by the following formula: ; where and ;

Examples:
test_morphop.cpp.

Definition at line 357 of file Morphop.cpp.

void Opening ( Image< T > & input,
ByteKernel & kern,
Image< T > & output )
 

Performs the gray level opening (denoted by in formulas) of the input image using the structuring element kern and stores the result in the output image.

Definition at line 319 of file Morphop.cpp.

void Opening3x3 ( Image< T > & input,
int iter,
CONN_TYPE connect,
Image< T > & output )
 

Performs iteratively the opening of the input image using as structural element a cross for 4-connectivity (connect = FOUR) or a disk for 8-connectivity (connect = EIGHT). The parameter iter specifies how many times (i.e. how many iterations) the opening is performed. The result is stored in the output image.

Examples:
test_morphop.cpp.

Definition at line 171 of file Morphop.cpp.

void TemplateMatch ( Image< T > & input,
ByteKernel & kern,
Image< T > & output )
 

Searches in the input image for occurrences of the structuring element specified by |a kern. The result is stored in the output image. The template match operation is defined by the following formula: ;

Examples:
test_morphop.cpp.

Definition at line 373 of file Morphop.cpp.

void TopHat ( Image< T > & input,
ByteKernel & kern,
Image< T > & output )
 

Performs the top-hat transform of the input image using the structuring element kern and stores the result in the output image. The top-hat transform is defined by the following formula: ;

Definition at line 333 of file Morphop.cpp.

void Watershed ( ByteImage & im,
CONN_TYPE connect,
IntImage & out )
 

Performs the watershed transform of the input image using the connectivity type indicated by connect and stores the result in the output image. The connectivity can be:

  • FOUR: four-connectivity, in which case only top, bottom, left and right pixels are taken as neighbors;
  • EIGHT: eight-connectivity, in which case also the diagonal pixels are considered as neighbors.
The current implementation is based on the article of Luc Vincent, Pierre Soille, "Watersheds in Digital Spaces: An Efficient Algorithm Based on Immersion Simulations", IEEE Transactions on Pattern Analysis and Machine Intelligence, vol. 13, no. 6, June 1991.
Examples:
test_watershed.cpp.

Definition at line 34 of file Watershed.cpp.