Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
itkFieldmapGeneratorFilter.cpp
Go to the documentation of this file.
1 /*===================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Coindex[1]right (c) German Cancer Research Center,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
17 
18 #include <itkImageRegionIterator.h>
19 #include <math.h>
20 #include <itkPoint.h>
21 
22 namespace itk{
23 
24 template< class OutputImageType >
26 {
27  m_Gradient.fill(0.0);
28  m_Offset.fill(0.0);
29 }
30 
31 template< class OutputImageType >
33 {
34 }
35 
36 template< class OutputImageType >
38 {
39  typename OutputImageType::Pointer outImage = OutputImageType::New();
40  outImage->SetSpacing( m_Spacing );
41  outImage->SetOrigin( m_Origin );
42  outImage->SetDirection( m_DirectionMatrix );
43  outImage->SetLargestPossibleRegion( m_ImageRegion );
44  outImage->SetBufferedRegion( m_ImageRegion );
45  outImage->SetRequestedRegion( m_ImageRegion );
46  outImage->Allocate();
47  outImage->FillBuffer(0);
48  this->SetNthOutput(0, outImage);
49 }
50 
51 template< class OutputImageType >
52 void FieldmapGeneratorFilter< OutputImageType >::ThreadedGenerateData( const OutputImageRegionType &outputRegionForThread, ThreadIdType threadId)
53 {
54  typename OutputImageType::Pointer outImage = static_cast< OutputImageType * >(this->ProcessObject::GetOutput(0));
55  ImageRegionIterator< OutputImageType > oit(outImage, outputRegionForThread);
56 
57  while( !oit.IsAtEnd() )
58  {
59  double value = 0;
60  IndexType idx = oit.GetIndex();
61  for (int i=0; i<3; i++)
62  value += idx[i]*m_Gradient[i] + m_Offset[i];
63 
64  for (unsigned int i=0; i<m_WorldPositions.size(); i++)
65  {
66  mitk::Point3D c = m_WorldPositions.at(i);
67  itk::Point<double, 3> vertex;
68  outImage->TransformIndexToPhysicalPoint(idx, vertex);
69  double dist = c.EuclideanDistanceTo(vertex);
70  value += m_Heights.at(i)*exp(-dist*dist/(2*m_Variances.at(i)));
71  }
72  oit.Set(value);
73  ++oit;
74  }
75 
76  MITK_INFO << "Thread " << threadId << "finished processing";
77 }
78 
79 }
itk::SmartPointer< Self > Pointer
#define MITK_INFO
Definition: mitkLogMacros.h:22
OutputImageType::IndexType IndexType
void ThreadedGenerateData(const OutputImageRegionType &outputRegionForThread, ThreadIdType threadId)
itk::ImageRegion< 3 > OutputImageRegionType
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.