Pruning2d
Point detector removing spurs from a two-dimensional binary image.
Access to parameter description
For an introduction:
It can be applied either specifying a number of iterations or until convergence.
This filter can be used for removing terminal branches from a skeleton, also known as spurs.
The skeleton is very sensitive to small distortions on the edges of the objects, generating artifacts. The pruning algorithm eliminates these artifacts by thinning with the following structuring element until convergence or for a predefined number of iterations.
The skeleton is first detected, and then this algorithm performs a thinning transform with the following configuration and its 7 associated rotations: $$ \begin{array}{ccc} 0 & 0 & \times\\ 0 & 1 & 0\\ 0 & 0 & 0 \end{array} $$ Where $\times$ means "don't care".
It is generally tedious to determine the number of iterations for the pruning and thinning until convergence removes all the skeletons except loops and branches intersecting the frame of the image in permissive mode.
The strict mode stops when an intersection or a right angle is encountered.
See also
Access to parameter description
For an introduction:
- section Mathematical Morphology
- section Point Detectors
It can be applied either specifying a number of iterations or until convergence.
This filter can be used for removing terminal branches from a skeleton, also known as spurs.
The skeleton is very sensitive to small distortions on the edges of the objects, generating artifacts. The pruning algorithm eliminates these artifacts by thinning with the following structuring element until convergence or for a predefined number of iterations.
The skeleton is first detected, and then this algorithm performs a thinning transform with the following configuration and its 7 associated rotations: $$ \begin{array}{ccc} 0 & 0 & \times\\ 0 & 1 & 0\\ 0 & 0 & 0 \end{array} $$ Where $\times$ means "don't care".
It is generally tedious to determine the number of iterations for the pruning and thinning until convergence removes all the skeletons except loops and branches intersecting the frame of the image in permissive mode.
The strict mode stops when an intersection or a right angle is encountered.
See also
Function Syntax
This function returns outputBinaryImage.
// Function prototype
std::shared_ptr< iolink::ImageView > pruning2d( std::shared_ptr< iolink::ImageView > inputBinaryImage, Pruning2d::PruningMode pruningMode, int32_t numberOfIterations, std::shared_ptr< iolink::ImageView > outputBinaryImage = nullptr );
This function returns outputBinaryImage.
// Function prototype. pruning_2d(input_binary_image: idt.ImageType, pruning_mode: Pruning2d.PruningMode = Pruning2d.PruningMode.RIGOROUS, number_of_iterations: int = 1, output_binary_image: idt.ImageType = None) -> idt.ImageType
This function returns outputBinaryImage.
// Function prototype. public static IOLink.ImageView Pruning2d( IOLink.ImageView inputBinaryImage, Pruning2d.PruningMode pruningMode = ImageDev.Pruning2d.PruningMode.RIGOROUS, Int32 numberOfIterations = 1, IOLink.ImageView outputBinaryImage = null );
Class Syntax
Parameters
Parameter Name | Description | Type | Supported Values | Default Value | |||||
---|---|---|---|---|---|---|---|---|---|
inputBinaryImage |
The binary input image. | Image | Binary | nullptr | |||||
pruningMode |
The mode for removing end points.
|
Enumeration | RIGOROUS | ||||||
numberOfIterations |
The number of iterations. If equal to 0, the algorithm is run until convergence. | Int32 | >=0 | 1 | |||||
outputBinaryImage |
The binary output image. Its size and type are forced to the same values as the input. | Image | nullptr |
Parameter Name | Description | Type | Supported Values | Default Value | |||||
---|---|---|---|---|---|---|---|---|---|
input_binary_image |
The binary input image. | image | Binary | None | |||||
pruning_mode |
The mode for removing end points.
|
enumeration | RIGOROUS | ||||||
number_of_iterations |
The number of iterations. If equal to 0, the algorithm is run until convergence. | int32 | >=0 | 1 | |||||
output_binary_image |
The binary output image. Its size and type are forced to the same values as the input. | image | None |
Parameter Name | Description | Type | Supported Values | Default Value | |||||
---|---|---|---|---|---|---|---|---|---|
inputBinaryImage |
The binary input image. | Image | Binary | null | |||||
pruningMode |
The mode for removing end points.
|
Enumeration | RIGOROUS | ||||||
numberOfIterations |
The number of iterations. If equal to 0, the algorithm is run until convergence. | Int32 | >=0 | 1 | |||||
outputBinaryImage |
The binary output image. Its size and type are forced to the same values as the input. | Image | null |
Object Examples
auto polystyrene_sep = readVipImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "polystyrene_sep.vip" ); Pruning2d pruning2dAlgo; pruning2dAlgo.setInputBinaryImage( polystyrene_sep ); pruning2dAlgo.setPruningMode( Pruning2d::PruningMode::RIGOROUS ); pruning2dAlgo.setNumberOfIterations( 1 ); pruning2dAlgo.execute(); std::cout << "outputBinaryImage:" << pruning2dAlgo.outputBinaryImage()->toString();
polystyrene_sep = imagedev.read_vip_image(imagedev_data.get_image_path("polystyrene_sep.vip")) pruning_2d_algo = imagedev.Pruning2d() pruning_2d_algo.input_binary_image = polystyrene_sep pruning_2d_algo.pruning_mode = imagedev.Pruning2d.RIGOROUS pruning_2d_algo.number_of_iterations = 1 pruning_2d_algo.execute() print("output_binary_image:", str(pruning_2d_algo.output_binary_image))
ImageView polystyrene_sep = Data.ReadVipImage( @"Data/images/polystyrene_sep.vip" ); Pruning2d pruning2dAlgo = new Pruning2d { inputBinaryImage = polystyrene_sep, pruningMode = Pruning2d.PruningMode.RIGOROUS, numberOfIterations = 1 }; pruning2dAlgo.Execute(); Console.WriteLine( "outputBinaryImage:" + pruning2dAlgo.outputBinaryImage.ToString() );
Function Examples
auto polystyrene_sep = readVipImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "polystyrene_sep.vip" ); auto result = pruning2d( polystyrene_sep, Pruning2d::PruningMode::RIGOROUS, 1 ); std::cout << "outputBinaryImage:" << result->toString();
polystyrene_sep = imagedev.read_vip_image(imagedev_data.get_image_path("polystyrene_sep.vip")) result = imagedev.pruning_2d(polystyrene_sep, imagedev.Pruning2d.RIGOROUS, 1) print("output_binary_image:", str(result))
ImageView polystyrene_sep = Data.ReadVipImage( @"Data/images/polystyrene_sep.vip" ); IOLink.ImageView result = Processing.Pruning2d( polystyrene_sep, Pruning2d.PruningMode.RIGOROUS, 1 ); Console.WriteLine( "outputBinaryImage:" + result.ToString() );