ImageDev

MeanFilter2d

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

Access to parameter description

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

Function Syntax

This function returns outputImage.
// Function prototype
std::shared_ptr< iolink::ImageView > meanFilter2d( std::shared_ptr< iolink::ImageView > inputImage, MeanFilter2d::KernelShape kernelShape, uint32_t kernelRadius, std::shared_ptr< iolink::ImageView > outputImage = nullptr );
This function returns outputImage.
// Function prototype.
mean_filter_2d(input_image: idt.ImageType,
               kernel_shape: MeanFilter2d.KernelShape = MeanFilter2d.KernelShape.DISK,
               kernel_radius: int = 3,
               output_image: idt.ImageType = None) -> idt.ImageType
This function returns outputImage.
// Function prototype.
public static IOLink.ImageView
MeanFilter2d( IOLink.ImageView inputImage,
              MeanFilter2d.KernelShape kernelShape = ImageDev.MeanFilter2d.KernelShape.DISK,
              UInt32 kernelRadius = 3,
              IOLink.ImageView outputImage = null );

Class Syntax

Parameters

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
Parameter Name Description Type Supported Values Default Value
input
input_image
The input image. image Binary, Label, Grayscale or Multispectral None
input
kernel_radius
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
kernel_shape
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
output_image
The output image. 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. Image Binary, Label, Grayscale or Multispectral null
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 null

Object Examples

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

MeanFilter2d meanFilter2dAlgo;
meanFilter2dAlgo.setInputImage( polystyrene );
meanFilter2dAlgo.setKernelShape( MeanFilter2d::KernelShape::SQUARE );
meanFilter2dAlgo.setKernelRadius( 3 );
meanFilter2dAlgo.execute();

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

mean_filter_2d_algo = imagedev.MeanFilter2d()
mean_filter_2d_algo.input_image = polystyrene
mean_filter_2d_algo.kernel_shape = imagedev.MeanFilter2d.SQUARE
mean_filter_2d_algo.kernel_radius = 3
mean_filter_2d_algo.execute()

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

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

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

Function Examples

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

auto result = meanFilter2d( polystyrene, MeanFilter2d::KernelShape::SQUARE, 3 );

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

result = imagedev.mean_filter_2d(polystyrene, imagedev.MeanFilter2d.SQUARE, 3)

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

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

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