ITK  4.0.0
Insight Segmentation and Registration Toolkit
itkSimilarityIndexImageFilter.h
Go to the documentation of this file.
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 __itkSimilarityIndexImageFilter_h
00019 #define __itkSimilarityIndexImageFilter_h
00020 
00021 #include "itkImageToImageFilter.h"
00022 #include "itkNumericTraits.h"
00023 #include "itkArray.h"
00024 
00025 namespace itk
00026 {
00059 template< class TInputImage1, class TInputImage2 >
00060 class ITK_EXPORT SimilarityIndexImageFilter:
00061   public ImageToImageFilter< TInputImage1, TInputImage1 >
00062 {
00063 public:
00065   typedef SimilarityIndexImageFilter                       Self;
00066   typedef ImageToImageFilter< TInputImage1, TInputImage1 > Superclass;
00067   typedef SmartPointer< Self >                             Pointer;
00068   typedef SmartPointer< const Self >                       ConstPointer;
00069 
00071   itkNewMacro(Self);
00072 
00074   itkTypeMacro(SimilarityIndexImageFilter, ImageToImageFilter);
00075 
00077   typedef TInputImage1                        InputImage1Type;
00078   typedef TInputImage2                        InputImage2Type;
00079   typedef typename TInputImage1::Pointer      InputImage1Pointer;
00080   typedef typename TInputImage2::Pointer      InputImage2Pointer;
00081   typedef typename TInputImage1::ConstPointer InputImage1ConstPointer;
00082   typedef typename TInputImage2::ConstPointer InputImage2ConstPointer;
00083 
00084   typedef typename TInputImage1::RegionType RegionType;
00085   typedef typename TInputImage1::SizeType   SizeType;
00086   typedef typename TInputImage1::IndexType  IndexType;
00087 
00088   typedef typename TInputImage1::PixelType InputImage1PixelType;
00089   typedef typename TInputImage2::PixelType InputImage2PixelType;
00090 
00092   itkStaticConstMacro(ImageDimension, unsigned int,
00093                       TInputImage1::ImageDimension);
00094 
00096   typedef typename NumericTraits< InputImage1PixelType >::RealType RealType;
00097 
00099   void SetInput1(const InputImage1Type *image)
00100   { this->SetInput(image); }
00101 
00103   void SetInput2(const InputImage2Type *image);
00104 
00106   const InputImage1Type * GetInput1(void)
00107   { return this->GetInput(); }
00108 
00110   const InputImage2Type * GetInput2(void);
00111 
00113   itkGetConstMacro(SimilarityIndex, RealType);
00114 
00115 #ifdef ITK_USE_CONCEPT_CHECKING
00116 
00117   itkConceptMacro( Input1HasNumericTraitsCheck,
00118                    ( Concept::HasNumericTraits< InputImage1PixelType > ) );
00119   itkConceptMacro( Input2HasNumericTraitsCheck,
00120                    ( Concept::HasNumericTraits< InputImage2PixelType > ) );
00121 
00123 #endif
00124 protected:
00125   SimilarityIndexImageFilter();
00126   ~SimilarityIndexImageFilter(){}
00127   void PrintSelf(std::ostream & os, Indent indent) const;
00129 
00132   void AllocateOutputs();
00133 
00135   void BeforeThreadedGenerateData();
00136 
00139   void AfterThreadedGenerateData();
00140 
00142   void  ThreadedGenerateData(const RegionType &
00143                              outputRegionForThread,
00144                              ThreadIdType threadId);
00145 
00146   // Override since the filter needs all the data for the algorithm
00147   void GenerateInputRequestedRegion();
00148 
00149   // Override since the filter produces all of its output
00150   void EnlargeOutputRequestedRegion(DataObject *data);
00151 
00152 private:
00153   SimilarityIndexImageFilter(const Self &); //purposely not implemented
00154   void operator=(const Self &);             //purposely not implemented
00155 
00156   RealType m_SimilarityIndex;
00157 
00158   Array< SizeValueType > m_CountOfImage1;
00159   Array< SizeValueType > m_CountOfImage2;
00160   Array< SizeValueType > m_CountOfIntersection;
00161 }; // end of class
00162 } // end namespace itk
00163 
00164 #ifndef ITK_MANUAL_INSTANTIATION
00165 #include "itkSimilarityIndexImageFilter.hxx"
00166 #endif
00167 
00168 #endif
00169