#include <mitkCalculateSegmentationVolume.h>
Public Types | |
typedef CalculateSegmentationVolume | Self |
typedef SegmentationSink | Superclass |
typedef itk::SmartPointer< Self > | Pointer |
typedef itk::SmartPointer < const Self > | ConstPointer |
Public Member Functions | |
virtual const char * | GetClassName () const |
virtual ::itk::LightObject::Pointer | CreateAnother (void) const |
Static Public Member Functions | |
static Pointer | New (void) |
Protected Member Functions | |
CalculateSegmentationVolume () | |
virtual | ~CalculateSegmentationVolume () |
virtual bool | ReadyToRun () |
virtual bool | ThreadedUpdateFunction () |
template<typename TPixel , unsigned int VImageDimension> | |
void | ItkImageProcessing (itk::Image< TPixel, VImageDimension > *itkImage, TPixel *dummy=NULL) |
Definition at line 28 of file mitkCalculateSegmentationVolume.h.
typedef itk::SmartPointer<const Self> mitk::CalculateSegmentationVolume::ConstPointer |
Reimplemented from mitk::SegmentationSink.
Definition at line 32 of file mitkCalculateSegmentationVolume.h.
typedef itk::SmartPointer<Self> mitk::CalculateSegmentationVolume::Pointer |
Reimplemented from mitk::SegmentationSink.
Definition at line 32 of file mitkCalculateSegmentationVolume.h.
Reimplemented from mitk::SegmentationSink.
Definition at line 32 of file mitkCalculateSegmentationVolume.h.
Reimplemented from mitk::SegmentationSink.
Definition at line 32 of file mitkCalculateSegmentationVolume.h.
mitk::CalculateSegmentationVolume::CalculateSegmentationVolume | ( | ) | [protected] |
Definition at line 21 of file mitkCalculateSegmentationVolume.cpp.
{
mitk::CalculateSegmentationVolume::~CalculateSegmentationVolume | ( | ) | [protected, virtual] |
Definition at line 26 of file mitkCalculateSegmentationVolume.cpp.
{ }
virtual ::itk::LightObject::Pointer mitk::CalculateSegmentationVolume::CreateAnother | ( | void | ) | const [inline, virtual] |
Reimplemented from mitk::SegmentationSink.
Definition at line 33 of file mitkCalculateSegmentationVolume.h.
:
virtual const char* mitk::CalculateSegmentationVolume::GetClassName | ( | ) | const [virtual] |
Reimplemented from mitk::SegmentationSink.
void mitk::CalculateSegmentationVolume::ItkImageProcessing | ( | itk::Image< TPixel, VImageDimension > * | itkImage, |
TPixel * | dummy = NULL |
||
) | [protected] |
Definition at line 32 of file mitkCalculateSegmentationVolume.cpp.
{ } template < typename TPixel, unsigned int VImageDimension > void CalculateSegmentationVolume::ItkImageProcessing( itk::Image< TPixel, VImageDimension >* itkImage, TPixel* itkNotUsed(dummy) ) { itk::ImageRegionConstIteratorWithIndex<itk::Image<TPixel, VImageDimension> > iterBinaryImage( itkImage, itkImage->GetLargestPossibleRegion() ); typename itk::ImageRegionConstIteratorWithIndex<itk::Image<TPixel, VImageDimension> >::IndexType currentIndex; typename itk::ImageRegionConstIteratorWithIndex<itk::Image<TPixel, VImageDimension> >::IndexType minIndex; for (unsigned int i = 0; i < VImageDimension; ++i) minIndex[i] = std::numeric_limits<long int>::max(); typename itk::ImageRegionConstIteratorWithIndex<itk::Image<TPixel, VImageDimension> >::IndexType maxIndex; for (unsigned int i = 0; i < VImageDimension; ++i) maxIndex[i] = std::numeric_limits<long int>::min(); m_CenterOfMass.Fill(0.0); m_Volume = 0; while (!iterBinaryImage.IsAtEnd()) { if ( iterBinaryImage.Get() > static_cast<TPixel>(0.0) ) { // update center of mass currentIndex = iterBinaryImage.GetIndex(); itk::Vector<float, VImageDimension> currentPoint; for (unsigned int i = 0; i < VImageDimension; ++i) currentPoint[i] = currentIndex[i]; m_CenterOfMass = (m_CenterOfMass * ( static_cast<float>(m_Volume) / static_cast<float>(m_Volume+1) ) ) // e.g. 3 points: old center * 2/3 + currentPoint * 1/3; + currentPoint / static_cast<float>(m_Volume+1); // update number of voxels ++m_Volume; // update bounding box for (unsigned int i = 0; i < VImageDimension; ++i) { if (currentIndex[i] < minIndex[i]) minIndex[i] = currentIndex[i]; if (currentIndex[i] > maxIndex[i]) maxIndex[i] = currentIndex[i]; } } ++iterBinaryImage; } m_MinIndexOfBoundingBox[2] = 0.0; m_MaxIndexOfBoundingBox[2] = 0.0; for (unsigned int i = 0; i < VImageDimension; ++i)
static Pointer mitk::CalculateSegmentationVolume::New | ( | void | ) | [inline, static] |
Reimplemented from mitk::SegmentationSink.
Definition at line 33 of file mitkCalculateSegmentationVolume.h.
:
bool mitk::CalculateSegmentationVolume::ReadyToRun | ( | ) | [protected, virtual] |
Reimplemented from mitk::SegmentationSink.
Definition at line 81 of file mitkCalculateSegmentationVolume.cpp.
{
bool mitk::CalculateSegmentationVolume::ThreadedUpdateFunction | ( | ) | [protected, virtual] |
Reimplemented from mitk::SegmentationSink.
Definition at line 90 of file mitkCalculateSegmentationVolume.cpp.
{ // get image Image::Pointer image; GetPointerParameter("Input", image); AccessFixedDimensionByItk( image.GetPointer(), ItkImageProcessing, 3 ); // some magic to call the correctly templated function (we only do 3D images here!) // consider single voxel volume Vector3D spacing = image->GetSlicedGeometry()->GetSpacing(); // spacing in mm float volumeML = (ScalarType) m_Volume * spacing[0] * spacing[1] * spacing[2] / 1000.0; // convert to ml DataNode* groupNode = GetGroupNode(); if (groupNode) { groupNode->SetProperty( "volume", FloatProperty::New(volumeML) ); groupNode->SetProperty( "centerOfMass", Vector3DProperty::New(m_CenterOfMass) ); groupNode->SetProperty( "boundingBoxMinimum", Vector3DProperty::New(m_MinIndexOfBoundingBox) ); groupNode->SetProperty( "boundingBoxMaximum", Vector3DProperty::New(m_MaxIndexOfBoundingBox) );