ImageDev

NagaoFilter2d

Performs an edge-preserving smoothing of a two-dimensional image by selecting a mean value from different neighborhood configurations.

Access to parameter description

For an introduction to image filters: see Images Filtering.

This algorithm uses an adaptive 5x5 neighborhood geometry to compute a mean neighbors value around a central pixel.
The mean values of different neighborhood configurations around the considered pixel are computed. The pixel is replaced by the mean value of the configuration presenting: This criterion is user-defined by the filter method parameter.

Four neighborhood geometry types are supported by this filter:
<b>Figure 1.</b> The Tsuji-Tomita neighborhoods.
Figure 1. The Tsuji-Tomita neighborhoods.
<b>Figure 2.</b> The  Nagao 7-pixel neighborhoods.
Figure 2. The Nagao 7-pixel neighborhoods.
<b>Figure 3.</b> The Nagao 9-pixel neighborhoods.
Figure 3. The Nagao 9-pixel neighborhoods.
<b>Figure 4.</b> The Nagmod neighborhoods.
Figure 4. The Nagmod neighborhoods.


Reference:
M.Nagao, T.Matsuyama. "Edge preserving smoothing". Computer Graphics and Image Processing, vol. 9, pp. 394-407, 1979.

See also

Function Syntax

This function returns outputImage.
// Function prototype
std::shared_ptr< iolink::ImageView > nagaoFilter2d( std::shared_ptr< iolink::ImageView > inputImage, NagaoFilter2d::FilterType filterType, NagaoFilter2d::FilterMethod filterMethod, std::shared_ptr< iolink::ImageView > outputImage = NULL );
This function returns outputImage.
// Function prototype.
nagao_filter_2d( input_image,
                 filter_type = NagaoFilter2d.FilterType.TSUJI,
                 filter_method = NagaoFilter2d.FilterMethod.VARIANCE,
                 output_image = None )
This function returns outputImage.
// Function prototype.
public static IOLink.ImageView
NagaoFilter2d( IOLink.ImageView inputImage,
               NagaoFilter2d.FilterType filterType = ImageDev.NagaoFilter2d.FilterType.TSUJI,
               NagaoFilter2d.FilterMethod filterMethod = ImageDev.NagaoFilter2d.FilterMethod.VARIANCE,
               IOLink.ImageView outputImage = null );

Class Syntax

Parameters

Parameter Name Description Type Supported Values Default Value
input
inputImage
The input image. Image Binary, Label, Grayscale or Multispectral nullptr
input
filterType
The neighborhood geometry type.
TSUJI This option uses the Tsuji-Tomita configurations.
NAGAO7 This option uses the Nagao configurations with 7 pixels made neighborhoods.
NAGAO9 This option uses the Nagao configurations with 9 pixels made neighborhoods.
NAGMOD This option uses Nagmod configurations.
Enumeration TSUJI
input
filterMethod
The neighborhood selection criterion.
VARIANCE This option selects the mean of the neighborhood configuration of lower variance.
RANGE This option selects the mean of the neighborhood configuration of lower intensity range.
Enumeration VARIANCE
output
outputImage
The output image. Its dimensions, type, and calibration are forced to the same values as the input. Image nullptr
Parameter Name Description Type Supported Values Default Value
input
input_image
The input image. image Binary, Label, Grayscale or Multispectral None
input
filter_type
The neighborhood geometry type.
TSUJI This option uses the Tsuji-Tomita configurations.
NAGAO7 This option uses the Nagao configurations with 7 pixels made neighborhoods.
NAGAO9 This option uses the Nagao configurations with 9 pixels made neighborhoods.
NAGMOD This option uses Nagmod configurations.
enumeration TSUJI
input
filter_method
The neighborhood selection criterion.
VARIANCE This option selects the mean of the neighborhood configuration of lower variance.
RANGE This option selects the mean of the neighborhood configuration of lower intensity range.
enumeration VARIANCE
output
output_image
The output image. Its dimensions, type, and calibration are forced to the same values as the input. image None
Parameter Name Description Type Supported Values Default Value
input
inputImage
The input image. Image Binary, Label, Grayscale or Multispectral null
input
filterType
The neighborhood geometry type.
TSUJI This option uses the Tsuji-Tomita configurations.
NAGAO7 This option uses the Nagao configurations with 7 pixels made neighborhoods.
NAGAO9 This option uses the Nagao configurations with 9 pixels made neighborhoods.
NAGMOD This option uses Nagmod configurations.
Enumeration TSUJI
input
filterMethod
The neighborhood selection criterion.
VARIANCE This option selects the mean of the neighborhood configuration of lower variance.
RANGE This option selects the mean of the neighborhood configuration of lower intensity range.
Enumeration VARIANCE
output
outputImage
The output image. Its dimensions, type, and calibration are forced to the same values as the input. Image null

Object Examples

std::shared_ptr< iolink::ImageView > polystyrene = ioformat::readImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "polystyrene.tif" );

NagaoFilter2d nagaoFilter2dAlgo;
nagaoFilter2dAlgo.setInputImage( polystyrene );
nagaoFilter2dAlgo.setFilterType( NagaoFilter2d::FilterType::TSUJI );
nagaoFilter2dAlgo.setFilterMethod( NagaoFilter2d::FilterMethod::VARIANCE );
nagaoFilter2dAlgo.execute();

std::cout << "outputImage:" << nagaoFilter2dAlgo.outputImage()->toString();
polystyrene = ioformat.read_image(imagedev_data.get_image_path("polystyrene.tif"))

nagao_filter_2d_algo = imagedev.NagaoFilter2d()
nagao_filter_2d_algo.input_image = polystyrene
nagao_filter_2d_algo.filter_type = imagedev.NagaoFilter2d.TSUJI
nagao_filter_2d_algo.filter_method = imagedev.NagaoFilter2d.VARIANCE
nagao_filter_2d_algo.execute()

print( "output_image:", str( nagao_filter_2d_algo.output_image ) )
ImageView polystyrene = ViewIO.ReadImage( @"Data/images/polystyrene.tif" );

NagaoFilter2d nagaoFilter2dAlgo = new NagaoFilter2d
{
    inputImage = polystyrene,
    filterType = NagaoFilter2d.FilterType.TSUJI,
    filterMethod = NagaoFilter2d.FilterMethod.VARIANCE
};
nagaoFilter2dAlgo.Execute();

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

Function Examples

std::shared_ptr< iolink::ImageView > polystyrene = ioformat::readImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "polystyrene.tif" );

auto result = nagaoFilter2d( polystyrene, NagaoFilter2d::FilterType::TSUJI, NagaoFilter2d::FilterMethod::VARIANCE );

std::cout << "outputImage:" << result->toString();
polystyrene = ioformat.read_image(imagedev_data.get_image_path("polystyrene.tif"))

result = imagedev.nagao_filter_2d( polystyrene, imagedev.NagaoFilter2d.TSUJI, imagedev.NagaoFilter2d.VARIANCE )

print( "output_image:", str( result ) )
ImageView polystyrene = ViewIO.ReadImage( @"Data/images/polystyrene.tif" );

IOLink.ImageView result = Processing.NagaoFilter2d( polystyrene, NagaoFilter2d.FilterType.TSUJI, NagaoFilter2d.FilterMethod.VARIANCE );

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