SnnFilter2d
            Performs an edge-preserving smoothing of a two-dimensional image with the Symmetric Nearest Neighbor filter.
Access to parameter description
For an introduction to image filters: see Images Filtering.
        
This algorithm implements the Symmetric Nearest Neighbor filter (SNN), which is an average filter weighted by the structural symmetry of a rectangular neighborhood window. It computes a local mean around a central pixel $x$, considering for each neighbor pixel $y$, having a gray level $I(y)$, the value given by:
$$ I'(y)=\left\{\begin{array}{ll} I(y) & ~\mbox{if $|I(x)-I(y)| < |I(x)-I(y_s)|$} \\ I(y_s) & ~\mbox{if $|I(x)-I(y)| > |I(x)-I(y_s)|$} \\ I(x) & ~\mbox{otherwise} \end{array}\right. $$ Where $y_s$ is the neighbor pixel symmetric to $y$ with respect to $x$.
 
The output value of the pixel $x$ is then given by: $$ O(x)=\mu[I'(y)] $$ Where $\mu$ is the mean value of the local window.
        
See also
		Access to parameter description
For an introduction to image filters: see Images Filtering.
This algorithm implements the Symmetric Nearest Neighbor filter (SNN), which is an average filter weighted by the structural symmetry of a rectangular neighborhood window. It computes a local mean around a central pixel $x$, considering for each neighbor pixel $y$, having a gray level $I(y)$, the value given by:
$$ I'(y)=\left\{\begin{array}{ll} I(y) & ~\mbox{if $|I(x)-I(y)| < |I(x)-I(y_s)|$} \\ I(y_s) & ~\mbox{if $|I(x)-I(y)| > |I(x)-I(y_s)|$} \\ I(x) & ~\mbox{otherwise} \end{array}\right. $$ Where $y_s$ is the neighbor pixel symmetric to $y$ with respect to $x$.
The output value of the pixel $x$ is then given by: $$ O(x)=\mu[I'(y)] $$ Where $\mu$ is the mean value of the local window.
See also
Function Syntax
This function returns the outputImage output parameter.
                        
                    
// Function prototype.
std::shared_ptr< iolink::ImageView >
snnFilter2d( std::shared_ptr< iolink::ImageView > inputImage,
             int32_t kernelSizeX,
             int32_t kernelSizeY,
             std::shared_ptr< iolink::ImageView > outputImage = NULL );
                    
This function returns the outputImage output parameter.
                        
                    
// Function prototype.
snn_filter_2d( input_image,
               kernel_size_x = 3,
               kernel_size_y = 3,
               output_image = None )
                    
This function returns the outputImage output parameter.
                        
                
// Function prototype.
public static IOLink.ImageView
SnnFilter2d( IOLink.ImageView inputImage,
             Int32 kernelSizeX = 3,
             Int32 kernelSizeY = 3,
             IOLink.ImageView outputImage = null );
                    Class Syntax
Parameters
| Class Name | SnnFilter2d | 
|---|
| Parameter Name | Description | Type | Supported Values | Default Value | |
|---|---|---|---|---|---|
![]()  | 
  inputImage    | 
 The input image. | Image | Binary, Label, Grayscale or Multispectral | nullptr | 
![]()  | 
  kernelSizeX    | 
 The horizontal kernel size in pixels (odd value). | Int32 | [3, 100] | 3 | 
![]()  | 
  kernelSizeY    | 
 The vertical kernel size in pixels (odd value). | Int32 | [3, 100] | 3 | 
![]()  | 
  outputImage    | 
 The output image. Its dimensions, type and calibration are forced to the same values as the input. | Image | nullptr | |
Object Examples
std::shared_ptr< iolink::ImageView > polystyrene = ioformat::readImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "polystyrene.tif" ); SnnFilter2d snnFilter2dAlgo; snnFilter2dAlgo.setInputImage( polystyrene ); snnFilter2dAlgo.setKernelSizeX( 3 ); snnFilter2dAlgo.setKernelSizeY( 3 ); snnFilter2dAlgo.execute(); std::cout << "outputImage:" << snnFilter2dAlgo.outputImage()->toString();
polystyrene = ioformat.read_image(imagedev_data.get_image_path("polystyrene.tif"))
snn_filter_2d_algo = imagedev.SnnFilter2d()
snn_filter_2d_algo.input_image = polystyrene
snn_filter_2d_algo.kernel_size_x = 3
snn_filter_2d_algo.kernel_size_y = 3
snn_filter_2d_algo.execute()
print( "output_image:", str( snn_filter_2d_algo.output_image ) );
            
ImageView polystyrene = ViewIO.ReadImage( @"Data/images/polystyrene.tif" );
SnnFilter2d snnFilter2dAlgo = new SnnFilter2d
{
    inputImage = polystyrene,
    kernelSizeX = 3,
    kernelSizeY = 3
};
snnFilter2dAlgo.Execute();
Console.WriteLine( "outputImage:" + snnFilter2dAlgo.outputImage.ToString() );
            Function Examples
std::shared_ptr< iolink::ImageView > polystyrene = ioformat::readImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "polystyrene.tif" ); auto result = snnFilter2d( polystyrene, 3, 3 ); std::cout << "outputImage:" << result->toString();
polystyrene = ioformat.read_image(imagedev_data.get_image_path("polystyrene.tif"))
result = imagedev.snn_filter_2d( polystyrene, 3, 3 )
print( "output_image:", str( result ) );
            ImageView polystyrene = ViewIO.ReadImage( @"Data/images/polystyrene.tif" ); IOLink.ImageView result = Processing.SnnFilter2d( polystyrene, 3, 3 ); Console.WriteLine( "outputImage:" + result.ToString() );

