ImageDev

StructureEnhancementFilter2d

Enhances structures of interest in a two-dimensional image using a multi-scale analysis.

Access to parameter description

Overview

This algorithm generates a score image that can be used with the goal of segmenting the input image.

It computes a score between 0 and 1 for each pixel: 1 representing a good match with a structure model and 0 a background pixel. This provides a powerful technique for automatically identifying structures such as blood vessels.
The score can be computed either on an Hessian matrix to detect ridge structures, or on a gradient structure tensor for object edges and corners.
The structure models available are: The principle of the algorithm can be summarized as follows: References:

Tensor Extraction

Two modes are available for computing the tensor field: the gradient mode and the Hessian mode. The first one is based on the gradient structure tensor, the second one on the Hessian matrix.

Gradient mode

With the gradient mode, the gradient tensor is extracted. This tensor, also referred to as structure tensor or second order moment matrix, is a matrix derived from the gradient of the image. This matrix summarizes the predominant directions of the gradient around the pixel of interest. $$ S_w(p) = \left( \begin{array}{cc} \int w(r) (I_x(p - r)) ^ 2\, d r & \int w(r) I_x(p - r)I_y(p - r)\, d r \\ \int w(r) I_x(p - r)I_y(p - r)\, d r & \int w(r) (I_y(p - r)) ^ 2\, d r \end{array} \right) $$
Where $w(r)$ is a gaussian kernel controlling the scale of analysis.

Hessian mode

With this mode, the tensor field is based on the extraction of the Hessian matrix of the image. This Hessian matrix is computed by filtering the image with the derivative of a Gaussian kernel. The standard deviation of the kernel controls the scale of analysis.

Feature extraction

