Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions

itk::LocalVariationImageFilter< TInputImage, TOutputImage > Class Template Reference

Calculates the local variation in each pixel. More...

#include <itkLocalVariationImageFilter.h>

List of all members.

Public Types

typedef TInputImage InputImageType
typedef TOutputImage OutputImageType
typedef LocalVariationImageFilter Self
typedef ImageToImageFilter
< InputImageType,
OutputImageType
Superclass
typedef SmartPointer< SelfPointer
typedef SmartPointer< const SelfConstPointer
typedef InputImageType::PixelType InputPixelType
typedef OutputImageType::PixelType OutputPixelType
typedef InputImageType::RegionType InputImageRegionType
typedef OutputImageType::RegionType OutputImageRegionType
typedef InputImageType::SizeType InputSizeType

Public Member Functions

 itkStaticConstMacro (InputImageDimension, unsigned int, TInputImage::ImageDimension)
 itkStaticConstMacro (OutputImageDimension, unsigned int, TOutputImage::ImageDimension)
virtual const char * GetClassName () const
virtual void GenerateInputRequestedRegion () throw (InvalidRequestedRegionError)

Static Public Member Functions

static Pointer New ()

Protected Member Functions

 LocalVariationImageFilter ()
virtual ~LocalVariationImageFilter ()
void PrintSelf (std::ostream &os, Indent indent) const
void ThreadedGenerateData (const OutputImageRegionType &outputRegionForThread, int threadId)

Detailed Description

template<class TInputImage, class TOutputImage>
class itk::LocalVariationImageFilter< TInputImage, TOutputImage >

Calculates the local variation in each pixel.

Reference: Tony F. Chan et al., The digital TV filter and nonlinear denoising

See also:
Image
Neighborhood
NeighborhoodOperator
NeighborhoodIterator

Definition at line 47 of file itkLocalVariationImageFilter.h.


Member Typedef Documentation

template<class TInputImage , class TOutputImage >
typedef SmartPointer<const Self> itk::LocalVariationImageFilter< TInputImage, TOutputImage >::ConstPointer

Definition at line 65 of file itkLocalVariationImageFilter.h.

template<class TInputImage , class TOutputImage >
typedef InputImageType::RegionType itk::LocalVariationImageFilter< TInputImage, TOutputImage >::InputImageRegionType

Definition at line 77 of file itkLocalVariationImageFilter.h.

template<class TInputImage , class TOutputImage >
typedef TInputImage itk::LocalVariationImageFilter< TInputImage, TOutputImage >::InputImageType

Convenient typedefs for simplifying declarations.

Definition at line 58 of file itkLocalVariationImageFilter.h.

template<class TInputImage , class TOutputImage >
typedef InputImageType::PixelType itk::LocalVariationImageFilter< TInputImage, TOutputImage >::InputPixelType

Image typedef support.

Definition at line 71 of file itkLocalVariationImageFilter.h.

template<class TInputImage , class TOutputImage >
typedef InputImageType::SizeType itk::LocalVariationImageFilter< TInputImage, TOutputImage >::InputSizeType

Definition at line 80 of file itkLocalVariationImageFilter.h.

template<class TInputImage , class TOutputImage >
typedef OutputImageType::RegionType itk::LocalVariationImageFilter< TInputImage, TOutputImage >::OutputImageRegionType

Definition at line 78 of file itkLocalVariationImageFilter.h.

template<class TInputImage , class TOutputImage >
typedef TOutputImage itk::LocalVariationImageFilter< TInputImage, TOutputImage >::OutputImageType

Definition at line 59 of file itkLocalVariationImageFilter.h.

template<class TInputImage , class TOutputImage >
typedef OutputImageType::PixelType itk::LocalVariationImageFilter< TInputImage, TOutputImage >::OutputPixelType

Definition at line 75 of file itkLocalVariationImageFilter.h.

template<class TInputImage , class TOutputImage >
typedef SmartPointer<Self> itk::LocalVariationImageFilter< TInputImage, TOutputImage >::Pointer

Definition at line 64 of file itkLocalVariationImageFilter.h.

