CudaBoxFilter2d
Smoothes an image using a box kernel.
Access to parameter description
This command is experimental, his signature may be modified between now and his final version.
For an introduction to image filters: section Images Filtering.
This algorithm smoothes an image using the same box kernel as a lowpass filter. The filter's X and Y sizes are user-defined.
The algorithm calculates the local mean in a given size window. For a window of size $2p+1$ in X and $2q+1$ in Y: $$ O(n,m)=\frac{1}{K}\sum_{i=-p}^{p}\sum_{j=-q}^{q} I(n-i,m-j) $$ The $K$ coefficient is a normalization factor:
See also
Access to parameter description
This command is experimental, his signature may be modified between now and his final version.
For an introduction to image filters: section Images Filtering.
This algorithm smoothes an image using the same box kernel as a lowpass filter. The filter's X and Y sizes are user-defined.
The algorithm calculates the local mean in a given size window. For a window of size $2p+1$ in X and $2q+1$ in Y: $$ O(n,m)=\frac{1}{K}\sum_{i=-p}^{p}\sum_{j=-q}^{q} I(n-i,m-j) $$ The $K$ coefficient is a normalization factor:
- $K = 1$ if the result is not normalized;
- $K = (2p+1) (2q+1)$ otherwise.
See also
Function Syntax
This function returns outputImage.
// Function prototype
std::shared_ptr< iolink::ImageView > cudaBoxFilter2d( std::shared_ptr< iolink::ImageView > inputImage, uint32_t kernelSizeX, uint32_t kernelSizeY, CudaContext::Ptr cudaContext, std::shared_ptr< iolink::ImageView > outputImage = NULL );
This function returns outputImage.
// Function prototype. cuda_box_filter_2d( input_image, kernel_size_x = 3, kernel_size_y = 3, cuda_context = None, output_image = None )
This function returns outputImage.
// Function prototype. public static IOLink.ImageView CudaBoxFilter2d( IOLink.ImageView inputImage, UInt32 kernelSizeX = 3, UInt32 kernelSizeY = 3, Data.CudaContext cudaContext = null, IOLink.ImageView outputImage = null );
Class Syntax
Parameters
Parameter Name | Description | Type | Supported Values | Default Value | |
---|---|---|---|---|---|
inputImage |
The input image. | Image | Binary, Grayscale or Multispectral | nullptr | |
kernelSizeX |
The horizontal kernel size. | UInt32 | >=1 | 3 | |
kernelSizeY |
The vertical kernel size. | UInt32 | >=1 | 3 | |
cudaContext |
CUDA context information. | CudaContext | nullptr | ||
outputImage |
The output image. Its dimensions are forced to the same values as the input. Its type is the same as the input if the normalization is set to yes, else the type is upgraded. | Image | nullptr |
Parameter Name | Description | Type | Supported Values | Default Value | |
---|---|---|---|---|---|
input_image |
The input image. | image | Binary, Grayscale or Multispectral | None | |
kernel_size_x |
The horizontal kernel size. | uint32 | >=1 | 3 | |
kernel_size_y |
The vertical kernel size. | uint32 | >=1 | 3 | |
cuda_context |
CUDA context information. | cuda_context | None | ||
output_image |
The output image. Its dimensions are forced to the same values as the input. Its type is the same as the input if the normalization is set to yes, else the type is upgraded. | image | None |
Parameter Name | Description | Type | Supported Values | Default Value | |
---|---|---|---|---|---|
inputImage |
The input image. | Image | Binary, Grayscale or Multispectral | null | |
kernelSizeX |
The horizontal kernel size. | UInt32 | >=1 | 3 | |
kernelSizeY |
The vertical kernel size. | UInt32 | >=1 | 3 | |
cudaContext |
CUDA context information. | CudaContext | null | ||
outputImage |
The output image. Its dimensions are forced to the same values as the input. Its type is the same as the input if the normalization is set to yes, else the type is upgraded. | Image | null |
Object Examples
std::shared_ptr< iolink::ImageView > polystyrene = ioformat::readImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "polystyrene.tif" ); CudaBoxFilter2d cudaBoxFilter2dAlgo; cudaBoxFilter2dAlgo.setInputImage( polystyrene ); cudaBoxFilter2dAlgo.setKernelSizeX( 3 ); cudaBoxFilter2dAlgo.setKernelSizeY( 3 ); cudaBoxFilter2dAlgo.setCudaContext( nullptr ); cudaBoxFilter2dAlgo.execute(); std::cout << "outputImage:" << cudaBoxFilter2dAlgo.outputImage()->toString();
polystyrene = ioformat.read_image(imagedev_data.get_image_path("polystyrene.tif")) cuda_box_filter_2d_algo = imagedev.CudaBoxFilter2d() cuda_box_filter_2d_algo.input_image = polystyrene cuda_box_filter_2d_algo.kernel_size_x = 3 cuda_box_filter_2d_algo.kernel_size_y = 3 cuda_box_filter_2d_algo.cuda_context = None cuda_box_filter_2d_algo.execute() print( "output_image:", str( cuda_box_filter_2d_algo.output_image ) )
ImageView polystyrene = ViewIO.ReadImage( @"Data/images/polystyrene.tif" ); CudaBoxFilter2d cudaBoxFilter2dAlgo = new CudaBoxFilter2d { inputImage = polystyrene, kernelSizeX = 3, kernelSizeY = 3, cudaContext = null }; cudaBoxFilter2dAlgo.Execute(); Console.WriteLine( "outputImage:" + cudaBoxFilter2dAlgo.outputImage.ToString() );
Function Examples
std::shared_ptr< iolink::ImageView > polystyrene = ioformat::readImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "polystyrene.tif" ); auto result = cudaBoxFilter2d( polystyrene, 3, 3, nullptr ); std::cout << "outputImage:" << result->toString();
polystyrene = ioformat.read_image(imagedev_data.get_image_path("polystyrene.tif")) result = imagedev.cuda_box_filter_2d( polystyrene, 3, 3, None ) print( "output_image:", str( result ) )
ImageView polystyrene = ViewIO.ReadImage( @"Data/images/polystyrene.tif" ); IOLink.ImageView result = Processing.CudaBoxFilter2d( polystyrene, 3, 3, null ); Console.WriteLine( "outputImage:" + result.ToString() );