Medical Imaging Interaction Toolkit  2018.4.99-389bf124
Medical Imaging Interaction Toolkit
itkSmoothedClassProbabilites.cpp
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #ifndef itSmoothedClassProbabilites_cpp
14 #define itSmoothedClassProbabilites_cpp
15 
17 #include "itkObjectFactory.h"
18 #include "itkImageRegionIterator.h"
19 #include "itkImageRegionConstIterator.h"
20 #include <itkDiscreteGaussianImageFilter.h>
21 
22 
23 #include <mitkImageCast.h>
24 #include <mitkIOUtil.h>
25 
26 #include <cstdlib> /* srand, rand */
27 #include <ctime> /* time */
28 #include <sstream>
29 namespace itk
30 {
31 
32 template< class TImage>
35 {
36 
37  typename TImage::Pointer out = this->GetOutput(0);
38  out->SetRegions(this->GetInput(0)->GetLargestPossibleRegion());
39  out->Allocate();
40 
41  for(unsigned int i = 0 ; i < this->GetNumberOfInputs(); i++)
42  {
43 
44  auto gf = itk::DiscreteGaussianImageFilter<TImage,TImage>::New();
45  gf->SetInput(this->GetInput(i));
46  gf->SetVariance(this->m_Sigma);
47  gf->Update();
48 
49  ImageRegionConstIterator<TImage> git(gf->GetOutput(),gf->GetOutput()->GetLargestPossibleRegion());
50  ImageRegionIterator<TImage> maskiter(m_MaskImage, m_MaskImage->GetLargestPossibleRegion());
51  ImageRegionIterator<TImage> outputIter(out, out->GetLargestPossibleRegion());
52 
53  while (!outputIter.IsAtEnd())
54  {
55  if(maskiter.Value() > 0 ){
56 
57  if(git.Value() > outputIter.Value())
58  outputIter.Set(i);
59  }else
60  {
61  outputIter.Set(0);
62  }
63 
64  ++git;
65  ++outputIter;
66  ++maskiter;
67  }
68  }
69 
70 
71 
72 
73 
74 
75 }
76 
77 }// end namespace
78 
79 #endif // itSmoothedClassProbabilites_cpp