ConvolutionWithImage2d
Performs a two-dimensional convolution between an image and another image used as a convolution kernel.
Access to parameter description
This filter produces a convolution between an image $I$ and another image $k$. This image $k$ is converted into a 1D-array and convolution by this general kernel is performed. This algorithm only supports kernel images with odd X and Y dimensions.
If image $k$ has a size $(2p+1)\times(2q+1)$, it is in fact a 2D-array with $(2p+1)$ columns and $(2q+1)$ lines. It is converted in a 1D-array of $(2p+1)\times(2q+1)$ elements by placing side by side the $(2q+1)$ lines of the $k$ array. $$ O(n,m)=\frac{1}{K}\sum_{i=-p}^{p}\sum_{j=-q}^{q}k(i,j)\times I(n-i,m-j) $$ Where $K$ is the normalization or automatic scaling coefficient. If normalization is disabled $K=1$, else it is given by: $$K=\sum_{i=-p}^{p}\sum_{j=-q}^{q}|k(i,j)|$$
Note: Since the original data range may not be preserved by this filter, the output image type is upgraded according to the Image type basic rule.
See also
Access to parameter description
This filter produces a convolution between an image $I$ and another image $k$. This image $k$ is converted into a 1D-array and convolution by this general kernel is performed. This algorithm only supports kernel images with odd X and Y dimensions.
If image $k$ has a size $(2p+1)\times(2q+1)$, it is in fact a 2D-array with $(2p+1)$ columns and $(2q+1)$ lines. It is converted in a 1D-array of $(2p+1)\times(2q+1)$ elements by placing side by side the $(2q+1)$ lines of the $k$ array. $$ O(n,m)=\frac{1}{K}\sum_{i=-p}^{p}\sum_{j=-q}^{q}k(i,j)\times I(n-i,m-j) $$ Where $K$ is the normalization or automatic scaling coefficient. If normalization is disabled $K=1$, else it is given by: $$K=\sum_{i=-p}^{p}\sum_{j=-q}^{q}|k(i,j)|$$
Note: Since the original data range may not be preserved by this filter, the output image type is upgraded according to the Image type basic rule.
See also
Function Syntax
This function returns the outputImage output parameter.
// Function prototype. std::shared_ptr< iolink::ImageView > convolutionWithImage2d( std::shared_ptr< iolink::ImageView > inputImage, std::shared_ptr< iolink::ImageView > inputKernelImage, ConvolutionWithImage2d::AutoScale autoScale, std::shared_ptr< iolink::ImageView > outputImage = NULL );
This function returns the outputImage output parameter.
// Function prototype. convolution_with_image_2d( input_image, input_kernel_image, auto_scale = ConvolutionWithImage2d.AutoScale.YES, output_image = None )
This function returns the outputImage output parameter.
// Function prototype. public static IOLink.ImageView ConvolutionWithImage2d( IOLink.ImageView inputImage, IOLink.ImageView inputKernelImage, ConvolutionWithImage2d.AutoScale autoScale = ImageDev.ConvolutionWithImage2d.AutoScale.YES, IOLink.ImageView outputImage = null );
Class Syntax
Parameters
Class Name | ConvolutionWithImage2d |
---|
Parameter Name | Description | Type | Supported Values | Default Value | |||||
---|---|---|---|---|---|---|---|---|---|
inputImage |
The input image. | Image | Binary, Label, Grayscale or Multispectral | nullptr | |||||
inputKernelImage |
The convolution kernel image. It must have odd X and Y dimensions. | Image | Binary, Label, Grayscale or Multispectral | nullptr | |||||
autoScale |
The automatic intensity scaling mode.
|
Enumeration | YES | ||||||
outputImage |
The output image. Its dimensions are forced to the same values as the input. Its data type is promoted. | Image | nullptr |
Object Examples
std::shared_ptr< iolink::ImageView > polystyrene = ioformat::readImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "polystyrene.tif" ); auto kernel_2d = readVipImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "kernel_2d.vip" ); ConvolutionWithImage2d convolutionWithImage2dAlgo; convolutionWithImage2dAlgo.setInputImage( polystyrene ); convolutionWithImage2dAlgo.setInputKernelImage( kernel_2d ); convolutionWithImage2dAlgo.setAutoScale( ConvolutionWithImage2d::AutoScale::YES ); convolutionWithImage2dAlgo.execute(); std::cout << "outputImage:" << convolutionWithImage2dAlgo.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_2d_algo = imagedev.ConvolutionWithImage2d() convolution_with_image_2d_algo.input_image = polystyrene convolution_with_image_2d_algo.input_kernel_image = kernel__2d convolution_with_image_2d_algo.auto_scale = imagedev.ConvolutionWithImage2d.YES convolution_with_image_2d_algo.execute() print( "output_image:", str( convolution_with_image_2d_algo.output_image ) )
ImageView polystyrene = ViewIO.ReadImage( @"Data/images/polystyrene.tif" ); ImageView kernel_2d = Data.ReadVipImage( @"Data/images/kernel_2d.vip" ); ConvolutionWithImage2d convolutionWithImage2dAlgo = new ConvolutionWithImage2d { inputImage = polystyrene, inputKernelImage = kernel_2d, autoScale = ConvolutionWithImage2d.AutoScale.YES }; convolutionWithImage2dAlgo.Execute(); Console.WriteLine( "outputImage:" + convolutionWithImage2dAlgo.outputImage.ToString() );
Function Examples
std::shared_ptr< iolink::ImageView > polystyrene = ioformat::readImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "polystyrene.tif" ); auto kernel_2d = readVipImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "kernel_2d.vip" ); auto result = convolutionWithImage2d( polystyrene, kernel_2d, ConvolutionWithImage2d::AutoScale::YES ); 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_2d( polystyrene, kernel__2d, imagedev.ConvolutionWithImage2d.YES ) 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.ConvolutionWithImage2d( polystyrene, kernel_2d, ConvolutionWithImage2d.AutoScale.YES ); Console.WriteLine( "outputImage:" + result.ToString() );