8 template <
typename TInput,
typename TOutput>
12 this->SetNthInput(0, const_cast<TInput*>(image));
15 this->SetNthInput(m_NbInputs, const_cast<TInput*>(image));
19 m_TLinksFilter->SetInputImage(i, image);
20 m_Graph3DFilter->SetInputImage(i, image);
23 template <
typename TInput,
typename TOutput>
26 this->SetNthInput(1, const_cast<TMask*>(mask));
27 m_Graph3DFilter->SetMask( mask );
30 template <
typename TInput,
typename TOutput>
33 this->SetNthInput(m_NbInputs, const_cast<TMask*>(mask));
34 m_IndexSourcesMask = m_NbInputs;
36 m_TLinksFilter->SetInputSeedSourcesMask( mask );
39 template <
typename TInput,
typename TOutput>
42 this->SetNthInput(m_NbInputs, const_cast<TMask*>(mask));
43 m_IndexSinksMask = m_NbInputs;
45 m_TLinksFilter->SetInputSeedSinksMask( mask );
49 template <
typename TInput,
typename TOutput>
52 this->SetNthInput(m_NbInputs, const_cast<TSeedProba*>(mask));
53 m_IndexSourcesProba = m_NbInputs;
55 m_TLinksFilter->SetInputSeedSourcesProba( mask );
58 template <
typename TInput,
typename TOutput>
61 this->SetNthInput(m_NbInputs, const_cast<TSeedProba*>(mask));
62 m_IndexSinksProba = m_NbInputs;
64 m_TLinksFilter->SetInputSeedSinksProba( mask );
67 template <
typename TInput,
typename TOutput>
70 return static_cast< const TMask *
> 71 ( this->itk::ProcessObject::GetInput(1) );
74 template <
typename TInput,
typename TOutput>
77 return static_cast< const TMask *
> 78 ( this->itk::ProcessObject::GetInput(m_IndexSourcesMask) );
81 template <
typename TInput,
typename TOutput>
84 return static_cast< const TMask *
> 85 ( this->itk::ProcessObject::GetInput(m_IndexSinksMask) );
88 template <
typename TInput,
typename TOutput>
92 ( this->itk::ProcessObject::GetInput(m_IndexSourcesProba) );
95 template <
typename TInput,
typename TOutput>
99 ( this->itk::ProcessObject::GetInput(m_IndexSinksProba) );
102 template <
typename TInputImage,
typename TOutput>
105 itk::DataObject::Pointer output;
110 output = ( TOutput::New() ).GetPointer();
113 output = ( TOutput::New() ).GetPointer();
116 std::cerr <<
"No output " << idx << std::endl;
120 return output.GetPointer();
123 template <
typename TInputImage,
typename TOutput>
126 return dynamic_cast< TOutput*
>( this->itk::ProcessObject::GetOutput(0) );
128 template <
typename TInputImage,
typename TOutput>
131 return dynamic_cast< TOutput*
>( this->itk::ProcessObject::GetOutput(1) );
134 template <
typename TInput,
typename TOutput>
139 if( m_OutputFilename !=
"" )
141 std::cout <<
"Writing graph cut output image to: " << m_OutputFilename << std::endl;
142 anima::writeImage<TOutput>(m_OutputFilename, this->GetOutput());
144 if( m_OutputBackgroundFilename !=
"" )
146 std::cout <<
"Writing graph cut output image to: " << m_OutputBackgroundFilename << std::endl;
147 anima::writeImage<TOutput>(m_OutputBackgroundFilename, this->GetOutputBackground());
151 template <
typename TInput,
typename TOutput>
156 std::cout <<
"Computing graph cut..." << std::endl;
158 m_TLinksFilter->SetAlpha( this->GetAlpha() );
159 m_TLinksFilter->SetMultiVarSources( this->GetMultiVarSources() );
160 m_TLinksFilter->SetMultiVarSinks( this->GetMultiVarSinks() );
161 m_TLinksFilter->SetTLinkMode( this->GetTLinkMode() );
162 m_TLinksFilter->SetVerbose( this->GetVerbose() );
163 m_TLinksFilter->SetNumberOfWorkUnits(this->GetNumberOfWorkUnits());
164 m_TLinksFilter->SetTol( m_Tol );
166 m_Graph3DFilter->SetSigma( this->GetSigma() );
167 m_Graph3DFilter->SetUseSpectralGradient( this->GetUseSpectralGradient() );
168 m_Graph3DFilter->SetMatrix( this->GetMatrix() );
169 m_Graph3DFilter->SetMatFilename( this->GetMatrixGradFilename() );
170 m_Graph3DFilter->SetVerbose( this->GetVerbose() );
171 m_Graph3DFilter->SetNumberOfWorkUnits(this->GetNumberOfWorkUnits());
172 m_Graph3DFilter->SetTol( m_Tol );
174 m_Graph3DFilter->GraftNthOutput( 0, this->GetOutput() );
175 m_Graph3DFilter->GraftNthOutput( 1, this->GetOutputBackground() );
179 m_Graph3DFilter->Update();
181 catch (itk::ExceptionObject &e)
183 std::cerr << e << std::endl;
187 this->GraftNthOutput( 0 , m_Graph3DFilter->GetOutput() );
188 this->GraftNthOutput( 1 , m_Graph3DFilter->GetOutputBackground() );
void SetInputImage(unsigned int i, const TInput *image)
itk::Image< PixelTypeD, 3 > TSeedProba
TMask::ConstPointer GetInputSeedSourcesMask()
void GenerateData() ITK_OVERRIDE
TMask::ConstPointer GetInputSeedSinksMask()
void SetInputSeedSinksProba(const TSeedProba *mask)
void SetMask(const TMask *mask)
itk::Image< PixelTypeUC, 3 > TMask
void SetInputSeedSourcesProba(const TSeedProba *mask)
void SetInputSeedSourcesMask(const TMask *mask)
TMask::ConstPointer GetMask()
void SetInputSeedSinksMask(const TMask *mask)
Class performing grah cut segmentation. First the sources and sinks probabilities maps are computed u...
TSeedProba::ConstPointer GetInputSeedSinksProba()
TSeedProba::ConstPointer GetInputSeedSourcesProba()