ImageDev

EntropyFilter2d

Computes, for each pixel of a two-dimensional image, the entropy value of its neighborhood.

Access to parameter description

For an introduction: This algorithm replaces each pixel of the output image by the entropy value of its neighborhood in the input image. The entropy operator is given by: $$ entropy=-\sum_{n}p(n)\cdot\log p(n) $$ The shape of the neighborhood can be: See also

Function Syntax

This function returns the outputImage output parameter.
// Function prototype.
std::shared_ptr< iolink::ImageView >
entropyFilter2d( std::shared_ptr< iolink::ImageView > inputImage,
                 EntropyFilter2d::KernelShape kernelShape,
                 uint32_t kernelRadius,
                 std::shared_ptr< iolink::ImageView > outputImage = NULL );
This function returns the outputImage output parameter.
// Function prototype.
entropy_filter_2d( input_image,
                   kernel_shape = EntropyFilter2d.KernelShape.DISK,
                   kernel_radius = 3,
                   output_image = None )
This function returns the outputImage output parameter.
// Function prototype.
public static IOLink.ImageView
EntropyFilter2d( IOLink.ImageView inputImage,
                 EntropyFilter2d.KernelShape kernelShape = ImageDev.EntropyFilter2d.KernelShape.DISK,
                 UInt32 kernelRadius = 3,
                 IOLink.ImageView outputImage = null );

Class Syntax

Parameters

Class Name EntropyFilter2d

Parameter Name Description Type Supported Values Default Value
input
inputImage
The input image. Image Binary, Label, Grayscale or Multispectral nullptr
input
kernelRadius
The kernel half side length or radius, in pixels. In case of a square, a value N produces a square window of 2N+1 pixels side length. In case of a disk, a value N produces a disk with a 2N+1 pixels diameter. UInt32 >=1 3
input
kernelShape
The shape of the window defining the neighborhood.
SQUARE The sliding window is a square.
DISK The sliding window is a disk.
Enumeration DISK
output
outputImage
The output image. Its dimensions are forced to the same values as the input. Its data type is forced to floating point. Image nullptr

Object Examples

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

EntropyFilter2d entropyFilter2dAlgo;
entropyFilter2dAlgo.setInputImage( polystyrene );
entropyFilter2dAlgo.setKernelShape( EntropyFilter2d::KernelShape::SQUARE );
entropyFilter2dAlgo.setKernelRadius( 3 );
entropyFilter2dAlgo.execute();

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

entropy_filter_2d_algo = imagedev.EntropyFilter2d()
entropy_filter_2d_algo.input_image = polystyrene
entropy_filter_2d_algo.kernel_shape = imagedev.EntropyFilter2d.SQUARE
entropy_filter_2d_algo.kernel_radius = 3
entropy_filter_2d_algo.execute()

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

EntropyFilter2d entropyFilter2dAlgo = new EntropyFilter2d
{
    inputImage = polystyrene,
    kernelShape = EntropyFilter2d.KernelShape.SQUARE,
    kernelRadius = 3
};
entropyFilter2dAlgo.Execute();

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

Function Examples

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

auto result = entropyFilter2d( polystyrene, EntropyFilter2d::KernelShape::SQUARE, 3 );

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

result = imagedev.entropy_filter_2d( polystyrene, imagedev.EntropyFilter2d.SQUARE, 3 )

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

IOLink.ImageView result = Processing.EntropyFilter2d( polystyrene, EntropyFilter2d.KernelShape.SQUARE, 3 );

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