Superpixel techniques consist in segmenting an image into regions by considering similarity measures.
The idea is to create a group of pixels that share common characteristics (like pixel intensity).
The motivation is to obtain regions that represent meaningful descriptions with far less data than
when using all image pixels.
Superpixels replace the rigid pixel structure by delineating regions that maintain meaning in the
image, so the regions provide information about the structure of the scene, making other processing
tasks simpler than using single image pixels.
The Waterpixel algorithm computes an image of binary borders or labeled regions associated to a grid of
user-defined cell size. This grid is warped to fit the input image high intensities, generally representing
edges. The warping is performed by applying a watershed on the input image. Markers used by the watershed
are choosen as local minima close to the cell centers.
In order to ensure a regular size to the output superpixels, the input image is blended with the grid.
A regularization factor is used to control the weight given to the grid relatively to the original intensities.
(a)
(b)
(c)
Figure 1. Superpixel generation with the waterpixel algorithm:(a) Input image given by a morphological gradient,
(b) waterpixels emphasizing the regular grid (high regularization factor),
(c) waterpixels emphasizing the input image (low regularization factor)
Reference: V. Machairas, E. Decenciere, T. Walter. "Waterpixels: Superpixels based on the watershed transformation".
IEEE International Conference On Image Processing, Paris, France, Oct 2014.
// Command constructor.Waterpixel();/// Gets the inputImage parameter./// The input grayscale image highlighting object boundaries, generally a gradient image.
std::shared_ptr< iolink::ImageView> inputImage()const;/// Sets the inputImage parameter./// The input grayscale image highlighting object boundaries, generally a gradient image.void setInputImage( std::shared_ptr< iolink::ImageView> inputImage );/// Gets the cellSize parameter./// The side size, in pixels, of the square cells used to generate superpixels.uint32_t cellSize()const;/// Sets the cellSize parameter./// The side size, in pixels, of the square cells used to generate superpixels.void setCellSize(constuint32_t& cellSize );/// Gets the factor parameter./// The spatial regularization factor.uint32_t factor()const;/// Sets the factor parameter./// The spatial regularization factor.void setFactor(constuint32_t& factor );/// Gets the algorithmMode parameter./// The mode for applying the watershed algorithm.Waterpixel::AlgorithmMode algorithmMode()const;/// Sets the algorithmMode parameter./// The mode for applying the watershed algorithm.void setAlgorithmMode(constWaterpixel::AlgorithmMode& algorithmMode );/// Gets the outputType parameter./// The type of output.Waterpixel::OutputType outputType()const;/// Sets the outputType parameter./// The type of output.void setOutputType(constWaterpixel::OutputType& outputType );/// Gets the outputImage parameter./// The output binary or label image. Its dimensions are forced to the same values as the input image. Its type depends on the outputType parameter.
std::shared_ptr< iolink::ImageView> outputImage()const;/// Sets the outputImage parameter./// The output binary or label image. Its dimensions are forced to the same values as the input image. Its type depends on the outputType parameter.void setOutputImage( std::shared_ptr< iolink::ImageView> outputImage );// Method to launch the command.void execute();
# Property of the inputImage parameter.Waterpixel.input_image
# Property of the cellSize parameter.Waterpixel.cell_size
# Property of the factor parameter.Waterpixel.factor
# Property of the algorithmMode parameter.Waterpixel.algorithm_mode
# Property of the outputType parameter.Waterpixel.output_type
# Property of the outputImage parameter.Waterpixel.output_image
// Method to launch the command.
execute()
// Command constructor.Waterpixel()// Property of the inputImage parameter.Waterpixel.inputImage
// Property of the cellSize parameter.Waterpixel.cellSize
// Property of the factor parameter.Waterpixel.factor
// Property of the algorithmMode parameter.Waterpixel.algorithmMode
// Property of the outputType parameter.Waterpixel.outputType
// Property of the outputImage parameter.Waterpixel.outputImage
// Method to launch the command.Execute()
Parameters
Parameter Name
Description
Type
Supported Values
Default Value
inputImage
The input grayscale image highlighting object boundaries, generally a gradient image.
Image
Grayscale
nullptr
cellSize
The side size, in pixels, of the square cells used to generate superpixels.
UInt32
>=3
25
factor
The spatial regularization factor.
A low value makes the output superpixels fit on original intensities and
generates irregular regions.
A high value makes the output superpixels fit on cell boundaries.
UInt32
Any value
10
outputType
The type of output.
LINES
The output image is a binary image containing superpixels boundaries.
CONTIGUOUS_REGIONS
The output image is a label image representing connected superpixels.
SEPARATED_REGIONS
The output image is a label image representing superpixels separated by a line of background.
Enumeration
SEPARATED_REGIONS
algorithmMode
The mode for applying the watershed algorithm.
REPEATABLE
The result is repeatable but slower to compute.
FAST
The result is faster to compute but not repeatable because of asynchronous parallel computation. Since a watershed problem does not generally have a unique solution, two processings of the same image can lead to two different results (both exact).
Enumeration
REPEATABLE
outputImage
The output binary or label image. Its dimensions are forced to the same values as the input image. Its type depends on the outputType parameter.
Image
nullptr
Parameter Name
Description
Type
Supported Values
Default Value
input_image
The input grayscale image highlighting object boundaries, generally a gradient image.
image
Grayscale
None
cell_size
The side size, in pixels, of the square cells used to generate superpixels.
uint32
>=3
25
factor
The spatial regularization factor.
A low value makes the output superpixels fit on original intensities and
generates irregular regions.
A high value makes the output superpixels fit on cell boundaries.
uint32
Any value
10
output_type
The type of output.
LINES
The output image is a binary image containing superpixels boundaries.
CONTIGUOUS_REGIONS
The output image is a label image representing connected superpixels.
SEPARATED_REGIONS
The output image is a label image representing superpixels separated by a line of background.
enumeration
SEPARATED_REGIONS
algorithm_mode
The mode for applying the watershed algorithm.
REPEATABLE
The result is repeatable but slower to compute.
FAST
The result is faster to compute but not repeatable because of asynchronous parallel computation. Since a watershed problem does not generally have a unique solution, two processings of the same image can lead to two different results (both exact).
enumeration
REPEATABLE
output_image
The output binary or label image. Its dimensions are forced to the same values as the input image. Its type depends on the outputType parameter.
image
None
Parameter Name
Description
Type
Supported Values
Default Value
inputImage
The input grayscale image highlighting object boundaries, generally a gradient image.
Image
Grayscale
null
cellSize
The side size, in pixels, of the square cells used to generate superpixels.
UInt32
>=3
25
factor
The spatial regularization factor.
A low value makes the output superpixels fit on original intensities and
generates irregular regions.
A high value makes the output superpixels fit on cell boundaries.
UInt32
Any value
10
outputType
The type of output.
LINES
The output image is a binary image containing superpixels boundaries.
CONTIGUOUS_REGIONS
The output image is a label image representing connected superpixels.
SEPARATED_REGIONS
The output image is a label image representing superpixels separated by a line of background.
Enumeration
SEPARATED_REGIONS
algorithmMode
The mode for applying the watershed algorithm.
REPEATABLE
The result is repeatable but slower to compute.
FAST
The result is faster to compute but not repeatable because of asynchronous parallel computation. Since a watershed problem does not generally have a unique solution, two processings of the same image can lead to two different results (both exact).
Enumeration
REPEATABLE
outputImage
The output binary or label image. Its dimensions are forced to the same values as the input image. Its type depends on the outputType parameter.