ApplyMorphologicalLut2d
Applies a predefined morphological lookup table (LUT) on a two-dimensional binary image.
Access to parameter description
For an introduction:
Before launching this algorithm, a MorphologicalLut2d object has to be built and set as the morphologicalLut parameter. The kernels defining the searched configurations can be inserted in this object with its addKernel method.
See also
Access to parameter description
For an introduction:
- section Mathematical Morphology
- section Morphological LUT
Before launching this algorithm, a MorphologicalLut2d object has to be built and set as the morphologicalLut parameter. The kernels defining the searched configurations can be inserted in this object with its addKernel method.
See also
Function Syntax
This function returns a ApplyMorphologicalLut2dOutput structure containing the outputBinaryImage and outputMeasurement output parameters.
// Output structure. struct ApplyMorphologicalLut2dOutput { std::shared_ptr< iolink::ImageView > outputBinaryImage; ApplyMorphologicalLutMsr::Ptr outputMeasurement; }; // Function prototype. ApplyMorphologicalLut2dOutput applyMorphologicalLut2d( std::shared_ptr< iolink::ImageView > inputBinaryImage, imagedev::MorphologicalLut2d::Ptr morphologicalLut, ApplyMorphologicalLut2d::MatchingFlag matchingFlag, ApplyMorphologicalLut2d::UnmatchingFlag unmatchingFlag, ApplyMorphologicalLut2d::BorderCondition borderCondition, std::shared_ptr< iolink::ImageView > outputBinaryImage = NULL, ApplyMorphologicalLutMsr::Ptr outputMeasurement = NULL );
This function returns a tuple containing the output_binary_image and output_measurement output parameters.
// Function prototype. apply_morphological_lut_2d( input_binary_image, morphological_lut, matching_flag = ApplyMorphologicalLut2d.MatchingFlag.M_SET_ONE, unmatching_flag = ApplyMorphologicalLut2d.UnmatchingFlag.U_SET_ZERO, border_condition = ApplyMorphologicalLut2d.BorderCondition.ZERO, output_binary_image = None, output_measurement = None )
This function returns a ApplyMorphologicalLut2dOutput structure containing the outputBinaryImage and outputMeasurement output parameters.
/// Output structure of the ApplyMorphologicalLut2d function. public struct ApplyMorphologicalLut2dOutput { public IOLink.ImageView outputBinaryImage; public ApplyMorphologicalLutMsr outputMeasurement; }; // Function prototype. public static ApplyMorphologicalLut2dOutput ApplyMorphologicalLut2d( IOLink.ImageView inputBinaryImage, Data.MorphologicalLut2d morphologicalLut, ApplyMorphologicalLut2d.MatchingFlag matchingFlag = ImageDev.ApplyMorphologicalLut2d.MatchingFlag.M_SET_ONE, ApplyMorphologicalLut2d.UnmatchingFlag unmatchingFlag = ImageDev.ApplyMorphologicalLut2d.UnmatchingFlag.U_SET_ZERO, ApplyMorphologicalLut2d.BorderCondition borderCondition = ImageDev.ApplyMorphologicalLut2d.BorderCondition.ZERO, IOLink.ImageView outputBinaryImage = null, ApplyMorphologicalLutMsr outputMeasurement = null );
Class Syntax
Parameters
Class Name | ApplyMorphologicalLut2d |
---|
Parameter Name | Description | Type | Supported Values | Default Value | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
inputBinaryImage |
The binary input image. | Image | Binary | nullptr | |||||||||
morphologicalLut |
The input morphological LUT array defining the configurations to detect. | MorphologicalLut2d | MorphologicalLut2d::New( MorphologicalKernel2d::New( MorphologicalKernel2d::ONE ) ) | ||||||||||
matchingFlag |
The value to set when a predefined configuration is encountered.
|
Enumeration | M_SET_ONE | ||||||||||
unmatchingFlag |
The value to set when the predefined configuration is not encountered.
|
Enumeration | U_SET_ZERO | ||||||||||
borderCondition |
The border condition used to extrapolate outside pixels.
|
Enumeration | ZERO | ||||||||||
outputBinaryImage |
The binary output image. Its size and type are forced to the same values as the input. | Image | nullptr | ||||||||||
outputMeasurement |
The output object containing the number of modified voxels by the selected LUT. | ApplyMorphologicalLutMsr | nullptr |
Object Examples
auto polystyrene_mask = readVipImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "polystyrene_mask.vip" ); ApplyMorphologicalLut2d applyMorphologicalLut2dAlgo; applyMorphologicalLut2dAlgo.setInputBinaryImage( polystyrene_mask ); applyMorphologicalLut2dAlgo.setMorphologicalLut( MorphologicalLut2d::New( MorphologicalKernel2d::New( MorphologicalKernel2d::ONE ) ) ); applyMorphologicalLut2dAlgo.setMatchingFlag( ApplyMorphologicalLut2d::MatchingFlag::M_SET_ONE ); applyMorphologicalLut2dAlgo.setUnmatchingFlag( ApplyMorphologicalLut2d::UnmatchingFlag::U_SET_ZERO ); applyMorphologicalLut2dAlgo.setBorderCondition( ApplyMorphologicalLut2d::BorderCondition::ZERO ); applyMorphologicalLut2dAlgo.execute(); std::cout << "outputBinaryImage:" << applyMorphologicalLut2dAlgo.outputBinaryImage()->toString(); std::cout << "modifiedPixelCount: " << applyMorphologicalLut2dAlgo.outputMeasurement()->modifiedPixelCount( 0 ) ;
polystyrene_mask = imagedev.read_vip_image(imagedev_data.get_image_path("polystyrene_mask.vip")) apply_morphological_lut_2d_algo = imagedev.ApplyMorphologicalLut2d() apply_morphological_lut_2d_algo.input_binary_image = polystyrene_mask apply_morphological_lut_2d_algo.morphological_lut = imagedev.MorphologicalLut2d(imagedev.MorphologicalKernel2d(imagedev.MorphologicalKernel2d.Value.ONE)) apply_morphological_lut_2d_algo.matching_flag = imagedev.ApplyMorphologicalLut2d.M_SET_ONE apply_morphological_lut_2d_algo.unmatching_flag = imagedev.ApplyMorphologicalLut2d.U_SET_ZERO apply_morphological_lut_2d_algo.border_condition = imagedev.ApplyMorphologicalLut2d.ZERO apply_morphological_lut_2d_algo.execute() print( "output_binary_image:", str( apply_morphological_lut_2d_algo.output_binary_image ) ) print( "modifiedPixelCount: ", str( apply_morphological_lut_2d_algo.output_measurement.modified_pixel_count( 0 ) ) )
ImageView polystyrene_mask = Data.ReadVipImage( @"Data/images/polystyrene_mask.vip" ); ApplyMorphologicalLut2d applyMorphologicalLut2dAlgo = new ApplyMorphologicalLut2d { inputBinaryImage = polystyrene_mask, morphologicalLut = new Data.MorphologicalLut2d(new Data.MorphologicalKernel2d(Data.MorphologicalKernel2d.Value.ONE)), matchingFlag = ApplyMorphologicalLut2d.MatchingFlag.M_SET_ONE, unmatchingFlag = ApplyMorphologicalLut2d.UnmatchingFlag.U_SET_ZERO, borderCondition = ApplyMorphologicalLut2d.BorderCondition.ZERO }; applyMorphologicalLut2dAlgo.Execute(); Console.WriteLine( "outputBinaryImage:" + applyMorphologicalLut2dAlgo.outputBinaryImage.ToString() ); Console.WriteLine( "modifiedPixelCount: " + applyMorphologicalLut2dAlgo.outputMeasurement.modifiedPixelCount( 0 ) );
Function Examples
auto polystyrene_mask = readVipImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "polystyrene_mask.vip" ); auto result = applyMorphologicalLut2d( polystyrene_mask, MorphologicalLut2d::New( MorphologicalKernel2d::New( MorphologicalKernel2d::ONE ) ), ApplyMorphologicalLut2d::MatchingFlag::M_SET_ONE, ApplyMorphologicalLut2d::UnmatchingFlag::U_SET_ZERO, ApplyMorphologicalLut2d::BorderCondition::ZERO ); std::cout << "outputBinaryImage:" << result.outputBinaryImage->toString(); std::cout << "modifiedPixelCount: " << result.outputMeasurement->modifiedPixelCount( 0 ) ;
polystyrene_mask = imagedev.read_vip_image(imagedev_data.get_image_path("polystyrene_mask.vip")) result_output_binary_image, result_output_measurement = imagedev.apply_morphological_lut_2d( polystyrene_mask, imagedev.MorphologicalLut2d(imagedev.MorphologicalKernel2d(imagedev.MorphologicalKernel2d.Value.ONE)), imagedev.ApplyMorphologicalLut2d.M_SET_ONE, imagedev.ApplyMorphologicalLut2d.U_SET_ZERO, imagedev.ApplyMorphologicalLut2d.ZERO ) print( "output_binary_image:", str( result_output_binary_image ) ) print( "modifiedPixelCount: ", str( result_output_measurement.modified_pixel_count( 0 ) ) )
ImageView polystyrene_mask = Data.ReadVipImage( @"Data/images/polystyrene_mask.vip" ); Processing.ApplyMorphologicalLut2dOutput result = Processing.ApplyMorphologicalLut2d( polystyrene_mask, new Data.MorphologicalLut2d(new Data.MorphologicalKernel2d(Data.MorphologicalKernel2d.Value.ONE)), ApplyMorphologicalLut2d.MatchingFlag.M_SET_ONE, ApplyMorphologicalLut2d.UnmatchingFlag.U_SET_ZERO, ApplyMorphologicalLut2d.BorderCondition.ZERO ); Console.WriteLine( "outputBinaryImage:" + result.outputBinaryImage.ToString() ); Console.WriteLine( "modifiedPixelCount: " + result.outputMeasurement.modifiedPixelCount( 0 ) );