cmtkScalarImageSimilarity.h

Go to the documentation of this file.
00001 /*
00002 //
00003 //  Copyright 2004-2010 SRI International
00004 //
00005 //  Copyright 1997-2009 Torsten Rohlfing
00006 //
00007 //  This file is part of the Computational Morphometry Toolkit.
00008 //
00009 //  http://www.nitrc.org/projects/cmtk/
00010 //
00011 //  The Computational Morphometry Toolkit is free software: you can
00012 //  redistribute it and/or modify it under the terms of the GNU General Public
00013 //  License as published by the Free Software Foundation, either version 3 of
00014 //  the License, or (at your option) any later version.
00015 //
00016 //  The Computational Morphometry Toolkit is distributed in the hope that it
00017 //  will be useful, but WITHOUT ANY WARRANTY; without even the implied
00018 //  warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019 //  GNU General Public License for more details.
00020 //
00021 //  You should have received a copy of the GNU General Public License along
00022 //  with the Computational Morphometry Toolkit.  If not, see
00023 //  <http://www.gnu.org/licenses/>.
00024 //
00025 //  $Revision: 2752 $
00026 //
00027 //  $LastChangedDate: 2011-01-17 11:33:31 -0800 (Mon, 17 Jan 2011) $
00028 //
00029 //  $LastChangedBy: torstenrohlfing $
00030 //
00031 */
00032 
00033 #ifndef __cmtkScalarImageSimilarity_h_included_
00034 #define __cmtkScalarImageSimilarity_h_included_
00035 
00036 #include <cmtkconfig.h>
00037 
00038 #include <Base/cmtkScalarImage.h>
00039 #include <Registration/cmtkTypedArraySimilarity.h>
00040 
00041 #include <vector>
00042 
00043 namespace
00044 cmtk
00045 {
00046 
00049 
00051 class ScalarImageSimilarityMemory :
00053   public TypedArraySimilarityMemory
00054 {
00055 };
00056 
00065 class ScalarImageSimilarity :
00067   public TypedArraySimilarity
00068 {
00069 public:
00071   typedef enum {
00073     MI = 0, 
00075     NMI = 1,
00077     RMI = 2,
00079     RNMI = 3,
00081     CR = 4,
00083     CC = 5,
00085     MSD = 6,
00087     PSNR = 7,
00089     DAE = 8,
00091     GradientCorrelation = 9,
00093     PatternIntensity = 10
00094   } ID;
00095   
00100   static ReturnType GetMutualInformation( const ScalarImage* image0, const ScalarImage* image1, ScalarImageSimilarityMemory *const memory = NULL );
00101 
00106   static ReturnType GetNormalizedMutualInformation( const ScalarImage* image0, const ScalarImage* image1, ScalarImageSimilarityMemory *const memory = NULL );
00107 
00109   static ReturnType GetMutualInformation( std::vector<const ScalarImage*>& array0, std::vector<const ScalarImage*>& array1, const bool normalized = false )
00110   {
00111     std::vector<const TypedArray*> data0(array0.size());
00112     std::vector<const TypedArray*> data1(array1.size());
00113     for ( size_t i = 0; i < array0.size(); ++i )
00114       {
00115       data0[i] = array0[i]->GetPixelData();
00116       }
00117     for ( size_t i = 0; i < array1.size(); ++i )
00118       {
00119       data1[i] = array1[i]->GetPixelData();
00120       } 
00121     return TypedArraySimilarity::GetMutualInformation( data0, data1, normalized );
00122   }
00123   
00125   static ReturnType GetNormalizedMutualInformation( std::vector<const ScalarImage*>& array0, std::vector<const ScalarImage*>& array1 )
00126   {
00127     return GetMutualInformation( array0, array1, true /*normalized*/ );
00128   }
00129   
00132   static ReturnType GetRegionalMutualInformation( const ScalarImage* image0, const ScalarImage* image1, const int radius = 2 );
00133 
00136   static ReturnType GetMinusMeanSquaredDifference( const ScalarImage* image0, const ScalarImage* image1 );
00137 
00141   static ReturnType GetCrossCorrelation( const ScalarImage* image0, const ScalarImage* image1 );
00142 
00146   static ReturnType GetGradientCorrelation( const ScalarImage* image0, const ScalarImage* image1 );
00147 
00151   static ReturnType GetGradientDifference( const ScalarImage* image0, const ScalarImage* image1, const ReturnType Ax = 1, const ReturnType Ay = 1 );
00152 
00156   static ReturnType GetPatternIntensity( const ScalarImage* image0, const ScalarImage* image1, const ReturnType sigma = 10, const int radius = 3 );
00157 
00161   static ReturnType GetDifferenceImageEntropy( const ScalarImage* image0, const ScalarImage* image1 );
00162 
00167   static ReturnType GetDifferenceImageEntropy( const ScalarImage* image0, const ScalarImage* image1, Types::DataItem &scaleFactor );
00168 
00169 
00173   static ReturnType GetCorrelationRatio( const ScalarImage* image0, const ScalarImage* image1 );
00174 
00176   static bool CheckImageDimensions( const ScalarImage* image0, const ScalarImage* image1 );
00177 };
00178 
00180 
00181 } // namespace cmtk
00182 
00183 #endif // #ifndef __cmtkScalarImageSimilarity_h_included_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines