ITK
4.1.0
Insight Segmentation and Registration Toolkit
|
00001 /*========================================================================= 00002 * 00003 * Copyright Insight Software Consortium 00004 * 00005 * Licensed under the Apache License, Version 2.0 (the "License"); 00006 * you may not use this file except in compliance with the License. 00007 * You may obtain a copy of the License at 00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.0.txt 00010 * 00011 * Unless required by applicable law or agreed to in writing, software 00012 * distributed under the License is distributed on an "AS IS" BASIS, 00013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 * See the License for the specific language governing permissions and 00015 * limitations under the License. 00016 * 00017 *=========================================================================*/ 00018 #ifndef __itkNaryMaximumImageFilter_h 00019 #define __itkNaryMaximumImageFilter_h 00020 00021 #include "itkNaryFunctorImageFilter.h" 00022 #include "itkNumericTraits.h" 00023 00024 namespace itk 00025 { 00026 namespace Functor 00027 { 00033 template< class TInput, class TOutput > 00034 class Maximum1 00035 { 00036 public: 00037 typedef typename NumericTraits< TOutput >::ValueType OutputValueType; 00038 // not sure if this typedef really makes things more clear... could just use 00039 // TOutput? 00040 00041 Maximum1() {} 00042 ~Maximum1() {} 00043 inline TOutput operator()(const std::vector< TInput > & B) const 00044 { 00045 OutputValueType A = NumericTraits< TOutput >::NonpositiveMin(); 00046 00047 for ( unsigned int i = 0; i < B.size(); i++ ) 00048 { 00049 if ( A < static_cast< OutputValueType >( B[i] ) ) 00050 { 00051 A = static_cast< OutputValueType >( B[i] ); 00052 } 00053 } 00054 return A; 00055 } 00056 00057 bool operator==(const Maximum1 &) const 00058 { 00059 return true; 00060 } 00061 00062 bool operator!=(const Maximum1 &) const 00063 { 00064 return false; 00065 } 00066 }; 00067 } 00103 template< class TInputImage, class TOutputImage > 00104 class ITK_EXPORT NaryMaximumImageFilter: 00105 public 00106 NaryFunctorImageFilter< TInputImage, TOutputImage, 00107 Functor::Maximum1< typename TInputImage::PixelType, 00108 typename TInputImage::PixelType > > 00109 { 00110 public: 00112 typedef NaryMaximumImageFilter Self; 00113 typedef NaryFunctorImageFilter< 00114 TInputImage, TOutputImage, 00115 Functor::Maximum1< typename TInputImage::PixelType, 00116 typename TInputImage::PixelType > > Superclass; 00117 00118 typedef SmartPointer< Self > Pointer; 00119 typedef SmartPointer< const Self > ConstPointer; 00120 00122 itkNewMacro(Self); 00123 00125 itkTypeMacro(NaryMaximumImageFilter, 00126 NaryFunctorImageFilter); 00127 00128 #ifdef ITK_USE_CONCEPT_CHECKING 00129 00130 itkConceptMacro( InputConvertibleToOutputCheck, 00131 ( Concept::Convertible< typename TInputImage::PixelType, 00132 typename TOutputImage::PixelType > ) ); 00133 itkConceptMacro( InputLessThanComparableCheck, 00134 ( Concept::LessThanComparable< typename TInputImage::PixelType > ) ); 00135 itkConceptMacro( InputHasNumericTraitsCheck, 00136 ( Concept::HasNumericTraits< typename TInputImage::PixelType > ) ); 00137 00139 #endif 00140 protected: 00141 NaryMaximumImageFilter() {} 00142 virtual ~NaryMaximumImageFilter() {} 00143 private: 00144 NaryMaximumImageFilter(const Self &); //purposely not implemented 00145 void operator=(const Self &); //purposely not implemented 00146 }; 00147 } // end namespace itk 00149 00150 #endif 00151