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 __itkMatrixIndexSelectionImageFilter_h 00019 #define __itkMatrixIndexSelectionImageFilter_h 00020 00021 #include "itkUnaryFunctorImageFilter.h" 00022 00023 namespace itk 00024 { 00025 namespace Functor 00026 { 00027 template< class TInput, class TOutput > 00028 class MatrixIndexSelection 00029 { 00030 public: 00031 MatrixIndexSelection() { m_I = m_J = 0; } 00032 ~MatrixIndexSelection() {} 00033 00034 void GetIndices(unsigned int & i, unsigned int & j) const { i = m_I; j = m_J; } 00035 void SetIndices(unsigned int i, unsigned int j) { m_I = i; m_J = j; } 00036 00037 bool operator!=(const MatrixIndexSelection & other) const 00038 { 00039 if ( m_I != other.m_I 00040 || m_J != other.m_J ) 00041 { 00042 return true; 00043 } 00044 return false; 00045 } 00046 00047 bool operator==(const MatrixIndexSelection & other) const 00048 { 00049 return !( *this != other ); 00050 } 00051 00052 inline TOutput operator()(const TInput & A) const 00053 { 00054 return static_cast< TOutput >( A[m_I][m_J] ); 00055 } 00056 00057 private: 00058 unsigned int m_I; 00059 unsigned int m_J; 00060 }; 00061 } 00062 00080 template< class TInputImage, class TOutputImage > 00081 class ITK_EXPORT MatrixIndexSelectionImageFilter: 00082 public 00083 UnaryFunctorImageFilter< TInputImage, TOutputImage, 00084 Functor::MatrixIndexSelection< typename TInputImage::PixelType, 00085 typename TOutputImage::PixelType > > 00086 { 00087 public: 00089 typedef MatrixIndexSelectionImageFilter 00090 Self; 00091 typedef UnaryFunctorImageFilter< TInputImage, TOutputImage, 00092 Functor::MatrixIndexSelection< typename TInputImage::PixelType, 00093 typename TOutputImage::PixelType > > Superclass; 00094 typedef SmartPointer< Self > 00095 Pointer; 00096 typedef SmartPointer< const Self > 00097 ConstPointer; 00098 00100 itkTypeMacro(MatrixIndexSelectionImageFilter, UnaryFunctorImageFilter); 00101 00103 itkNewMacro(Self); 00104 00106 void SetIndices(unsigned int i, unsigned int j) 00107 { 00108 this->GetFunctor().SetIndices(i, j); 00109 this->Modified(); 00110 } 00112 00113 void GetIndices(unsigned int & i, unsigned int & j) const 00114 { return this->GetFunctor().GetIndices(i, j); } 00115 00116 #ifdef ITK_USE_CONCEPT_CHECKING 00117 00118 itkConceptMacro( InputHasNumericTraitsCheck, 00119 ( Concept::HasNumericTraits< typename TInputImage::PixelType::ValueType > ) ); 00120 00122 #endif 00123 protected: 00124 MatrixIndexSelectionImageFilter() {} 00125 virtual ~MatrixIndexSelectionImageFilter() {} 00126 private: 00127 MatrixIndexSelectionImageFilter(const Self &); //purposely not implemented 00128 void operator=(const Self &); //purposely not implemented 00129 }; 00130 } // end namespace itk 00132 00133 #endif 00134