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

mitk::PadImageFilter Class Reference
[Process Classes]

PadImageFilter class pads the first input image to the size of the second input image. Two Images have to be set. The first image is the image to pad. The second image defines the pad size. It is also possible to use an included binary filter. More...

#include <mitkPadImageFilter.h>

Inheritance diagram for mitk::PadImageFilter:
Inheritance graph
[legend]
Collaboration diagram for mitk::PadImageFilter:
Collaboration graph
[legend]

List of all members.

Public Types

typedef PadImageFilter Self
typedef ImageToImageFilter Superclass
typedef itk::SmartPointer< SelfPointer
typedef itk::SmartPointer
< const Self
ConstPointer

Public Member Functions

virtual const char * GetClassName () const
virtual void SetPadConstant (int _arg)
 Sets the intensity of the pixel to pad.
virtual void SetBinaryFilter (bool _arg)
 sets the binary filter ON or OFF
virtual void SetLowerThreshold (int _arg)
 Sets the lower threshold of the included binary filter.
virtual void SetUpperThreshold (int _arg)
 Sets the upper threshold of the included binary filter.

Static Public Member Functions

static Pointer New ()

Protected Member Functions

 PadImageFilter ()
virtual ~PadImageFilter ()
virtual void GenerateData ()
 A version of GenerateData() specific for image processing filters.

Detailed Description

PadImageFilter class pads the first input image to the size of the second input image. Two Images have to be set. The first image is the image to pad. The second image defines the pad size. It is also possible to use an included binary filter.

Definition at line 40 of file mitkPadImageFilter.h.


Member Typedef Documentation

typedef itk::SmartPointer<const Self> mitk::PadImageFilter::ConstPointer

Definition at line 43 of file mitkPadImageFilter.h.

typedef itk::SmartPointer<Self> mitk::PadImageFilter::Pointer

Definition at line 43 of file mitkPadImageFilter.h.

Definition at line 43 of file mitkPadImageFilter.h.

Definition at line 43 of file mitkPadImageFilter.h.


Constructor & Destructor Documentation

mitk::PadImageFilter::PadImageFilter (  ) [protected]

Definition at line 25 of file mitkPadImageFilter.cpp.

{
  this->SetNumberOfInputs(2);
  this->SetNumberOfRequiredInputs(2);
  m_BinaryFilter = false;

  m_PadConstant = -32766;
  m_LowerThreshold = -32766;
  m_UpperThreshold = -32765;
}
mitk::PadImageFilter::~PadImageFilter (  ) [protected, virtual]

Definition at line 36 of file mitkPadImageFilter.cpp.

{
}

Member Function Documentation

void mitk::PadImageFilter::GenerateData (  ) [protected, virtual]

A version of GenerateData() specific for image processing filters.

This implementation will split the processing across multiple threads. The buffer is allocated by this method. Then the BeforeThreadedGenerateData() method is called (if provided). Then, a series of threads are spawned each calling ThreadedGenerateData(). After all the threads have completed processing, the AfterThreadedGenerateData() method is called (if provided). If an image processing filter cannot be threaded, the filter should provide an implementation of GenerateData(). That implementation is responsible for allocating the output buffer. If a filter an be threaded, it should NOT provide a GenerateData() method but should provide a ThreadedGenerateData() instead.

See also:
ThreadedGenerateData()

Reimplemented from mitk::ImageSource.

Definition at line 41 of file mitkPadImageFilter.cpp.

References mitk::CastToItkImage(), mitk::CastToMitkImage(), mitk::Geometry3D::GetOrigin(), and mitk::Geometry3D::GetSpacing().

{
  mitk::Image::ConstPointer image = this->GetInput( 0 );
  mitk::Image::ConstPointer referenceImage = this->GetInput( 1 );

  typedef itk::Image< short, 3 > ImageType;
  ImageType::Pointer itkImage = ImageType::New();
  mitk::CastToItkImage( image, itkImage );


  mitk::Geometry3D *imageGeometry = image->GetGeometry();
  mitk::Point3D origin = imageGeometry->GetOrigin();
  mitk::Vector3D spacing = imageGeometry->GetSpacing();

  mitk::Geometry3D *referenceImageGeometry = referenceImage->GetGeometry();
  mitk::Point3D referenceOrigin = referenceImageGeometry->GetOrigin();
  mitk::Vector3D referenceSpacing = referenceImageGeometry->GetSpacing();


  double outputOrigin[3];
  unsigned long padLowerBound[3];
  unsigned long padUpperBound[3];
  
  int i;
  for ( i = 0; i < 3; ++i )
  {
    outputOrigin[i] = referenceOrigin[i];
   
    padLowerBound[i] = static_cast< unsigned long >
      ((origin[i] - referenceOrigin[i]) / spacing[i] + 0.5);

    padUpperBound[i] = referenceImage->GetDimension( i ) 
      - image->GetDimension( i ) - padLowerBound[i];
  }

  // The origin of the input image is passed through the filter and used as 
  // output origin as well. Hence, it needs to be overwritten accordingly.
  itkImage->SetOrigin( outputOrigin );


  typedef itk::ConstantPadImageFilter< ImageType, ImageType > PadFilterType;
  PadFilterType::Pointer padFilter = PadFilterType::New();
  padFilter->SetInput( itkImage );
  padFilter->SetConstant( m_PadConstant );
  padFilter->SetPadLowerBound( padLowerBound );
  padFilter->SetPadUpperBound( padUpperBound );

  mitk::Image::Pointer outputImage = this->GetOutput();


  // If the Binary flag is set, use an additional binary threshold filter after
  // padding.
  if ( m_BinaryFilter )
  {
    typedef itk::Image< char, 3 > BinaryImageType;
    typedef itk::BinaryThresholdImageFilter< ImageType, BinaryImageType >
      BinaryFilterType;
    BinaryFilterType::Pointer binaryFilter = BinaryFilterType::New();

    binaryFilter->SetInput( padFilter->GetOutput() );
    binaryFilter->SetLowerThreshold( m_LowerThreshold );
    binaryFilter->SetUpperThreshold( m_UpperThreshold );
    binaryFilter->SetInsideValue( 0 );
    binaryFilter->SetOutsideValue( 1 );
    binaryFilter->Update();

    mitk::CastToMitkImage( binaryFilter->GetOutput(), outputImage );
  }
  else
  {
    padFilter->Update();
    mitk::CastToMitkImage( padFilter->GetOutput(), outputImage );
  }

  outputImage->SetRequestedRegionToLargestPossibleRegion();
}
virtual const char* mitk::PadImageFilter::GetClassName (  ) const [virtual]
static Pointer mitk::PadImageFilter::New (  ) [static]

Method for creation through the object factory.

Reimplemented from mitk::ImageToImageFilter.

virtual void mitk::PadImageFilter::SetBinaryFilter ( bool  _arg ) [virtual]

sets the binary filter ON or OFF

virtual void mitk::PadImageFilter::SetLowerThreshold ( int  _arg ) [virtual]

Sets the lower threshold of the included binary filter.

virtual void mitk::PadImageFilter::SetPadConstant ( int  _arg ) [virtual]

Sets the intensity of the pixel to pad.

virtual void mitk::PadImageFilter::SetUpperThreshold ( int  _arg ) [virtual]

Sets the upper threshold of the included binary filter.


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