The structureType parameter controls the type of structure that is extracted from the tensor field (rod or ball). Let $\lambda_1 \geq \lambda_2$ be the two eigenvalues of the extracted tensor.
The score for rod structure type favors anisotropic tensors and corresponds to:
$$ \text{ score }_{ \text{ ROD } } = \exp \left(-\frac{ \big(\frac{ \lambda_{ 2 } } {\lambda_{ 1 }} \big)^{ 2 } }{2 \beta^{ 2 } } \right) \left( 1 - ; exp \big(-\frac{ S^{ 2 } }{2c ^ {2}} \right) \\ $$ The score for ball structure type favors isotropic tensors and is computed as follows:
$$ \text{ score }_{ \text{ BALL } } = \left( 1 - \exp(-\frac{ \big(\frac{ \lambda_{ 2 } } {\lambda_{ 1 }} \big)^{ 2 } }{2 \beta^{ 2 } }) \right) \left(1 - \exp \big(-\frac{ S^{ 2 } } {2c ^ {2}} \big) \right) \\ $$ Where: With the Hessian mode, the lightness parameter limits the feature extraction to dark or bright objects by analyzing the sign of eigenvalues. This parameter is ignored in gradient mode where tensors are positive definite matrices.

The following table summarizes enhanced features according to the parameters. \begin{array}{|l|l|l|l|l|} \hline \textbf{Tensor Type} &\textbf{Structure Type} & \textbf{$\lambda_1$} & \textbf{$\lambda_2$} & \textbf{Highlighted features} \\ \hline \hline \text{HESSIAN} & \text{ROD} & \text{Strong} & \text{Weak} & \text{Ridges} \\ \hline \text{HESSIAN} & \text{BALL} & \text{Strong} & \text{Strong} & \text{Blobs}\\ \hline \text{GRADIENT} & \text{ROD} & \text{Strong} & \text{Weak} & \text{Object edges} \\ \hline \text{GRADIENT} & \text{BALL} & \text{Strong} & \text{Strong} & \text{Blobs/Object corners} \\ \hline \end{array} See also

Function Syntax

This function returns outputImage.
// Function prototype
std::shared_ptr< iolink::ImageView > structureEnhancementFilter2d( std::shared_ptr< iolink::ImageView > inputImage, StructureEnhancementFilter2d::TensorType tensorType, iolink::Vector2d standardDeviationRange, double standardDeviationStep, StructureEnhancementFilter2d::Lightness lightness, StructureEnhancementFilter2d::StructureType structureType, std::shared_ptr< iolink::ImageView > outputImage = NULL );
This function returns outputImage.
// Function prototype.
structure_enhancement_filter_2d( input_image,
                                 tensor_type = StructureEnhancementFilter2d.TensorType.HESSIAN,
                                 standard_deviation_range = [1, 3],
                                 standard_deviation_step = 1,
                                 lightness = StructureEnhancementFilter2d.Lightness.BRIGHT,
                                 structure_type = StructureEnhancementFilter2d.StructureType.ROD,
                                 output_image = None )
This function returns outputImage.
// Function prototype.
public static IOLink.ImageView
StructureEnhancementFilter2d( IOLink.ImageView inputImage,
                              StructureEnhancementFilter2d.TensorType tensorType = ImageDev.StructureEnhancementFilter2d.TensorType.HESSIAN,
                              double[] standardDeviationRange = null,
                              double standardDeviationStep = 1,
                              StructureEnhancementFilter2d.Lightness lightness = ImageDev.StructureEnhancementFilter2d.Lightness.BRIGHT,
                              StructureEnhancementFilter2d.StructureType structureType = ImageDev.StructureEnhancementFilter2d.StructureType.ROD,
                              IOLink.ImageView outputImage = null );

Class Syntax

Parameters

Parameter Name Description Type Supported Values Default Value
input
inputImage
The input image. The image type can be integer or floating point. Image Grayscale nullptr
input
tensorType
The type of tensor to compute: gradient tensor or Hessian matrix.
HESSIAN The Hessian matrix is extracted.
GRADIENT The gradient structure tensor is extracted.
Enumeration HESSIAN
input
standardDeviationRange
The standard deviation of the Gaussian kernel at minimum and maximum scale, in pixel units. Vector2d >=0.1 {1.f, 3.f}
input
standardDeviationStep
The standard deviation step. Structures will be detected from minimum to maximum standard deviation at a pitch of this value. Float64 >0 1
input
lightness
The lightness type of structures to enhance. This parameter is ignored when the gradient tensor type is selected.
BRIGHT The bright structures are extracted from a dark background.
DARK The dark structures are extracted from a bright background.
Enumeration BRIGHT
input
structureType
The shape of the structures to enhance.
ROD The tubular structures are enhanced.
BALL The blob-like structures are enhanced.
Enumeration ROD
output
outputImage
The output image reprensenting the matching score between 0 and 1. Its dimensions are forced to the same values as the input. Its data type is forced to floating point. Image nullptr
Parameter Name Description Type Supported Values Default Value
input
input_image
The input image. The image type can be integer or floating point. image Grayscale None
input
tensor_type
The type of tensor to compute: gradient tensor or Hessian matrix.
HESSIAN The Hessian matrix is extracted.
GRADIENT The gradient structure tensor is extracted.
enumeration HESSIAN
input
standard_deviation_range
The standard deviation of the Gaussian kernel at minimum and maximum scale, in pixel units. vector2d >=0.1 [1, 3]
input
standard_deviation_step
The standard deviation step. Structures will be detected from minimum to maximum standard deviation at a pitch of this value. float64 >0 1
input
lightness
The lightness type of structures to enhance. This parameter is ignored when the gradient tensor type is selected.
BRIGHT The bright structures are extracted from a dark background.
DARK The dark structures are extracted from a bright background.
enumeration BRIGHT
input
structure_type
The shape of the structures to enhance.
ROD The tubular structures are enhanced.
BALL The blob-like structures are enhanced.
enumeration ROD
output
output_image
The output image reprensenting the matching score between 0 and 1. Its dimensions are forced to the same values as the input. Its data type is forced to floating point. image None
Parameter Name Description Type Supported Values Default Value
input
inputImage
The input image. The image type can be integer or floating point. Image Grayscale null
input
tensorType
The type of tensor to compute: gradient tensor or Hessian matrix.
HESSIAN The Hessian matrix is extracted.
GRADIENT The gradient structure tensor is extracted.
Enumeration HESSIAN
input
standardDeviationRange
The standard deviation of the Gaussian kernel at minimum and maximum scale, in pixel units. Vector2d >=0.1 {1f, 3f}
input
standardDeviationStep
The standard deviation step. Structures will be detected from minimum to maximum standard deviation at a pitch of this value. Float64 >0 1
input
lightness
The lightness type of structures to enhance. This parameter is ignored when the gradient tensor type is selected.
BRIGHT The bright structures are extracted from a dark background.
DARK The dark structures are extracted from a bright background.
Enumeration BRIGHT
input
structureType
The shape of the structures to enhance.
ROD The tubular structures are enhanced.
BALL The blob-like structures are enhanced.
Enumeration ROD
output
outputImage
The output image reprensenting the matching score between 0 and 1. Its dimensions are forced to the same values as the input. Its data type is forced to floating point. Image null

Object Examples

std::shared_ptr< iolink::ImageView > polystyrene = ioformat::readImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "polystyrene.tif" );

