ImageDev

ApplyMorphologicalLut3d

Applies a predefined morphological lookup table (LUT) on a three-dimensional binary image.

Access to parameter description

For an introduction: Applying a morphological LUT amounts to moving some predefined configurations of neighborhood in a binary image, and then applying decisions when this configuration is encountered or not. It can be used to compute morphological operators such as thinning, thickening, or hit-or-miss in an optimized way.

Before launching this algorithm, a MorphologicalLut3d 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 ApplyMorphologicalLut3dOutput structure containing outputBinaryImage and outputMeasurement.
// Output structure of the applyMorphologicalLut3d function.
struct ApplyMorphologicalLut3dOutput
{
    /// The binary output image. Its size and type are forced to the same values as the input.
    std::shared_ptr< iolink::ImageView > outputBinaryImage;
    /// The output object containing the number of modified voxels by the selected LUT.
    ApplyMorphologicalLutMsr::Ptr outputMeasurement;
};

// Function prototype
ApplyMorphologicalLut3dOutput applyMorphologicalLut3d( std::shared_ptr< iolink::ImageView > inputBinaryImage, imagedev::MorphologicalLut3d::Ptr morphologicalLut, ApplyMorphologicalLut3d::MatchingFlag matchingFlag, ApplyMorphologicalLut3d::UnmatchingFlag unmatchingFlag, ApplyMorphologicalLut3d::BorderCondition borderCondition, std::shared_ptr< iolink::ImageView > outputBinaryImage = nullptr, ApplyMorphologicalLutMsr::Ptr outputMeasurement = nullptr );
This function returns a tuple containing output_binary_image and output_measurement.
// Function prototype.
apply_morphological_lut_3d(input_binary_image: idt.ImageType,
                           morphological_lut: MorphologicalLut3d,
                           matching_flag: ApplyMorphologicalLut3d.MatchingFlag = ApplyMorphologicalLut3d.MatchingFlag.M_SET_ONE,
                           unmatching_flag: ApplyMorphologicalLut3d.UnmatchingFlag = ApplyMorphologicalLut3d.UnmatchingFlag.U_SET_ZERO,
                           border_condition: ApplyMorphologicalLut3d.BorderCondition = ApplyMorphologicalLut3d.BorderCondition.MIRROR,
                           output_binary_image: idt.ImageType = None,
                           output_measurement: Union[Any, None] = None) -> Tuple[idt.ImageType, ApplyMorphologicalLutMsr]
This function returns a ApplyMorphologicalLut3dOutput structure containing outputBinaryImage and outputMeasurement.
/// Output structure of the ApplyMorphologicalLut3d function.
public struct ApplyMorphologicalLut3dOutput
{
    /// 
    /// The binary output image. Its size and type are forced to the same values as the input.
    /// 
    public IOLink.ImageView outputBinaryImage;
    /// The output object containing the number of modified voxels by the selected LUT.
    public ApplyMorphologicalLutMsr outputMeasurement;
};

// Function prototype.
public static ApplyMorphologicalLut3dOutput
ApplyMorphologicalLut3d( IOLink.ImageView inputBinaryImage,
                         Data.MorphologicalLut3d morphologicalLut,
                         ApplyMorphologicalLut3d.MatchingFlag matchingFlag = ImageDev.ApplyMorphologicalLut3d.MatchingFlag.M_SET_ONE,
                         ApplyMorphologicalLut3d.UnmatchingFlag unmatchingFlag = ImageDev.ApplyMorphologicalLut3d.UnmatchingFlag.U_SET_ZERO,
                         ApplyMorphologicalLut3d.BorderCondition borderCondition = ImageDev.ApplyMorphologicalLut3d.BorderCondition.MIRROR,
                         IOLink.ImageView outputBinaryImage = null,
                         ApplyMorphologicalLutMsr outputMeasurement = null );

Class Syntax

Parameters

