cmtkImageSymmetryPlaneFunctionalDevice.cxx

Go to the documentation of this file.
00001 /*
00002 //
00003 //  Copyright 1997-2009 Torsten Rohlfing
00004 //
00005 //  Copyright 2004-2010 SRI International
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: 2568 $
00026 //
00027 //  $LastChangedDate: 2010-11-29 15:08:37 -0800 (Mon, 29 Nov 2010) $
00028 //
00029 //  $LastChangedBy: torstenrohlfing $
00030 //
00031 */
00032 
00033 #include "cmtkImageSymmetryPlaneFunctionalDevice.h"
00034 
00035 #include <GPU/cmtkImagePairAffineRegistrationFunctionalDevice_kernels.h>
00036 
00037 namespace
00038 cmtk
00039 {
00040 
00043 
00044 ImageSymmetryPlaneFunctionalDevice::ImageSymmetryPlaneFunctionalDevice
00045 ( UniformVolume::SmartConstPtr& volume ) 
00046   : ImageSymmetryPlaneFunctionalBase( volume ),
00047     m_VolumeOnDevice( DeviceUniformVolumeArray::Create( *(this->m_Volume) ) )
00048 {
00049 }
00050 
00051 ImageSymmetryPlaneFunctionalDevice::ImageSymmetryPlaneFunctionalDevice
00052 ( UniformVolume::SmartConstPtr& volume, 
00053   const Types::DataItemRange& valueRange )
00054   : ImageSymmetryPlaneFunctionalBase( volume, valueRange ),
00055     m_VolumeOnDevice( DeviceUniformVolumeArray::Create( *(this->m_Volume) ) )
00056 {
00057 }
00058 
00059 ImageSymmetryPlaneFunctionalDevice::ReturnType
00060 ImageSymmetryPlaneFunctionalDevice::Evaluate()
00061 {
00062   const AffineXform::MatrixType mirrorMatrix = this->m_ParametricPlane.GetMirrorXformMatrix();
00063 
00064   float matrix[4][4];
00065   for ( size_t j = 0; j < 4; ++j )
00066     {
00067     for ( size_t i = 0; i < 4; ++i )
00068       {
00069       matrix[j][i] = static_cast<float>( mirrorMatrix[j][i] );
00070       }
00071     }
00072 
00073   FixedVector<3,float> deltas = this->m_Volume->Deltas();
00074 
00075   // multiply deltas for index-to-image space conversion
00076   for ( size_t j = 0; j < 3; ++j )
00077     {
00078     for ( size_t i = 0; i < 3; ++i )
00079       {
00080       matrix[j][i] *= deltas[j];
00081       }
00082     }
00083 
00084   // divide by size to get to normalized image coordinates after mirror
00085   for ( size_t j = 0; j < 4; ++j ) // here, need to run up to 3 because translation is also in output space
00086     {
00087     for ( size_t i = 0; i < 3; ++i )
00088       {
00089       matrix[j][i] /= this->m_Volume->Size[i];
00090       }
00091     }
00092   
00093   return -ImagePairAffineRegistrationFunctionalDeviceEvaluateMSD( this->m_Volume->m_Dims.begin(), this->m_VolumeOnDevice->GetDeviceArrayPtr()->GetArrayOnDevice(), 
00094                                                                   this->m_Volume->m_Dims.begin(), this->m_VolumeOnDevice->GetDeviceArrayPtr()->GetArrayOnDevice(), matrix );
00095 }
00096 
00097 } // namespace cmtk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines