Converts surface data to pixel data. Requires a surface and an image, which header information defines the output image. More...
#include <mitkSurfaceToImageFilter.h>
Public Types | |
typedef SurfaceToImageFilter | Self |
typedef ImageSource | Superclass |
typedef itk::SmartPointer< Self > | Pointer |
typedef itk::SmartPointer < const Self > | ConstPointer |
Public Member Functions | |
virtual const char * | GetClassName () const |
virtual void | SetMakeOutputBinary (bool _arg) |
virtual bool | GetMakeOutputBinary () |
virtual void | MakeOutputBinaryOn () |
virtual void | MakeOutputBinaryOff () |
virtual float | GetBackgroundValue () const |
virtual void | SetBackgroundValue (float _arg) |
virtual void | GenerateInputRequestedRegion () |
virtual void | GenerateOutputInformation () |
virtual void | GenerateData () |
A version of GenerateData() specific for image processing filters. | |
const mitk::Surface * | GetInput (void) |
virtual void | SetInput (const mitk::Surface *surface) |
void | SetImage (const mitk::Image *source) |
const mitk::Image * | GetImage (void) |
Static Public Member Functions | |
static Pointer | New () |
Method for creation through the object factory. | |
Protected Member Functions | |
SurfaceToImageFilter () | |
virtual | ~SurfaceToImageFilter () |
void | Stencil3DImage (int time=0) |
Protected Attributes | |
bool | m_MakeOutputBinary |
float | m_BackgroundValue |
Converts surface data to pixel data. Requires a surface and an image, which header information defines the output image.
The resulting image has the same dimension, size, and Geometry3D as the input image. The image is cut using a vtkStencil. The user can decide if he wants to keep the original values or create a binary image by setting MakeBinaryOutputOn (default is false). If set to true all voxels inside the surface are set to one and all outside voxel are set to zero.
NOTE: Since the reference input image is passed to the vtkStencil in any case, the image needs to be initialized with pixel values greater than the numerical minimum of the used pixel type (e.g. at least -127 for unsigned char images, etc.) to produce a correct binary image representation of the surface in MakeOutputBinary mode.
Definition at line 55 of file mitkSurfaceToImageFilter.h.
typedef itk::SmartPointer<const Self> mitk::SurfaceToImageFilter::ConstPointer |
Reimplemented in TwoOutputsFilter.
Definition at line 58 of file mitkSurfaceToImageFilter.h.
typedef itk::SmartPointer<Self> mitk::SurfaceToImageFilter::Pointer |
Reimplemented in TwoOutputsFilter.
Definition at line 58 of file mitkSurfaceToImageFilter.h.
Reimplemented in TwoOutputsFilter.
Definition at line 58 of file mitkSurfaceToImageFilter.h.
Reimplemented in TwoOutputsFilter.
Definition at line 58 of file mitkSurfaceToImageFilter.h.
mitk::SurfaceToImageFilter::SurfaceToImageFilter | ( | ) | [protected] |
Definition at line 37 of file mitkSurfaceToImageFilter.cpp.
: m_MakeOutputBinary( false ), m_BackgroundValue( -10000 ) { }
mitk::SurfaceToImageFilter::~SurfaceToImageFilter | ( | ) | [protected, virtual] |
Definition at line 43 of file mitkSurfaceToImageFilter.cpp.
{ }
void mitk::SurfaceToImageFilter::GenerateData | ( | ) | [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.
Reimplemented from mitk::ImageSource.
Definition at line 75 of file mitkSurfaceToImageFilter.cpp.
References QuadProgPP::t().
{ mitk::Image::ConstPointer inputImage = this->GetImage(); mitk::Image::Pointer output = this->GetOutput(); if(inputImage.IsNull()) return; if(output->IsInitialized()==false ) return; mitk::Image::RegionType outputRegion = output->GetRequestedRegion(); int tstart=outputRegion.GetIndex(3); int tmax=tstart+outputRegion.GetSize(3); if ( tmax > 0) { int t; for(t=tstart;t<tmax;++t) { Stencil3DImage( t ); } } else { Stencil3DImage( 0 ); } }
void mitk::SurfaceToImageFilter::GenerateInputRequestedRegion | ( | ) | [virtual] |
Definition at line 47 of file mitkSurfaceToImageFilter.cpp.
References mitk::GenerateTimeInInputRegion(), and mitk::BaseData::IsInitialized().
{ mitk::Image* output = this->GetOutput(); if((output->IsInitialized()==false) ) return; GenerateTimeInInputRegion(output, const_cast< mitk::Image * > ( this->GetImage() )); }
void mitk::SurfaceToImageFilter::GenerateOutputInformation | ( | void | ) | [virtual] |
Definition at line 56 of file mitkSurfaceToImageFilter.cpp.
References mitk::Image::GetPixelType(), mitk::BaseData::GetPropertyList(), mitk::BaseData::GetTimeSlicedGeometry(), and mitk::BaseData::IsInitialized().
{ mitk::Image *inputImage = (mitk::Image*)this->GetImage(); mitk::Image::Pointer output = this->GetOutput(); itkDebugMacro(<<"GenerateOutputInformation()"); if((inputImage == NULL) || (inputImage->IsInitialized() == false) || (inputImage->GetTimeSlicedGeometry() == NULL)) return; if (m_MakeOutputBinary) output->Initialize(mitk::PixelType(typeid(unsigned char)), *inputImage->GetTimeSlicedGeometry()); else output->Initialize(inputImage->GetPixelType(), *inputImage->GetTimeSlicedGeometry()); output->SetPropertyList(inputImage->GetPropertyList()->Clone()); }
virtual float mitk::SurfaceToImageFilter::GetBackgroundValue | ( | ) | const [virtual] |
virtual const char* mitk::SurfaceToImageFilter::GetClassName | ( | ) | const [virtual] |
Reimplemented in TwoOutputsFilter.
const mitk::Image * mitk::SurfaceToImageFilter::GetImage | ( | void | ) |
Definition at line 213 of file mitkSurfaceToImageFilter.cpp.
{ return static_cast< const mitk::Image * >(this->ProcessObject::GetInput(1)); }
const mitk::Surface * mitk::SurfaceToImageFilter::GetInput | ( | void | ) |
Definition at line 190 of file mitkSurfaceToImageFilter.cpp.
{ if (this->GetNumberOfInputs() < 1) { return 0; } return static_cast<const mitk::Surface * > ( this->ProcessObject::GetInput(0) ); }
virtual bool mitk::SurfaceToImageFilter::GetMakeOutputBinary | ( | ) | [virtual] |
virtual void mitk::SurfaceToImageFilter::MakeOutputBinaryOff | ( | ) | [virtual] |
virtual void mitk::SurfaceToImageFilter::MakeOutputBinaryOn | ( | ) | [virtual] |
static Pointer mitk::SurfaceToImageFilter::New | ( | ) | [static] |
Method for creation through the object factory.
Reimplemented from mitk::ImageSource.
Reimplemented in TwoOutputsFilter.
Referenced by QmitkSegmentationView::CreateSegmentationFromSurface(), and mitkSurfaceToImageFilterTest().
virtual void mitk::SurfaceToImageFilter::SetBackgroundValue | ( | float | _arg ) | [virtual] |
void mitk::SurfaceToImageFilter::SetImage | ( | const mitk::Image * | source ) |
Definition at line 208 of file mitkSurfaceToImageFilter.cpp.
{ this->ProcessObject::SetNthInput( 1, const_cast< mitk::Image * >( source ) ); }
void mitk::SurfaceToImageFilter::SetInput | ( | const mitk::Surface * | surface ) | [virtual] |
Definition at line 201 of file mitkSurfaceToImageFilter.cpp.
{
// Process object is not const-correct so the const_cast is required here
this->ProcessObject::SetNthInput(0,
const_cast< mitk::Surface * >( input ) );
}
virtual void mitk::SurfaceToImageFilter::SetMakeOutputBinary | ( | bool | _arg ) | [virtual] |
void mitk::SurfaceToImageFilter::Stencil3DImage | ( | int | time = 0 ) |
[protected] |
Definition at line 105 of file mitkSurfaceToImageFilter.cpp.
References mitk::TimeSlicedGeometry::GetGeometry3D(), mitk::Geometry3D::GetVtkTransform(), MITK_INFO, mitk::TimeSlicedGeometry::TimeStepToTimeStep(), and mitk::Geometry3D::TransferItkToVtkTransform().
{ const mitk::TimeSlicedGeometry *surfaceTimeGeometry = GetInput()->GetTimeSlicedGeometry(); const mitk::TimeSlicedGeometry *imageTimeGeometry = GetImage()->GetTimeSlicedGeometry(); // Convert time step from image time-frame to surface time-frame int surfaceTimeStep = surfaceTimeGeometry->TimeStepToTimeStep( imageTimeGeometry, time ); vtkPolyData * polydata = ( (mitk::Surface*)GetInput() )->GetVtkPolyData( surfaceTimeStep ); vtkTransformPolyDataFilter * move=vtkTransformPolyDataFilter::New(); move->SetInput(polydata); move->ReleaseDataFlagOn(); vtkTransform *transform=vtkTransform::New(); Geometry3D* geometry = surfaceTimeGeometry->GetGeometry3D( surfaceTimeStep ); geometry->TransferItkToVtkTransform(); transform->PostMultiply(); transform->Concatenate(geometry->GetVtkTransform()->GetMatrix()); // take image geometry into account. vtk-Image information will be changed to unit spacing and zero origin below. Geometry3D* imageGeometry = imageTimeGeometry->GetGeometry3D(time); imageGeometry->TransferItkToVtkTransform(); transform->Concatenate(imageGeometry->GetVtkTransform()->GetLinearInverse()); move->SetTransform(transform); transform->Delete(); vtkPolyDataNormals * normalsFilter = vtkPolyDataNormals::New(); normalsFilter->SetFeatureAngle(50); normalsFilter->SetConsistency(1); normalsFilter->SetSplitting(1); normalsFilter->SetFlipNormals(0); normalsFilter->ReleaseDataFlagOn(); normalsFilter->SetInput( move->GetOutput() ); move->Delete(); vtkPolyDataToImageStencil * surfaceConverter = vtkPolyDataToImageStencil::New(); surfaceConverter->SetTolerance( 0.0 ); surfaceConverter->ReleaseDataFlagOn(); surfaceConverter->SetInput( normalsFilter->GetOutput() ); normalsFilter->Delete(); vtkImageData *image = const_cast< mitk::Image * >(this->GetImage())->GetVtkImageData( time ); // Create stencil and use numerical minimum of pixel type as background value vtkImageStencil * stencil = vtkImageStencil::New(); stencil->SetInput( image ); stencil->ReverseStencilOff(); stencil->ReleaseDataFlagOn(); stencil->SetStencil( surfaceConverter->GetOutput() ); surfaceConverter->Delete(); if (m_MakeOutputBinary) { stencil->SetBackgroundValue( image->GetScalarTypeMin() ); vtkImageThreshold * threshold = vtkImageThreshold::New(); threshold->SetInput( stencil->GetOutput() ); threshold->ThresholdByLower( image->GetScalarTypeMin() ); threshold->ReplaceInOn(); threshold->ReplaceOutOn(); threshold->SetInValue( 0 ); threshold->SetOutValue( 1 ); threshold->SetOutputScalarTypeToUnsignedChar(); threshold->Update(); mitk::Image::Pointer output = this->GetOutput(); output->SetVolume( threshold->GetOutput()->GetScalarPointer(), time ); threshold->Delete(); } else { stencil->SetBackgroundValue( m_BackgroundValue ); stencil->Update(); mitk::Image::Pointer output = this->GetOutput(); output->SetVolume( stencil->GetOutput()->GetScalarPointer(), time ); MITK_INFO << "stencil ref count: " << stencil->GetReferenceCount() << std::endl; } stencil->Delete(); }
float mitk::SurfaceToImageFilter::m_BackgroundValue [protected] |
Definition at line 91 of file mitkSurfaceToImageFilter.h.
bool mitk::SurfaceToImageFilter::m_MakeOutputBinary [protected] |
Definition at line 89 of file mitkSurfaceToImageFilter.h.