ImageDev

RegionalExtrema2d

Computes the regional maxima or minima of a two-dimensional grayscale image and marks them in a binary image.

Access to parameter description

For an introduction: This algorithm computes the regional (or relative) maxima or minima of a grayscale image $I$ and creates a binary image $O$ containing these extrema.

A regional maximum (resp. minimum) $C$ is a set of connected pixels such that:

<b> Figure 1.</b> One-dimensional example of a regional maxima detection
Figure 1. One-dimensional example of a regional maxima detection


<b> Figure 2.</b> One-dimensional example of a regional minima detection
Figure 2. One-dimensional example of a regional minima detection


This algorithm uses a recursive method combined with a geodesic propagation.
To avoid getting too many regions in the output image, the input should be smoothed first with a low-pass filter or with the numerical reconstruction algorithm.




Figure 3. Original image (left) and regional maxima in red (right)


Reference:
P. Soille, Morphological Image Analysis. Principles and Applications, Second Edition, Springer-Verlag, Berlin, pp.201-203, 2003.

See also

Function Syntax

This function returns outputBinaryImage.
// Function prototype
std::shared_ptr< iolink::ImageView > regionalExtrema2d( std::shared_ptr< iolink::ImageView > inputImage, RegionalExtrema2d::ExtremaType extremaType, RegionalExtrema2d::Neighborhood neighborhood, std::shared_ptr< iolink::ImageView > outputBinaryImage = nullptr );
This function returns outputBinaryImage.
// Function prototype.
regional_extrema_2d(input_image: idt.ImageType,
                    extrema_type: RegionalExtrema2d.ExtremaType = RegionalExtrema2d.ExtremaType.MAXIMA,
                    neighborhood: RegionalExtrema2d.Neighborhood = RegionalExtrema2d.Neighborhood.CONNECTIVITY_8,
                    output_binary_image: idt.ImageType = None) -> idt.ImageType
This function returns outputBinaryImage.
// Function prototype.
public static IOLink.ImageView
RegionalExtrema2d( IOLink.ImageView inputImage,
                   RegionalExtrema2d.ExtremaType extremaType = ImageDev.RegionalExtrema2d.ExtremaType.MAXIMA,
                   RegionalExtrema2d.Neighborhood neighborhood = ImageDev.RegionalExtrema2d.Neighborhood.CONNECTIVITY_8,
                   IOLink.ImageView outputBinaryImage = null );

Class Syntax

Parameters

Parameter Name Description Type Supported Values Default Value
input
inputImage
The input grayscale image. Image Grayscale nullptr
input
extremaType
The type of extrema to detect.
MAXIMA The regional maxima are extracted from the input image.
MINIMA The regional minima are extracted from the input image.
Enumeration MAXIMA
input
neighborhood
The 2D neighborhood configuration used for geodesic propagation.
CONNECTIVITY_4 The neighborhood configuration is a cross.
CONNECTIVITY_8 The neighborhood configuration is a square.
Enumeration CONNECTIVITY_8
output
outputBinaryImage
The output binary image. Its dimensions are forced to the same values as the input. Image nullptr
Parameter Name Description Type Supported Values Default Value
input
input_image
The input grayscale image. image Grayscale None
input
extrema_type
The type of extrema to detect.
MAXIMA The regional maxima are extracted from the input image.
MINIMA The regional minima are extracted from the input image.
enumeration MAXIMA
input
neighborhood
The 2D neighborhood configuration used for geodesic propagation.
CONNECTIVITY_4 The neighborhood configuration is a cross.
CONNECTIVITY_8 The neighborhood configuration is a square.
enumeration CONNECTIVITY_8
output
output_binary_image
The output binary image. Its dimensions are forced to the same values as the input. image None
Parameter Name Description Type Supported Values Default Value
input
inputImage
The input grayscale image. Image Grayscale null
input
extremaType
The type of extrema to detect.
MAXIMA The regional maxima are extracted from the input image.
MINIMA The regional minima are extracted from the input image.
Enumeration MAXIMA
input
neighborhood
The 2D neighborhood configuration used for geodesic propagation.
CONNECTIVITY_4 The neighborhood configuration is a cross.
CONNECTIVITY_8 The neighborhood configuration is a square.
Enumeration CONNECTIVITY_8
output
outputBinaryImage
The output binary image. Its dimensions are forced to the same values as the input. Image null

Object Examples

auto polystyrene = ioformat::readImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "polystyrene.tif" );

RegionalExtrema2d regionalExtrema2dAlgo;
regionalExtrema2dAlgo.setInputImage( polystyrene );
regionalExtrema2dAlgo.setExtremaType( RegionalExtrema2d::ExtremaType::MAXIMA );
regionalExtrema2dAlgo.setNeighborhood( RegionalExtrema2d::Neighborhood::CONNECTIVITY_8 );
regionalExtrema2dAlgo.execute();

std::cout << "outputBinaryImage:" << regionalExtrema2dAlgo.outputBinaryImage()->toString();
polystyrene = ioformat.read_image(imagedev_data.get_image_path("polystyrene.tif"))

regional_extrema_2d_algo = imagedev.RegionalExtrema2d()
regional_extrema_2d_algo.input_image = polystyrene
regional_extrema_2d_algo.extrema_type = imagedev.RegionalExtrema2d.MAXIMA
regional_extrema_2d_algo.neighborhood = imagedev.RegionalExtrema2d.CONNECTIVITY_8
regional_extrema_2d_algo.execute()

print("output_binary_image:", str(regional_extrema_2d_algo.output_binary_image))
ImageView polystyrene = ViewIO.ReadImage( @"Data/images/polystyrene.tif" );

RegionalExtrema2d regionalExtrema2dAlgo = new RegionalExtrema2d
{
    inputImage = polystyrene,
    extremaType = RegionalExtrema2d.ExtremaType.MAXIMA,
    neighborhood = RegionalExtrema2d.Neighborhood.CONNECTIVITY_8
};
regionalExtrema2dAlgo.Execute();

Console.WriteLine( "outputBinaryImage:" + regionalExtrema2dAlgo.outputBinaryImage.ToString() );

Function Examples

auto polystyrene = ioformat::readImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "polystyrene.tif" );

auto result = regionalExtrema2d( polystyrene, RegionalExtrema2d::ExtremaType::MAXIMA, RegionalExtrema2d::Neighborhood::CONNECTIVITY_8 );

std::cout << "outputBinaryImage:" << result->toString();
polystyrene = ioformat.read_image(imagedev_data.get_image_path("polystyrene.tif"))

result = imagedev.regional_extrema_2d(polystyrene, imagedev.RegionalExtrema2d.MAXIMA, imagedev.RegionalExtrema2d.CONNECTIVITY_8)

print("output_binary_image:", str(result))
ImageView polystyrene = ViewIO.ReadImage( @"Data/images/polystyrene.tif" );

IOLink.ImageView result = Processing.RegionalExtrema2d( polystyrene, RegionalExtrema2d.ExtremaType.MAXIMA, RegionalExtrema2d.Neighborhood.CONNECTIVITY_8 );

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