17 #include <itkLinearInterpolateImageFunction.h>
18 #include <itkNearestNeighborInterpolateImageFunction.h>
19 #include <itkPolyLineParametricPath.h>
20 #include <itkWindowedSincInterpolateImageFunction.h>
31 switch (image->GetDimension())
56 itk::PolyLineParametricPath<3>::InputType input = path->StartOfInput();
58 const PixelType pixelType = image->GetPixelType();
60 IntensityProfile::MeasurementVectorType measurementVector;
61 itk::PolyLineParametricPath<3>::OffsetType
offset;
67 imageGeometry->
IndexToWorld(path->Evaluate(input), worldPoint);
71 intensityProfile->PushBack(measurementVector);
73 offset = path->IncrementInput(input);
74 }
while ((offset[0] | offset[1] | offset[2]) != 0);
76 return intensityProfile;
79 template <
class TInputImage>
91 return itk::WindowedSincInterpolateImageFunction<TInputImage, 3, itk::Function::BlackmanWindowFunction<3> >
::New().GetPointer();
94 return itk::WindowedSincInterpolateImageFunction<TInputImage, 4, itk::Function::BlackmanWindowFunction<4> >
::New().GetPointer();
97 return itk::WindowedSincInterpolateImageFunction<TInputImage, 5, itk::Function::BlackmanWindowFunction<5> >
::New().GetPointer();
100 return itk::WindowedSincInterpolateImageFunction<TInputImage, 3, itk::Function::CosineWindowFunction<3> >
::New().GetPointer();
103 return itk::WindowedSincInterpolateImageFunction<TInputImage, 4, itk::Function::CosineWindowFunction<4> >
::New().GetPointer();
106 return itk::WindowedSincInterpolateImageFunction<TInputImage, 5, itk::Function::CosineWindowFunction<5> >
::New().GetPointer();
109 return itk::WindowedSincInterpolateImageFunction<TInputImage, 3, itk::Function::HammingWindowFunction<3> >
::New().GetPointer();
112 return itk::WindowedSincInterpolateImageFunction<TInputImage, 4, itk::Function::HammingWindowFunction<4> >
::New().GetPointer();
115 return itk::WindowedSincInterpolateImageFunction<TInputImage, 5, itk::Function::HammingWindowFunction<5> >
::New().GetPointer();
118 return itk::WindowedSincInterpolateImageFunction<TInputImage, 3, itk::Function::LanczosWindowFunction<3> >
::New().GetPointer();
121 return itk::WindowedSincInterpolateImageFunction<TInputImage, 4, itk::Function::LanczosWindowFunction<4> >
::New().GetPointer();
124 return itk::WindowedSincInterpolateImageFunction<TInputImage, 5, itk::Function::LanczosWindowFunction<5> >
::New().GetPointer();
127 return itk::WindowedSincInterpolateImageFunction<TInputImage, 3, itk::Function::WelchWindowFunction<3> >
::New().GetPointer();
130 return itk::WindowedSincInterpolateImageFunction<TInputImage, 4, itk::Function::WelchWindowFunction<4> >
::New().GetPointer();
133 return itk::WindowedSincInterpolateImageFunction<TInputImage, 5, itk::Function::WelchWindowFunction<5> >
::New().GetPointer();
140 template <
class TPixel,
unsigned int VImageDimension>
143 typename itk::InterpolateImageFunction<itk::Image<TPixel, VImageDimension> >
::Pointer interpolateImageFunction = CreateInterpolateImageFunction<itk::Image<TPixel, VImageDimension> >(interpolator);
144 interpolateImageFunction->SetInputImage(image);
146 const itk::PolyLineParametricPath<3>::InputType startOfInput = path->StartOfInput();
147 const itk::PolyLineParametricPath<3>::InputType delta = 1.0 / (numSamples - 1);
149 IntensityProfile::MeasurementVectorType measurementVector;
151 for (
unsigned int i = 0; i < numSamples; ++i)
153 measurementVector[0] = interpolateImageFunction->EvaluateAtContinuousIndex(path->Evaluate(startOfInput + i * delta));
154 intensityProfile->PushBack(measurementVector);
162 return intensityProfile;
165 class AddPolyLineElementToPath
169 : m_PlanarFigureGeometry(planarFigureGeometry),
170 m_ImageGeometry(imageGeometry),
177 m_PlanarFigureGeometry->Map(polyLineElement, m_WorldPoint);
178 m_ImageGeometry->WorldToIndex(m_WorldPoint, m_ContinuousIndexPoint);
179 m_Vertex.CastFrom(m_ContinuousIndexPoint);
180 m_Path->AddVertex(m_Vertex);
189 Point3D m_ContinuousIndexPoint;
190 itk::PolyLineParametricPath<3>::ContinuousIndexType m_Vertex;
198 std::for_each(polyLine.begin(), polyLine.end(),
199 AddPolyLineElementToPath(planarFigure->
GetPlaneGeometry(), imageGeometry, path));
207 imageGeometry->
WorldToIndex(point, continuousIndexPoint);
209 itk::PolyLineParametricPath<3>::ContinuousIndexType vertex;
210 vertex.CastFrom(continuousIndexPoint);
212 path->AddVertex(vertex);
243 IntensityProfile::InstanceIdentifier maxIndex = 0;
245 IntensityProfile::ConstIterator end = intensityProfile->End();
246 IntensityProfile::MeasurementType measurement;
248 for (IntensityProfile::ConstIterator it = intensityProfile->Begin(); it != end; ++it)
250 measurement = it.GetMeasurementVector()[0];
252 if (measurement > max)
255 maxIndex = it.GetInstanceIdentifier();
265 IntensityProfile::InstanceIdentifier minIndex = 0;
267 IntensityProfile::ConstIterator end = intensityProfile->End();
268 IntensityProfile::MeasurementType measurement;
270 for (IntensityProfile::ConstIterator it = intensityProfile->Begin(); it != end; ++it)
272 measurement = it.GetMeasurementVector()[0];
274 if (measurement < min)
277 minIndex = it.GetInstanceIdentifier();
287 IntensityProfile::MeasurementType
min;
289 const IntensityProfile::InstanceIdentifier areaWidth = 1 + 2 * radius;
291 IntensityProfile::MeasurementType maxArea = 0;
293 for (IntensityProfile::InstanceIdentifier i = 0; i < areaWidth; ++i)
294 maxArea += intensityProfile->GetMeasurementVector(i)[0] -
min;
296 const IntensityProfile::InstanceIdentifier lastIndex = intensityProfile->Size() - areaWidth;
297 IntensityProfile::InstanceIdentifier centerOfMaxArea = radius;
298 IntensityProfile::MeasurementType area = maxArea;
300 for (IntensityProfile::InstanceIdentifier i = 1; i <= lastIndex; ++i)
302 area += intensityProfile->GetMeasurementVector(i + areaWidth - 1)[0] -
min;
303 area -= intensityProfile->GetMeasurementVector(i - 1)[0] -
min;
308 centerOfMaxArea = i + radius;
312 return centerOfMaxArea;
317 std::vector<IntensityProfile::MeasurementType> result;
318 result.reserve(intensityProfile->Size());
320 IntensityProfile::ConstIterator end = intensityProfile->End();
322 for (IntensityProfile::ConstIterator it = intensityProfile->Begin(); it != end; ++it)
323 result.push_back(it.GetMeasurementVector()[0]);
330 const IntensityProfile::InstanceIdentifier size = vector.size();
333 result->Resize(size);
335 for (IntensityProfile::InstanceIdentifier i = 0; i < size; ++i)
336 result->SetMeasurement(i, 0, vector[i]);
343 typedef std::vector<IntensityProfile::MeasurementType> StatsVecType;
347 IntensityProfile::MeasurementType
min;
348 IntensityProfile::MeasurementType
max;
351 StatsVecType::size_type numSamples = statsVec.size();
355 for ( StatsVecType::const_iterator it = statsVec.begin(); it != statsVec.end(); ++it )
365 for ( StatsVecType::const_iterator it = statsVec.begin(); it != statsVec.end(); ++it )
367 double diff = *it - mean;
370 var /= ( numSamples - 1 );
374 stats->SetMin( static_cast<double>( min ) );
375 stats->SetMax( static_cast<double>( max ) );
376 stats->SetN( numSamples );
377 stats->SetMean( mean );
378 stats->SetVariance( var );
379 stats->SetRMS( rms );
MITKIMAGESTATISTICS_EXPORT IntensityProfile::InstanceIdentifier ComputeCenterOfMaximumArea(IntensityProfile::Pointer intensityProfile, IntensityProfile::InstanceIdentifier radius)
Compute center of maximum area under the curve of an intensity profile.
MITKIMAGESTATISTICS_EXPORT IntensityProfile::InstanceIdentifier ComputeGlobalMaximum(IntensityProfile::Pointer intensityProfile, IntensityProfile::MeasurementType &max)
Compute global maximum of an intensity profile.
itk::SmartPointer< Self > Pointer
Gives locked and index-based read access for a particular image part. The class provides several set-...
const TPixel & GetPixelByIndex(const itk::Index< VDimension > &idx) const
MITKIMAGESTATISTICS_EXPORT IntensityProfile::Pointer ComputeIntensityProfile(Image::Pointer image, PlanarFigure::Pointer planarFigure)
Compute intensity profile of an image for each pixel along the first PolyLine of a given planar figur...
#define AccessFixedDimensionByItk_n(mitkImage, itkImageTypeFunction, dimension, va_tuple)
Access a mitk-image with known dimension by an itk-image with one or more parameters.
static IntensityProfile::Pointer ComputeIntensityProfile(Image::Pointer image, itk::PolyLineParametricPath< 3 >::Pointer path)
static itk::PolyLineParametricPath< 3 >::Pointer CreatePathFromPlanarFigure(BaseGeometry *imageGeometry, PlanarFigure *planarFigure)
DataCollection - Class to facilitate loading/accessing structured data.
itk::SmartPointer< Self > Pointer
MITKIMAGESTATISTICS_EXPORT IntensityProfile::InstanceIdentifier ComputeGlobalMinimum(IntensityProfile::Pointer intensityProfile, IntensityProfile::MeasurementType &min)
Compute global minimum of an intensity profile.
static void AddPointToPath(const BaseGeometry *imageGeometry, const Point3D &point, itk::PolyLineParametricPath< 3 >::Pointer path)
static itk::PolyLineParametricPath< 3 >::Pointer CreatePathFromPoints(BaseGeometry *imageGeometry, const Point3D &startPoint, const Point3D &endPoint)
#define mitkPixelTypeMultiplex3(function, ptype, param1, param2, param3)
MITKIMAGESTATISTICS_EXPORT IntensityProfile::Pointer CreateIntensityProfileFromVector(const std::vector< IntensityProfile::MeasurementType > &vector)
Convert a standard library vector to an intensity profile.
void IndexToWorld(const mitk::Vector3D &vec_units, mitk::Vector3D &vec_mm) const
Convert (continuous or discrete) index coordinates of a vector vec_units to world coordinates (in mm)...
MITKIMAGESTATISTICS_EXPORT void ComputeIntensityProfileStatistics(IntensityProfile::Pointer intensityProfile, ImageStatisticsCalculator::StatisticsContainer::Pointer stats)
Compute statistics of an intensity profile.
Describes a two-dimensional, rectangular plane.
static void ReadPixel(const PixelType &, Image::Pointer image, const itk::Index< 3 > &index, ScalarType *returnValue)
static itk::InterpolateImageFunction< TInputImage >::Pointer CreateInterpolateImageFunction(InterpolateImageFunction::Enum interpolator)
MITKIMAGESTATISTICS_EXPORT std::vector< IntensityProfile::MeasurementType > CreateVectorFromIntensityProfile(IntensityProfile::Pointer intensityProfile)
Convert an intensity profile to a standard library vector.
BaseGeometry Describes the geometry of a data object.
Class for defining the data type of pixels.
void WorldToIndex(const mitk::Point3D &pt_mm, mitk::Point3D &pt_units) const
Convert world coordinates (in mm) of a point to (continuous!) index coordinates.
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.