template<class TInputImage , class TOutputImage >
typedef LocalVariationImageFilter itk::LocalVariationImageFilter< TInputImage, TOutputImage >::Self

Standard class typedefs.

Definition at line 62 of file itkLocalVariationImageFilter.h.

template<class TInputImage , class TOutputImage >
typedef ImageToImageFilter< InputImageType, OutputImageType> itk::LocalVariationImageFilter< TInputImage, TOutputImage >::Superclass

Definition at line 63 of file itkLocalVariationImageFilter.h.


Constructor & Destructor Documentation

template<class TInputImage , class TOutputImage >
itk::LocalVariationImageFilter< TInputImage, TOutputImage >::LocalVariationImageFilter (  ) [protected]

Definition at line 37 of file itkLocalVariationImageFilter.txx.

  {}
template<class TInputImage , class TOutputImage >
virtual itk::LocalVariationImageFilter< TInputImage, TOutputImage >::~LocalVariationImageFilter (  ) [inline, protected, virtual]

Definition at line 93 of file itkLocalVariationImageFilter.h.

{}

Member Function Documentation

template<class TInputImage , class TOutputImage >
void itk::LocalVariationImageFilter< TInputImage, TOutputImage >::GenerateInputRequestedRegion (  ) throw (InvalidRequestedRegionError) [virtual]

MedianImageFilter needs a larger input requested region than the output requested region. As such, MedianImageFilter needs to provide an implementation for GenerateInputRequestedRegion() in order to inform the pipeline execution model.

See also:
ImageToImageFilter::GenerateInputRequestedRegion()

Definition at line 43 of file itkLocalVariationImageFilter.txx.

  {
    // call the superclass' implementation of this method
    Superclass::GenerateInputRequestedRegion();

    // get pointers to the input and output
    typename Superclass::InputImagePointer inputPtr = 
      const_cast< TInputImage * >( this->GetInput() );
    typename Superclass::OutputImagePointer outputPtr = this->GetOutput();

    if ( !inputPtr || !outputPtr )
    {
      return;
    }

    // get a copy of the input requested region (should equal the output
    // requested region)
    typename TInputImage::RegionType inputRequestedRegion;
    inputRequestedRegion = inputPtr->GetRequestedRegion();

    // pad the input requested region by 1
    inputRequestedRegion.PadByRadius( 1 );

    // crop the input requested region at the input's largest possible region
    if ( inputRequestedRegion.Crop(inputPtr->GetLargestPossibleRegion()) )
    {
      inputPtr->SetRequestedRegion( inputRequestedRegion );
      return;
    }
    else
    {
      // Couldn't crop the region (requested region is outside the largest
      // possible region).  Throw an exception.

      // store what we tried to request (prior to trying to crop)
      inputPtr->SetRequestedRegion( inputRequestedRegion );

      // build an exception
      InvalidRequestedRegionError e(__FILE__, __LINE__);
      e.SetLocation(ITK_LOCATION);
      e.SetDescription("Requested region outside possible region.");
      e.SetDataObject(inputPtr);
      throw e;
    }
  }
template<class TInputImage , class TOutputImage >
virtual const char* itk::LocalVariationImageFilter< TInputImage, TOutputImage >::GetClassName (  ) const [virtual]

Run-time type information (and related methods).

template<class TInputImage , class TOutputImage >
itk::LocalVariationImageFilter< TInputImage, TOutputImage >::itkStaticConstMacro ( OutputImageDimension  ,
unsigned  int,
TOutputImage::ImageDimension   
)
template<class TInputImage , class TOutputImage >
itk::LocalVariationImageFilter< TInputImage, TOutputImage >::itkStaticConstMacro ( InputImageDimension  ,
unsigned  int,
TInputImage::ImageDimension   
)

Extract dimension from input and output image.

template<class TInputImage , class TOutputImage >
static Pointer itk::LocalVariationImageFilter< TInputImage, TOutputImage >::New (  ) [static]

Method for creation through the object factory.

template<class TInputImage , class TOutput >
void itk::LocalVariationImageFilter< TInputImage, TOutput >::PrintSelf ( std::ostream &  os,
Indent  indent 
) const [protected]

Standard "PrintSelf" method

