ConvolutionWithImage
Performs a two or three-dimensional convolution between an input image $I$ and another image $K$ used as a convolution kernel.
Access to parameter description
This filter produces a convolution between an image $I$ and another image $k$.
In 2d case, output image values $O$ associated to convolution of input image $I$ by a $p \times q$ kernel image $K$, are given by : $$ O(x,y)=\frac{1}{N_K}\sum_{i=0}^{p}\sum_{j=0}^{q}K(i,j)\times I(x+\frac{p}{2}-i,y+\frac{q}{2}-j) $$
The $N_K$ coefficient is a normalization factor:
In 3d case, output image values $O$ associated to convolution of input image $I$ by a $p \times q \times r$ kernel image $K$, are given by : $$ O(x,y,z)=\frac{1}{N_K}\sum_{i=0}^{p}\sum_{j=0}^{q}\sum_{k=0}^{r}K(i,j,k)\times I(x+\frac{p}{2}-i,y+\frac{q}{2}-j,z+\frac{r}{2}-k) $$
The $N_K$ coefficient is a normalization factor:
Note: in case where input image contains several spectral series, input kernel image may :
See also
Access to parameter description
This filter produces a convolution between an image $I$ and another image $k$.
In 2d case, output image values $O$ associated to convolution of input image $I$ by a $p \times q$ kernel image $K$, are given by : $$ O(x,y)=\frac{1}{N_K}\sum_{i=0}^{p}\sum_{j=0}^{q}K(i,j)\times I(x+\frac{p}{2}-i,y+\frac{q}{2}-j) $$
The $N_K$ coefficient is a normalization factor:
- $N_K = 1$ if the result is not normalized (automatic intensity scaling is set to NO);
- $N_K = \sum_{i=0}^{p}\sum_{j=0}^{q}|K(i,j)|$ otherwise (automatic intensity scaling is set to YES).
In 3d case, output image values $O$ associated to convolution of input image $I$ by a $p \times q \times r$ kernel image $K$, are given by : $$ O(x,y,z)=\frac{1}{N_K}\sum_{i=0}^{p}\sum_{j=0}^{q}\sum_{k=0}^{r}K(i,j,k)\times I(x+\frac{p}{2}-i,y+\frac{q}{2}-j,z+\frac{r}{2}-k) $$
The $N_K$ coefficient is a normalization factor:
- $N_K = 1$ if the result is not normalized (automatic intensity scaling is set to NO);
- $N_K = \sum_{i=0}^{p}\sum_{j=0}^{q}\sum_{k=0}^{r}|K(i,j,k)|$ otherwise (automatic intensity scaling is set to YES).
Note: in case where input image contains several spectral series, input kernel image may :
- contains a single component along spectral series axis. In this case, input kernel image will be used for computation irrespective of the spectral serie of input image.
- contains as many components as input image along spectral series axis. In this case, components will be proceeded accordingly.
See also
Function Syntax
This function returns outputImage.
// Function prototype
std::shared_ptr< iolink::ImageView > convolutionWithImage( std::shared_ptr< iolink::ImageView > inputImage, std::shared_ptr< iolink::ImageView > inputKernelImage, ConvolutionWithImage::AutoScale autoScale, ConvolutionWithImage::FilterMode filterMode, std::shared_ptr< iolink::ImageView > outputImage = nullptr );
This function returns outputImage.
// Function prototype. convolution_with_image(input_image: idt.ImageType, input_kernel_image: idt.ImageType, auto_scale: ConvolutionWithImage.AutoScale = ConvolutionWithImage.AutoScale.YES, filter_mode: ConvolutionWithImage.FilterMode = ConvolutionWithImage.FilterMode.FREQUENCY, output_image: idt.ImageType = None) -> idt.ImageType
This function returns outputImage.
// Function prototype. public static IOLink.ImageView ConvolutionWithImage( IOLink.ImageView inputImage, IOLink.ImageView inputKernelImage, ConvolutionWithImage.AutoScale autoScale = ImageDev.ConvolutionWithImage.AutoScale.YES, ConvolutionWithImage.FilterMode filterMode = ImageDev.ConvolutionWithImage.FilterMode.FREQUENCY, IOLink.ImageView outputImage = null );
Class Syntax
Parameters
Parameter Name | Description | Type | Supported Values | Default Value | |||||
---|---|---|---|---|---|---|---|---|---|
![]() |
inputImage |
The input image. | Image | Grayscale or Multispectral | nullptr | ||||
![]() |
inputKernelImage |
The convolution kernel image. In case of a multispectral input image it must have either 1 channels, or the same number of channel. | Image | Binary, Grayscale or Multispectral | nullptr | ||||
![]() |
autoScale |
The automatic intensity scaling mode.
|
Enumeration | YES | |||||
![]() |
filterMode |
The algorithm implementation used to perform the convolution.
|
Enumeration | FREQUENCY | |||||
![]() |
outputImage |
The output image. Its dimensions are forced to the same values as the input. Its data type is float 64-bits in case of a 64-bits input, float 32-bits in other cases. | Image | nullptr |
Parameter Name | Description | Type | Supported Values | Default Value | |||||
---|---|---|---|---|---|---|---|---|---|
![]() |
input_image |
The input image. | image | Grayscale or Multispectral | None | ||||
![]() |
input_kernel_image |
The convolution kernel image. In case of a multispectral input image it must have either 1 channels, or the same number of channel. | image | Binary, Grayscale or Multispectral | None | ||||
![]() |
auto_scale |
The automatic intensity scaling mode.
|
enumeration | YES | |||||
![]() |
filter_mode |
The algorithm implementation used to perform the convolution.
|
enumeration | FREQUENCY | |||||
![]() |
output_image |
The output image. Its dimensions are forced to the same values as the input. Its data type is float 64-bits in case of a 64-bits input, float 32-bits in other cases. | image | None |
Parameter Name | Description | Type | Supported Values | Default Value | |||||
---|---|---|---|---|---|---|---|---|---|
![]() |
inputImage |
The input image. | Image | Grayscale or Multispectral | null | ||||
![]() |
inputKernelImage |
The convolution kernel image. In case of a multispectral input image it must have either 1 channels, or the same number of channel. | Image | Binary, Grayscale or Multispectral | null | ||||
![]() |
autoScale |
The automatic intensity scaling mode.
|
Enumeration | YES | |||||
![]() |
filterMode |
The algorithm implementation used to perform the convolution.
|
Enumeration | FREQUENCY | |||||
![]() |
outputImage |
The output image. Its dimensions are forced to the same values as the input. Its data type is float 64-bits in case of a 64-bits input, float 32-bits in other cases. | Image | null |
Object Examples
auto polystyrene = ioformat::readImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "polystyrene.tif" ); auto kernel_2d = readVipImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "kernel_2d.vip" ); ConvolutionWithImage convolutionWithImageAlgo; convolutionWithImageAlgo.setInputImage( polystyrene ); convolutionWithImageAlgo.setInputKernelImage( kernel_2d ); convolutionWithImageAlgo.setAutoScale( ConvolutionWithImage::AutoScale::YES ); convolutionWithImageAlgo.setFilterMode( ConvolutionWithImage::FilterMode::FREQUENCY ); convolutionWithImageAlgo.execute(); std::cout << "outputImage:" << convolutionWithImageAlgo.outputImage()->toString();
polystyrene = ioformat.read_image(imagedev_data.get_image_path("polystyrene.tif")) kernel_2d = imagedev.read_vip_image(imagedev_data.get_image_path("kernel_2d.vip")) convolution_with_image_algo = imagedev.ConvolutionWithImage() convolution_with_image_algo.input_image = polystyrene convolution_with_image_algo.input_kernel_image = kernel_2d convolution_with_image_algo.auto_scale = imagedev.ConvolutionWithImage.YES convolution_with_image_algo.filter_mode = imagedev.ConvolutionWithImage.FREQUENCY convolution_with_image_algo.execute() print("output_image:", str(convolution_with_image_algo.output_image))
ImageView polystyrene = ViewIO.ReadImage( @"Data/images/polystyrene.tif" ); ImageView kernel_2d = Data.ReadVipImage( @"Data/images/kernel_2d.vip" ); ConvolutionWithImage convolutionWithImageAlgo = new ConvolutionWithImage { inputImage = polystyrene, inputKernelImage = kernel_2d, autoScale = ConvolutionWithImage.AutoScale.YES, filterMode = ConvolutionWithImage.FilterMode.FREQUENCY }; convolutionWithImageAlgo.Execute(); Console.WriteLine( "outputImage:" + convolutionWithImageAlgo.outputImage.ToString() );
Function Examples
auto polystyrene = ioformat::readImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "polystyrene.tif" ); auto kernel_2d = readVipImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "kernel_2d.vip" ); auto result = convolutionWithImage( polystyrene, kernel_2d, ConvolutionWithImage::AutoScale::YES, ConvolutionWithImage::FilterMode::FREQUENCY ); std::cout << "outputImage:" << result->toString();
polystyrene = ioformat.read_image(imagedev_data.get_image_path("polystyrene.tif")) kernel_2d = imagedev.read_vip_image(imagedev_data.get_image_path("kernel_2d.vip")) result = imagedev.convolution_with_image(polystyrene, kernel_2d, imagedev.ConvolutionWithImage.YES, imagedev.ConvolutionWithImage.FREQUENCY) print("output_image:", str(result))
ImageView polystyrene = ViewIO.ReadImage( @"Data/images/polystyrene.tif" ); ImageView kernel_2d = Data.ReadVipImage( @"Data/images/kernel_2d.vip" ); IOLink.ImageView result = Processing.ConvolutionWithImage( polystyrene, kernel_2d, ConvolutionWithImage.AutoScale.YES, ConvolutionWithImage.FilterMode.FREQUENCY ); Console.WriteLine( "outputImage:" + result.ToString() );
© 2025 Thermo Fisher Scientific Inc. All rights reserved.