ImageDev

ReorderLabels

Forces values of a label image to be consecutive.

Access to parameter description

When a label image contains missing values in its histogram, it is not always possible to reassign consecutive labels automatically using the labeling algorithm, as shown in Figure 1.
By definition, it assigns a unique value to each connected component.
ReorderLabels fills the missing values of the histogram while preserving the original connectivity of the input labels.

<b> (a) </b>
(a)
<b> (b) </b>
(b)
<b> (c) </b>
(c)
Figure 1. Effects of the label reordering algorithm: (a) input label image,@Br (b) output of the labeling algorithm, (c) output of the ReorderLabels algorithm

See also

Function Syntax

This function returns outputLabelImage.
// Function prototype
std::shared_ptr< iolink::ImageView > reorderLabels( std::shared_ptr< iolink::ImageView > inputLabelImage, std::shared_ptr< iolink::ImageView > outputLabelImage = NULL );
This function returns outputLabelImage.
// Function prototype.
reorder_labels( input_label_image, output_label_image = None )
This function returns outputLabelImage.
// Function prototype.
public static IOLink.ImageView
ReorderLabels( IOLink.ImageView inputLabelImage, IOLink.ImageView outputLabelImage = null );

Class Syntax

Parameters

Class Name ReorderLabels

Parameter Name Description Type Supported Values Default Value
input
inputLabelImage
The input label image. Image Label nullptr
output
outputLabelImage
The output label image. Its dimensions and type are forced to the same values as the input. Image nullptr

Object Examples

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

ReorderLabels reorderLabelsAlgo;
reorderLabelsAlgo.setInputLabelImage( foam_sep_label );
reorderLabelsAlgo.execute();

std::cout << "outputLabelImage:" << reorderLabelsAlgo.outputLabelImage()->toString();
foam_sep_label = imagedev.read_vip_image(imagedev_data.get_image_path("foam_sep_label.vip"))

reorder_labels_algo = imagedev.ReorderLabels()
reorder_labels_algo.input_label_image = foam_sep_label
reorder_labels_algo.execute()

print( "output_label_image:", str( reorder_labels_algo.output_label_image ) )
ImageView foam_sep_label = Data.ReadVipImage( @"Data/images/foam_sep_label.vip" );

ReorderLabels reorderLabelsAlgo = new ReorderLabels
{
    inputLabelImage = foam_sep_label
};
reorderLabelsAlgo.Execute();

Console.WriteLine( "outputLabelImage:" + reorderLabelsAlgo.outputLabelImage.ToString() );

Function Examples

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

auto result = reorderLabels( foam_sep_label );

std::cout << "outputLabelImage:" << result->toString();
foam_sep_label = imagedev.read_vip_image(imagedev_data.get_image_path("foam_sep_label.vip"))

result = imagedev.reorder_labels( foam_sep_label )

print( "output_label_image:", str( result ) )
ImageView foam_sep_label = Data.ReadVipImage( @"Data/images/foam_sep_label.vip" );

IOLink.ImageView result = Processing.ReorderLabels( foam_sep_label );

Console.WriteLine( "outputLabelImage:" + result.ToString() );