Definition at line 202 of file itkLocalVariationImageFilter.txx.

  {
    Superclass::PrintSelf( os, indent );
  }
template<class TInputImage , class TOutputImage >
void itk::LocalVariationImageFilter< TInputImage, TOutputImage >::ThreadedGenerateData ( const OutputImageRegionType outputRegionForThread,
int  threadId 
) [protected]

MedianImageFilter can be implemented as a multithreaded filter. Therefore, this implementation provides a ThreadedGenerateData() routine which is called for each processing thread. The output image data is allocated automatically by the superclass prior to calling ThreadedGenerateData(). ThreadedGenerateData can only write to the portion of the output image specified by the parameter "outputRegionForThread"

See also:
ImageToImageFilter::ThreadedGenerateData(), ImageToImageFilter::GenerateData()

Definition at line 110 of file itkLocalVariationImageFilter.txx.

References QuadProgPP::sqrt().

  {

    // Allocate output
    typename OutputImageType::Pointer output = this->GetOutput();
    typename  InputImageType::ConstPointer input  = this->GetInput();

    itk::Size<InputImageDimension> size;
    for( int i=0; i<InputImageDimension; i++)
      size[i] = 1;

    // Find the data-set boundary "faces"
    NeighborhoodAlgorithm::ImageBoundaryFacesCalculator<InputImageType> bC;
    typename NeighborhoodAlgorithm::
      ImageBoundaryFacesCalculator<InputImageType>::FaceListType
      faceList = bC(input, outputRegionForThread, size);

    // support progress methods/callbacks
    ProgressReporter progress(
      this, threadId, outputRegionForThread.GetNumberOfPixels());

    ZeroFluxNeumannBoundaryCondition<InputImageType> nbc;
    std::vector<InputPixelType> pixels;

    // Process each of the boundary faces.  These are N-d regions which border
    // the edge of the buffer.
    for ( typename NeighborhoodAlgorithm::
      ImageBoundaryFacesCalculator<InputImageType>::FaceListType::iterator
      fit=faceList.begin(); fit != faceList.end(); ++fit)
    {

      // iterators over output and input
      ImageRegionIterator<OutputImageType> 
        output_image_it(output, *fit);
      ImageRegionConstIterator<InputImageType> 
        input_image_it(input.GetPointer(), *fit);

      // neighborhood iterator for input image
      ConstShapedNeighborhoodIterator<InputImageType> 
        input_image_neighbors_it(size, input, *fit);
      typename ConstShapedNeighborhoodIterator<InputImageType>::
        OffsetType offset;
      input_image_neighbors_it.OverrideBoundaryCondition(&nbc);
      input_image_neighbors_it.ClearActiveList();
      for(int i=0; i<InputImageDimension; i++)
      {
        offset.Fill(0);
        offset[i] = -1;
        input_image_neighbors_it.ActivateOffset(offset);
        offset[i] = 1;
        input_image_neighbors_it.ActivateOffset(offset);
      }
      input_image_neighbors_it.GoToBegin();
      //const unsigned int neighborhoodSize = InputImageDimension*2;

      while ( ! input_image_neighbors_it.IsAtEnd() )
      {
        // collect all the pixels in the neighborhood, note that we use
        // GetPixel on the NeighborhoodIterator to honor the boundary conditions
        typename OutputImageType::PixelType locVariation = 0;
        typename ConstShapedNeighborhoodIterator<InputImageType>::
          ConstIterator input_neighbors_it;
        for (input_neighbors_it = input_image_neighbors_it.Begin(); 
          ! input_neighbors_it.IsAtEnd(); 
          input_neighbors_it++)
        { 
            typename TInputImage::PixelType diffVec = 
              input_neighbors_it.Get()-input_image_it.Get();
            locVariation += SquaredEuclideanMetric
              <typename TInputImage::PixelType>::Calc(diffVec);
        }
        locVariation = sqrt(locVariation + 0.0001);
        output_image_it.Set(locVariation);

        // update iterators
        ++input_image_neighbors_it;
        ++output_image_it;
        ++input_image_it;

        // report progress
        progress.CompletedPixel();
      }
    }
  }

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines