1 /*========================================================================= 2 * 3 * Copyright Insight Software Consortium 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0.txt 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 * 17 *=========================================================================*/ 18 #include "itkKLMSegmentationBorder.h" 19 20 namespace itk 21 { 22 KLMSegmentationBorder KLMSegmentationBorder()23::KLMSegmentationBorder() 24 { 25 m_Lambda = 0.0; 26 m_Region1 = nullptr; 27 m_Region2 = nullptr; 28 } 29 30 KLMSegmentationBorder 31 ::~KLMSegmentationBorder() = default; 32 33 /** 34 * PrintSelf 35 */ 36 void 37 KLMSegmentationBorder PrintSelf(std::ostream & os,Indent indent) const38::PrintSelf(std::ostream & os, Indent indent) const 39 { 40 Superclass::PrintSelf(os, indent); 41 os << indent << "Lambda = " << m_Lambda << std::endl; 42 os << indent << "Region1 = " << m_Region1 << std::endl; 43 os << indent << "Region2 = " << m_Region2 << std::endl; 44 } // end PrintSelf 45 46 void 47 KLMSegmentationBorder SetRegion1(KLMSegmentationRegion * Region1)48::SetRegion1(KLMSegmentationRegion *Region1) 49 { 50 m_Region1 = Region1; 51 } // end SetRegion1 52 53 KLMSegmentationRegion * 54 KLMSegmentationBorder GetRegion1()55::GetRegion1() 56 { 57 return m_Region1; 58 } // end GetRegion2 59 60 void 61 KLMSegmentationBorder SetRegion2(KLMSegmentationRegion * Region2)62::SetRegion2(KLMSegmentationRegion *Region2) 63 { 64 m_Region2 = Region2; 65 } // end SetRegion2 66 67 KLMSegmentationRegion * 68 KLMSegmentationBorder GetRegion2()69::GetRegion2() 70 { 71 return m_Region2; 72 } // end GetRegion2 73 74 void 75 KLMSegmentationBorder EvaluateLambda()76::EvaluateLambda() 77 { 78 m_Lambda = m_Region1->EnergyFunctional(m_Region2) / this->GetBorderLength(); 79 } // end EvaluateLambda() 80 81 void 82 KLMSegmentationBorder PrintBorderInfo()83::PrintBorderInfo() 84 { 85 itkDebugMacro(<< "------------------------------"); 86 itkDebugMacro(<< "Location : " << this); 87 itkDebugMacro(<< "Lambda : " << m_Lambda); 88 itkDebugMacro( << "Region1 : " << this->GetRegion1() ); 89 itkDebugMacro( << "Region 1 Label: " << ( this->GetRegion1()->GetRegionLabel() ) ); 90 itkDebugMacro( << "Region2 : " << this->GetRegion2() ); 91 itkDebugMacro( << "Region 2 Label: " << ( this->GetRegion2()->GetRegionLabel() ) ); 92 itkDebugMacro(<< "++++++++++++++++++++++++++++++"); 93 itkDebugMacro(<< "------------------------------"); 94 itkDebugMacro(<< "------------------------------"); 95 96 std::cout << "Location : " << this << std::endl; 97 std::cout << "Lambda : " << m_Lambda << std::endl; 98 } 99 } // namespace itk 100