ImageDev

Despeckle3d

Smoothes a three-dimensional image by replacing any aberrant voxel values by their neighbors mean value.

Access to parameter description

For an introduction to image filters: see Images Filtering.

For each voxel of the input image, mean $\mu$ and standard deviation $\sigma$ values of a rectangular neighbor window are computed.
The output image value is then given by: $$ O(i,j,k)=\left\{\begin{array}{ll} \mu(i,j,k) & ~ \mbox{if} ~ \lambda \times |I(i,j,k)-\mu(i,j,k)| > \sigma(i,j,k)\\ I(i,j,k) & ~ \mbox{otherwise} \end{array}\right. $$
Where $\lambda$ is a user-defined threshold factor on the distance of the current voxel gray level to the mean of its neighbors, relative to their standard deviation.
The greater $\lambda$ is, the stronger the blur.

This filter gives good results in the case of impulse noise.

See also

Function Syntax

This function returns outputImage.
// Function prototype
std::shared_ptr< iolink::ImageView > despeckle3d( std::shared_ptr< iolink::ImageView > inputImage, int32_t kernelSizeX, int32_t kernelSizeY, int32_t kernelSizeZ, double thresholdFactor, std::shared_ptr< iolink::ImageView > outputImage = NULL );
This function returns outputImage.
// Function prototype.
despeckle_3d( input_image,
              kernel_size_x = 3,
              kernel_size_y = 3,
              kernel_size_z = 3,
              threshold_factor = 1,
              output_image = None )
This function returns outputImage.
// Function prototype.
public static IOLink.ImageView
Despeckle3d( IOLink.ImageView inputImage,
             Int32 kernelSizeX = 3,
             Int32 kernelSizeY = 3,
             Int32 kernelSizeZ = 3,
             double thresholdFactor = 1,
             IOLink.ImageView outputImage = null );

Class Syntax

Parameters

Class Name Despeckle3d

Parameter Name Description Type Supported Values Default Value
input
inputImage
The input image. Image Binary, Label, Grayscale or Multispectral nullptr
input
kernelSizeX
The horizontal kernel size in voxels (odd value). Int32 [3, 100] 3
input
kernelSizeY
The vertical kernel size in voxels (odd value). Int32 [3, 100] 3
input
kernelSizeZ
The depth kernel size in voxels (odd value). Int32 [3, 100] 3
input
thresholdFactor
The standard deviation threshold factor (must be a positive value). Float64 >0 1
output
outputImage
The output image. Its dimensions, type, and calibration are forced to the same values as the input. Image nullptr

Object Examples

auto foam = readVipImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "foam.vip" );

Despeckle3d despeckle3dAlgo;
despeckle3dAlgo.setInputImage( foam );
despeckle3dAlgo.setKernelSizeX( 3 );
despeckle3dAlgo.setKernelSizeY( 3 );
despeckle3dAlgo.setKernelSizeZ( 3 );
despeckle3dAlgo.setThresholdFactor( 1.0 );
despeckle3dAlgo.execute();

std::cout << "outputImage:" << despeckle3dAlgo.outputImage()->toString();
foam = imagedev.read_vip_image(imagedev_data.get_image_path("foam.vip"))

despeckle_3d_algo = imagedev.Despeckle3d()
despeckle_3d_algo.input_image = foam
despeckle_3d_algo.kernel_size_x = 3
despeckle_3d_algo.kernel_size_y = 3
despeckle_3d_algo.kernel_size_z = 3
despeckle_3d_algo.threshold_factor = 1.0
despeckle_3d_algo.execute()

print( "output_image:", str( despeckle_3d_algo.output_image ) )
ImageView foam = Data.ReadVipImage( @"Data/images/foam.vip" );

Despeckle3d despeckle3dAlgo = new Despeckle3d
{
    inputImage = foam,
    kernelSizeX = 3,
    kernelSizeY = 3,
    kernelSizeZ = 3,
    thresholdFactor = 1.0
};
despeckle3dAlgo.Execute();

Console.WriteLine( "outputImage:" + despeckle3dAlgo.outputImage.ToString() );

Function Examples

auto foam = readVipImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "foam.vip" );

auto result = despeckle3d( foam, 3, 3, 3, 1.0 );

std::cout << "outputImage:" << result->toString();
foam = imagedev.read_vip_image(imagedev_data.get_image_path("foam.vip"))

result = imagedev.despeckle_3d( foam, 3, 3, 3, 1.0 )

print( "output_image:", str( result ) )
ImageView foam = Data.ReadVipImage( @"Data/images/foam.vip" );

IOLink.ImageView result = Processing.Despeckle3d( foam, 3, 3, 3, 1.0 );

Console.WriteLine( "outputImage:" + result.ToString() );