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)=1Kp∑i=−pq∑j=−qI(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.
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.
// Command constructor.CudaBoxFilter2d();/// Gets the inputImage parameter./// The input image.
std::shared_ptr< iolink::ImageView> inputImage()const;/// Sets the inputImage parameter./// The input image.void setInputImage( std::shared_ptr< iolink::ImageView> inputImage );/// Gets the kernelSizeX parameter./// The horizontal kernel size.uint32_t kernelSizeX()const;/// Sets the kernelSizeX parameter./// The horizontal kernel size.void setKernelSizeX(constuint32_t& kernelSizeX );/// Gets the kernelSizeY parameter./// The vertical kernel size.uint32_t kernelSizeY()const;/// Sets the kernelSizeY parameter./// The vertical kernel size.void setKernelSizeY(constuint32_t& kernelSizeY );/// Gets the cudaContext parameter./// CUDA context information.CudaContext::Ptr cudaContext()const;/// Sets the cudaContext parameter./// CUDA context information.void setCudaContext(constCudaContext::Ptr& cudaContext );/// Gets the outputImage parameter./// 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.
std::shared_ptr< iolink::ImageView> outputImage()const;/// Sets the outputImage parameter./// 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.void setOutputImage( std::shared_ptr< iolink::ImageView> outputImage );// Method to launch the command.void execute();
# Property of the inputImage parameter.CudaBoxFilter2d.input_image
# Property of the kernelSizeX parameter.CudaBoxFilter2d.kernel_size_x
# Property of the kernelSizeY parameter.CudaBoxFilter2d.kernel_size_y
# Property of the cudaContext parameter.CudaBoxFilter2d.cuda_context
# Property of the outputImage parameter.CudaBoxFilter2d.output_image
// Method to launch the command.
execute()
// Command constructor.CudaBoxFilter2d()// Property of the inputImage parameter.CudaBoxFilter2d.inputImage
// Property of the kernelSizeX parameter.CudaBoxFilter2d.kernelSizeX
// Property of the kernelSizeY parameter.CudaBoxFilter2d.kernelSizeY
// Property of the cudaContext parameter.CudaBoxFilter2d.cudaContext
// Property of the outputImage parameter.CudaBoxFilter2d.outputImage
// Method to launch the command.Execute()
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.
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());