Parameter Name Description Type Supported Values Default Value
input
inputBinaryImage
The binary input image. Image Binary nullptr
input
morphologicalLut
The input morphological LUT array defining the configurations to detect. MorphologicalLut3d MorphologicalLut3d::New( MorphologicalKernel3d::New( MorphologicalKernel3d::ONE ) )
input
matchingFlag
The value to set when a predefined configuration is encountered.
M_SET_ZERO The output value is forced to 0.
M_SET_ONE The output value is forced to 1.
M_CHANGE The output value is the logical negation of the input value.
M_PRESERVE The output value is equal to the input value.
Enumeration M_SET_ONE
input
unmatchingFlag
The value to set when a predefined configuration is not encountered.
U_SET_ZERO The output value is forced to 0.
U_SET_ONE The output value is forced to 1.
U_CHANGE The output value is the logical negation of the input value.
U_PRESERVE The output value is equal to the input value.
Enumeration U_SET_ZERO
input
borderCondition
The border condition used to extrapolate outside pixels.
ZERO Voxels outside of the image are considered as having the value 0.
MIRROR Voxels outside of the image are a replication the border image pixels.
Enumeration MIRROR
output
outputBinaryImage
The binary output image. Its size and type are forced to the same values as the input. Image nullptr
output
outputMeasurement
The output object containing the number of modified voxels by the selected LUT. ApplyMorphologicalLutMsr nullptr
Parameter Name Description Type Supported Values Default Value
input
input_binary_image
The binary input image. image Binary None
input
morphological_lut
The input morphological LUT array defining the configurations to detect. morphological_lut_3d VpParameterMorphologicalLut3d_Default
input
matching_flag
The value to set when a predefined configuration is encountered.
M_SET_ZERO The output value is forced to 0.
M_SET_ONE The output value is forced to 1.
M_CHANGE The output value is the logical negation of the input value.
M_PRESERVE The output value is equal to the input value.
enumeration M_SET_ONE
input
unmatching_flag
The value to set when a predefined configuration is not encountered.
U_SET_ZERO The output value is forced to 0.
U_SET_ONE The output value is forced to 1.
U_CHANGE The output value is the logical negation of the input value.
U_PRESERVE The output value is equal to the input value.
enumeration U_SET_ZERO
input
border_condition
The border condition used to extrapolate outside pixels.
ZERO Voxels outside of the image are considered as having the value 0.
MIRROR Voxels outside of the image are a replication the border image pixels.
enumeration MIRROR
output
output_binary_image
The binary output image. Its size and type are forced to the same values as the input. image None
output
output_measurement
The output object containing the number of modified voxels by the selected LUT. ApplyMorphologicalLutMsr None
Parameter Name Description Type Supported Values Default Value
input
inputBinaryImage
The binary input image. Image Binary null
input
morphologicalLut
The input morphological LUT array defining the configurations to detect. MorphologicalLut3d new Data.MorphologicalLut3d(new Data.MorphologicalKernel3d(Data.MorphologicalKernel3d.Value.ONE))
input
matchingFlag
The value to set when a predefined configuration is encountered.
M_SET_ZERO The output value is forced to 0.
M_SET_ONE The output value is forced to 1.
M_CHANGE The output value is the logical negation of the input value.
M_PRESERVE The output value is equal to the input value.
Enumeration M_SET_ONE
input
unmatchingFlag
The value to set when a predefined configuration is not encountered.
U_SET_ZERO The output value is forced to 0.
U_SET_ONE The output value is forced to 1.
U_CHANGE The output value is the logical negation of the input value.
U_PRESERVE The output value is equal to the input value.
Enumeration U_SET_ZERO
input
borderCondition
The border condition used to extrapolate outside pixels.
ZERO Voxels outside of the image are considered as having the value 0.
MIRROR Voxels outside of the image are a replication the border image pixels.
Enumeration MIRROR
output
outputBinaryImage
The binary output image. Its size and type are forced to the same values as the input. Image null
output
outputMeasurement
The output object containing the number of modified voxels by the selected LUT. ApplyMorphologicalLutMsr null

Object Examples

auto foam_sep = readVipImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "foam_sep.vip" );

ApplyMorphologicalLut3d applyMorphologicalLut3dAlgo;
applyMorphologicalLut3dAlgo.setInputBinaryImage( foam_sep );
applyMorphologicalLut3dAlgo.setMorphologicalLut( MorphologicalLut3d::New( MorphologicalKernel3d::New( MorphologicalKernel3d::ONE ) ) );
applyMorphologicalLut3dAlgo.setMatchingFlag( ApplyMorphologicalLut3d::MatchingFlag::M_SET_ONE );
applyMorphologicalLut3dAlgo.setUnmatchingFlag( ApplyMorphologicalLut3d::UnmatchingFlag::U_SET_ZERO );
applyMorphologicalLut3dAlgo.setBorderCondition( ApplyMorphologicalLut3d::BorderCondition::ZERO );
applyMorphologicalLut3dAlgo.execute();

