ITK/Examples/Smoothing/SmoothingRecursiveGaussianImageFilter: Difference between revisions

From KitwarePublic
< ITK‎ | Examples
Jump to navigationJump to search
(Removed the use of image adaptors as the filter can now handle vector images)
(Deprecated content that is moved to sphinx)
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
<div class="floatcenter">[[File:ITK_Examples_Baseline_Smoothing_TestSmoothingRecursiveGaussianImageFilter.png]]</div>
{{warning|1=The media wiki content on this page is no longer maintained.  The examples presented on the https://itk.org/Wiki/*  pages likely require ITK version 4.13 or earlier releases.  In many cases, the examples on this page no longer conform to the best practices for modern ITK versions.
This examples uses image adaptors to smooth RGB images. Each component is smoothed separately and the 3 resulting images are composed into an RGBImage.
}}
==SmoothingRecursiveGaussianImageFilter.cxx==
<source lang="cpp">
#include "itkImage.h"
#include "itkImageFileReader.h"
#include "itkDiscreteGaussianImageFilter.h"
#include "itkSmoothingRecursiveGaussianImageFilter.h"
#include "itkRGBPixel.h"
#include "itkNthElementImageAdaptor.h"
#include "itkComposeRGBImageFilter.h"


#include "QuickView.h"
[https://itk.org/ITKExamples[ITK Sphinx Examples]]
 
int main(int argc, char * argv[])
{
  // Verify command line arguments
  if( argc < 2 )
    {
    std::cerr << "Usage: " << std::endl;
    std::cerr << argv[0] << " inputImageFile [sigma]" << std::endl;
    return EXIT_FAILURE;
    }
 
  double sigma = 4.0;
  if (argc > 2)
    {
    sigma = atof(argv[2]);
    }
 
 
  const unsigned int Dimension = 2;
  typedef unsigned char PixelComponentType;
 
  typedef itk::Image<itk::RGBPixel< PixelComponentType>,
    Dimension > ColorImageType;
 
  typedef itk::ImageFileReader< ColorImageType >
    ReaderType;
  // Create and setup a reader
  ReaderType::Pointer reader = ReaderType::New();
  reader->SetFileName( argv[1] );
  reader->Update();
 
  typedef itk::SmoothingRecursiveGaussianImageFilter<
    ColorImageType, ColorImageType >  FilterType;
 
  FilterType::Pointer smoothingRecursiveGaussianImageFilter = FilterType::New();
  smoothingRecursiveGaussianImageFilter->SetInput(reader->GetOutput());
  smoothingRecursiveGaussianImageFilter->SetSigma(sigma);
  smoothingRecursiveGaussianImageFilter->Update();
 
  QuickView viewer;
  viewer.AddRGBImage(
    reader->GetOutput(),true,
    itksys::SystemTools::GetFilenameName(argv[1]));
 
  std::stringstream desc;
  desc << "SmoothingRecursiveGaussian\n sigma = " << sigma;
  viewer.AddRGBImage(
    smoothingRecursiveGaussianImageFilter.GetPointer(),
    true,
    desc.str());
 
  viewer.Visualize();
 
  return EXIT_SUCCESS;
}
 
</source>
 
{{ITKVTKCMakeLists|SmoothingRecursiveGaussianImageFilter|}}

Latest revision as of 20:09, 31 May 2019

Warning: The media wiki content on this page is no longer maintained. The examples presented on the https://itk.org/Wiki/* pages likely require ITK version 4.13 or earlier releases. In many cases, the examples on this page no longer conform to the best practices for modern ITK versions.

[ITK Sphinx Examples]