freDifferenceEnergyImageToImageMetric.txx

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   F.R.E.E. - flexible registration evaluation engine
00004   Version:   v.1.0.0
00005   Date:      $Date: 2006/09/01 12:00:00 $
00006   Module:    $RCSfile: freDifferenceEnergyImageToImageMetric.txx,v $
00007   Language:  C++
00008 
00009 
00010 
00011   Copyright (c) 2007 Ralf o Floca (Department of Medical Informatics,
00012   Institute for Medical Biometry and Informatics, University of Heidelberg,
00013   Germany). All rights reserved.
00014   See FREECopyright.txt or http://www.mi.med.uni-hd.de/free/copyright.htm
00015   for details.
00016 
00017      This software is distributed WITHOUT ANY WARRANTY; without even 
00018      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00019      PURPOSE.  See the above copyright notices for more information.
00020 
00021 =========================================================================*/
00022 #ifndef __freDifferenceEnergyImageToImageMetric_txx
00023 #define __freDifferenceEnergyImageToImageMetric_txx
00024 
00025 #include "freDifferenceEnergyImageToImageMetric.h"
00026 
00027 namespace itk
00028 {
00029 template <class TFixedImage, class TMovingImage, class TDifImage>
00030   typename DifferenceEnergyImageToImageMetric<TFixedImage, TMovingImage, TDifImage>
00031   ::MeasureType
00032   DifferenceEnergyImageToImageMetric<TFixedImage, TMovingImage, TDifImage>
00033   ::EvaluateMeasure(HistogramType& histogram) const
00034   {
00035     MeasureType measure = NumericTraits<MeasureType>::Zero;
00036     HistogramIteratorType it = histogram.Begin();
00037     HistogramIteratorType end = histogram.End();
00038     HistogramFrequencyType totalFrequency = histogram.GetTotalFrequency();
00039 
00040     while (it != end)
00041       {
00042       HistogramFrequencyType freq = it.GetFrequency();
00043       if (freq > 0)
00044         {
00045         MeasureType energy = freq/totalFrequency;
00046                                 energy *= energy;
00047                                 measure += energy;
00048         }
00049       ++it;
00050       }
00051 
00052                 //negate the measure because some optimizers (e.g. can only minimize)
00053     return -1*measure;
00054   }
00055 } // End namespace itk
00056 
00057 
00058 #endif // __freDifferenceEnergyImageToImageMetric_txx

Generated at Sat Oct 13 15:47:27 2007 for f.r.e.e. - Flexible Registration and Evaluation Engine by doxygen 1.5.3 written by Dimitri van Heesch, © 1997-2000