std::cout << "outputBinaryImage:" << applyMorphologicalLut3dAlgo.outputBinaryImage()->toString();
std::cout << "modifiedPixelCount: " << applyMorphologicalLut3dAlgo.outputMeasurement()->modifiedPixelCount( 0 ) ;
foam_sep = imagedev.read_vip_image(imagedev_data.get_image_path("foam_sep.vip"))

apply_morphological_lut_3d_algo = imagedev.ApplyMorphologicalLut3d()
apply_morphological_lut_3d_algo.input_binary_image = foam_sep
apply_morphological_lut_3d_algo.morphological_lut = imagedev.MorphologicalLut3d(imagedev.MorphologicalKernel3d(imagedev.MorphologicalKernel3d.Value.ONE))
apply_morphological_lut_3d_algo.matching_flag = imagedev.ApplyMorphologicalLut3d.M_SET_ONE
apply_morphological_lut_3d_algo.unmatching_flag = imagedev.ApplyMorphologicalLut3d.U_SET_ZERO
apply_morphological_lut_3d_algo.border_condition = imagedev.ApplyMorphologicalLut3d.ZERO
apply_morphological_lut_3d_algo.execute()

print("output_binary_image:", str(apply_morphological_lut_3d_algo.output_binary_image))
print("modifiedPixelCount: ", str(apply_morphological_lut_3d_algo.output_measurement.modified_pixel_count(0)))
ImageView foam_sep = Data.ReadVipImage( @"Data/images/foam_sep.vip" );

ApplyMorphologicalLut3d applyMorphologicalLut3dAlgo = new ApplyMorphologicalLut3d
{
    inputBinaryImage = foam_sep,
    morphologicalLut = new Data.MorphologicalLut3d(new Data.MorphologicalKernel3d(Data.MorphologicalKernel3d.Value.ONE)),
    matchingFlag = ApplyMorphologicalLut3d.MatchingFlag.M_SET_ONE,
    unmatchingFlag = ApplyMorphologicalLut3d.UnmatchingFlag.U_SET_ZERO,
    borderCondition = ApplyMorphologicalLut3d.BorderCondition.ZERO
};
applyMorphologicalLut3dAlgo.Execute();

Console.WriteLine( "outputBinaryImage:" + applyMorphologicalLut3dAlgo.outputBinaryImage.ToString() );
Console.WriteLine( "modifiedPixelCount: " + applyMorphologicalLut3dAlgo.outputMeasurement.modifiedPixelCount( 0 ) );

Function Examples

auto foam_sep = readVipImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "foam_sep.vip" );

auto result = applyMorphologicalLut3d( foam_sep, MorphologicalLut3d::New( MorphologicalKernel3d::New( MorphologicalKernel3d::ONE ) ), ApplyMorphologicalLut3d::MatchingFlag::M_SET_ONE, ApplyMorphologicalLut3d::UnmatchingFlag::U_SET_ZERO, ApplyMorphologicalLut3d::BorderCondition::ZERO );

std::cout << "outputBinaryImage:" << result.outputBinaryImage->toString();
std::cout << "modifiedPixelCount: " << result.outputMeasurement->modifiedPixelCount( 0 ) ;
foam_sep = imagedev.read_vip_image(imagedev_data.get_image_path("foam_sep.vip"))

result_output_binary_image, result_output_measurement = imagedev.apply_morphological_lut_3d(foam_sep, imagedev.MorphologicalLut3d(imagedev.MorphologicalKernel3d(imagedev.MorphologicalKernel3d.Value.ONE)), imagedev.ApplyMorphologicalLut3d.M_SET_ONE, imagedev.ApplyMorphologicalLut3d.U_SET_ZERO, imagedev.ApplyMorphologicalLut3d.ZERO)

print("output_binary_image:", str(result_output_binary_image))
print("modifiedPixelCount: ", str(result_output_measurement.modified_pixel_count(0)))
ImageView foam_sep = Data.ReadVipImage( @"Data/images/foam_sep.vip" );

Processing.ApplyMorphologicalLut3dOutput result = Processing.ApplyMorphologicalLut3d( foam_sep, new Data.MorphologicalLut3d(new Data.MorphologicalKernel3d(Data.MorphologicalKernel3d.Value.ONE)), ApplyMorphologicalLut3d.MatchingFlag.M_SET_ONE, ApplyMorphologicalLut3d.UnmatchingFlag.U_SET_ZERO, ApplyMorphologicalLut3d.BorderCondition.ZERO );

Console.WriteLine( "outputBinaryImage:" + result.outputBinaryImage.ToString() );
Console.WriteLine(  "modifiedPixelCount: " + result.outputMeasurement.modifiedPixelCount( 0 )  );