StructureEnhancementFilter2d structureEnhancementFilter2dAlgo;
structureEnhancementFilter2dAlgo.setInputImage( polystyrene );
structureEnhancementFilter2dAlgo.setTensorType( StructureEnhancementFilter2d::TensorType::HESSIAN );
structureEnhancementFilter2dAlgo.setStandardDeviationRange( {1.0, 3.0} );
structureEnhancementFilter2dAlgo.setStandardDeviationStep( 1.0 );
structureEnhancementFilter2dAlgo.setLightness( StructureEnhancementFilter2d::Lightness::BRIGHT );
structureEnhancementFilter2dAlgo.setStructureType( StructureEnhancementFilter2d::StructureType::ROD );
structureEnhancementFilter2dAlgo.execute();

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

structure_enhancement_filter_2d_algo = imagedev.StructureEnhancementFilter2d()
structure_enhancement_filter_2d_algo.input_image = polystyrene
structure_enhancement_filter_2d_algo.tensor_type = imagedev.StructureEnhancementFilter2d.HESSIAN
structure_enhancement_filter_2d_algo.standard_deviation_range = [1.0, 3.0]
structure_enhancement_filter_2d_algo.standard_deviation_step = 1.0
structure_enhancement_filter_2d_algo.lightness = imagedev.StructureEnhancementFilter2d.BRIGHT
structure_enhancement_filter_2d_algo.structure_type = imagedev.StructureEnhancementFilter2d.ROD
structure_enhancement_filter_2d_algo.execute()

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

StructureEnhancementFilter2d structureEnhancementFilter2dAlgo = new StructureEnhancementFilter2d
{
    inputImage = polystyrene,
    tensorType = StructureEnhancementFilter2d.TensorType.HESSIAN,
    standardDeviationRange = new double[]{1.0, 3.0},
    standardDeviationStep = 1.0,
    lightness = StructureEnhancementFilter2d.Lightness.BRIGHT,
    structureType = StructureEnhancementFilter2d.StructureType.ROD
};
structureEnhancementFilter2dAlgo.Execute();

Console.WriteLine( "outputImage:" + structureEnhancementFilter2dAlgo.outputImage.ToString() );

Function Examples

std::shared_ptr< iolink::ImageView > polystyrene = ioformat::readImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "polystyrene.tif" );

auto result = structureEnhancementFilter2d( polystyrene, StructureEnhancementFilter2d::TensorType::HESSIAN, {1.0, 3.0}, 1.0, StructureEnhancementFilter2d::Lightness::BRIGHT, StructureEnhancementFilter2d::StructureType::ROD );

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

result = imagedev.structure_enhancement_filter_2d( polystyrene, imagedev.StructureEnhancementFilter2d.HESSIAN, [1.0, 3.0], 1.0, imagedev.StructureEnhancementFilter2d.BRIGHT, imagedev.StructureEnhancementFilter2d.ROD )

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

IOLink.ImageView result = Processing.StructureEnhancementFilter2d( polystyrene, StructureEnhancementFilter2d.TensorType.HESSIAN, new double[]{1.0, 3.0}, 1.0, StructureEnhancementFilter2d.Lightness.BRIGHT, StructureEnhancementFilter2d.StructureType.ROD );

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