Loading [MathJax]/jax/output/CommonHTML/jax.js
ImageDev

CudaBoxFilter2d

Smoothes an image with a box kernel. The calculations are performed on the GPU.

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)=1Kpi=pqj=qI(ni,mj) The K coefficient is a normalization factor: Note: If the result is normalized, the output image has same type as the input. Else, it is upgraded according to the Image type promotion rule.

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, CudaBoxFilter2d::TilingMode tilingMode, iolink::Vector2u32 tileSize, CudaContext::Ptr cudaContext, std::shared_ptr< iolink::ImageView > outputImage = nullptr );

Class Syntax

Parameters

Parameter Name Description Type Supported Values Default Value
input
inputImage
The input image. Image Binary, Grayscale or Multispectral nullptr
input
kernelSizeX
The horizontal kernel size. UInt32 >=1 3
input
kernelSizeY
The vertical kernel size. UInt32 >=1 3
input
tilingMode
The way to manage the GPU memory.
NONE The entire input image is transferred to the GPU memory. If the total input, intermediate and output data size exceed the GPU memory, the computation will fail.
USER_DEFINED The input image is processed by tiles of a predefined size.
Enumeration NONE
input
tileSize
The tile width and height in pixels. This parameter is used only in USER_DEFINED tiling mode. Vector2u32 >=1 {1024, 1024}
input
cudaContext
CUDA context information. CudaContext nullptr
output
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

Object Examples

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

CudaBoxFilter2d cudaBoxFilter2dAlgo;
cudaBoxFilter2dAlgo.setInputImage( polystyrene );
cudaBoxFilter2dAlgo.setKernelSizeX( 3 );
cudaBoxFilter2dAlgo.setKernelSizeY( 3 );
cudaBoxFilter2dAlgo.setTilingMode( CudaBoxFilter2d::TilingMode::NONE );
cudaBoxFilter2dAlgo.setTileSize( {264, 264} );
cudaBoxFilter2dAlgo.setCudaContext( nullptr );
cudaBoxFilter2dAlgo.setOutputImage( iolink::ImageViewFactory::allocate( iolink::VectorXu64( { 1, 1 } ), iolink::DataTypeId::UINT8 ) );
cudaBoxFilter2dAlgo.execute();

std::cout << "outputImage:" << cudaBoxFilter2dAlgo.outputImage()->toString();

Function Examples

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

auto result = cudaBoxFilter2d( polystyrene, 3, 3, CudaBoxFilter2d::TilingMode::NONE, {264, 264}, nullptr , iolink::ImageViewFactory::allocate( iolink::VectorXu64( { 1, 1 } ), iolink::DataTypeId::UINT8 ));

std::cout << "outputImage:" << result->toString();