zxhproj v 2.2
zxhproj

zxhValidation.h

00001 
00002 /*=========================================================================
00003 
00004   Program:   ZXH Registration Software
00005   Author:    Xiahai Zhuang
00006   Module:    $RCSfle: zxhValidation.h    $
00007   Language:  C++
00008   Date:      $Date: From  2004-01 $
00009   Version:   $Revision: 1.0, 2.0 $
00010 
00011 =========================================================================*/
00012 #ifndef zxhValidation_h
00013 #define zxhValidation_h
00014 
00015 #include <iostream>
00016 #include <fstream>
00017 #include <math.h>
00018 
00019 #include "zxhDllExport.h"
00020 #include "zxh.h"
00021 #include "zxhImageData.h"
00022 #include "zxhImageGipl.h"
00023 #include "zxhImageModelingLinear.h"
00024 #include "zxhTransformAffine.h"
00025 #include "zxhTransformFFD.h"
00026 #include "zxhImageModelingBase.h"
00027 
00028 #ifndef max_of_distance
00029 #define max_of_distance 100  // voxels
00030 #endif
00031 #ifndef start_of_distance
00032 #define start_of_distance 2 //  radius of searchingvolume
00033 #endif
00034 #ifndef max_of_graylevel_short
00035 #define max_of_graylevel_short 0x7fff
00036 #endif
00037 #ifndef ZXH_GrayLevelOfSurface
00038 #define ZXH_GrayLevelOfSurface 1
00039 #endif
00040 namespace zxh{
00041 
00043 ZXH_DLL_EXPORT void Seg2Binf(zxhImageData* seg,zxhImageDataT<float> *bin);
00046 ZXH_DLL_EXPORT void Binf2Sur(zxhImageDataT<float>*bin, zxhImageData*sur);
00048 ZXH_DLL_EXPORT void TransformImageInverseByDeformField(zxhImageDataT<float>*pInvImg,zxhImageModelingLinearT<float,float>*pRef,
00049                                                        zxhImageDataT<float>*pDef[ImageDimensionMax]);
00051 ZXH_DLL_EXPORT std::string ComputeRealError(zxhImageData*pTest, zxhTransformBase* pGold, zxhTransformBase* pTrans,
00052                              int iSaveMedial,std::string strSavePathName,zxhImageData*pMask=0);
00054 //ZXH_DLL_EXPORT std::string ComputeRealError(zxhImageData*pTest,zxhImageDataT<float>*pGold[ImageDimensionMax],
00055 //                                          zxhImageDataT<float>*pDeform[ImageDimensionMax],
00056 //                           int iSaveMedial,std::string strSavePathName,zxhImageData*pMask=0);
00058 ZXH_DLL_EXPORT std::string ComputeInconsistency(zxhImageData*pTest,zxhTransformBase*pTest2Ref,zxhTransformBase*pRef2Test,
00059                                  int iSaveMedial,std::string strSavePathName,zxhImageData*pMask=0);
00061 ZXH_DLL_EXPORT std::string ComputeDeformField(zxhImageData*pTest,zxhImageDataT<float>*pDeformMag,zxhImageData*pMask);
00063 ZXH_DLL_EXPORT std::string ComputeDeformField(zxhImageData*pTest,zxhTransformBase*pTest2Ref,
00064                                  int iSaveMedial,std::string strSavePathName,zxhImageData*pMask=0);
00066 ZXH_DLL_EXPORT std::string ComputeDeformField(zxhImageData*pTest,zxhImageDataT<float>*pDeform[ImageDimensionMax],
00067                                  int iSaveMedial,std::string strSavePathName,zxhImageData*pMask=0);
00068 
00070 ZXH_DLL_EXPORT bool ComputeSurfaceDistance(zxhImageData*pSurTest,zxhImageData*pSurRef,zxhTransformBase*pTrans,
00071         zxhlfloat &fsum, zxhlfloat &fsqsum, zxhlfloat &fmax, zxhlfloat &fmin, zxhlfloat &nTestSurface,
00072         zxhlfloat errorrange[6], zxhImageDataT<float> * pdis_mag ) ;
00074 ZXH_DLL_EXPORT std::string ComputeSurfaceDistance(zxhImageData*pSurTest,zxhImageData*pSurRef,
00075         zxhTransformBase*pTrans,int iSaveMedial,std::string strSaveFileName);
00076 
00078 ZXH_DLL_EXPORT std::string ComputeSurfaceDistanceClostPoint(zxhImageData*pSurTest,zxhImageData*pSurRef,
00079         zxhTransformBase*pTrans,int iSaveMedial,std::string strSaveFileName) ;
00081 ZXH_DLL_EXPORT std::string ComputeSurfaceDistanceSwap(zxhImageData* apSurTest[2],zxhImageData* apSurRef[2] );
00085 ZXH_DLL_EXPORT float ComputeOverlap(zxhImageDataT<float>*pBinTest,zxhImageDataT<float>*pBinRef,zxhTransformBase*pTrans);
00087 ZXH_DLL_EXPORT float ComputeOverlap(zxhImageDataT<float>*pBinTest,zxhImageDataT<float>*pBinRef,zxhImageDataT<float>*pDeform[ImageDimensionMax]);
00088 
00090 zxhlfloat DisPnt2Triangle(zxhlfloat pnt[3],zxhlfloat pTr1[3],zxhlfloat pTr2[3],zxhlfloat pTr3[3]) ;
00091 float DisPnt2Triangle(float pnt[3],float pTr1[3],float pTr2[3],float pTr3[3]) ;
00092 
00094 zxhlfloat VOPDistance(int dim,const zxhlfloat* A, const zxhlfloat* B);
00096 void VOPCrossProduct( const zxhlfloat* A, const zxhlfloat* B, zxhlfloat* AxB );
00098 zxhlfloat VOPDotProduct(int dim,const zxhlfloat* A,const zxhlfloat* B);
00100 zxhlfloat VOPVectorLength(int dim,const zxhlfloat* A);
00101 
00103 template <class imagevoxel>
00104 void SelectRoi(zxhImageDataT<imagevoxel>*pImg,const int pFrom[3],const int pTo[3])
00105 {
00106     for(int it=0;it<pImg->GetImageSize()[3];++it)
00107     for(int ix=0;ix<pImg->GetImageSize()[0];++ix)
00108     for(int iy=0;iy<pImg->GetImageSize()[1];++iy)
00109     for(int iz=0;iz<pImg->GetImageSize()[2];++iz)
00110     {
00111         if(!(ix>=pFrom[0]&&ix<=pTo[0]&&
00112             iy>=pFrom[1]&&iy<=pTo[1]&&
00113             iz>=pFrom[2]&&iz<=pTo[2]))
00114             pImg->SetPixelByGreyscale(ix,iy,iz,it,0);
00115     }
00116 };
00117 
00118 struct surface_point
00119 {
00120     float   fx;
00121     float   fy;
00122     float   fz;
00123     float   ft;
00124     float           fDistance;
00125     int             nNumber;
00126     surface_point   *       pNext;
00127 };
00128 
00130 template<class type>
00131 void NewMedialImage(zxhImageDataT<type>*pTem,zxhImageDataT<float>*pDim,zxhImageDataT<float>*pMag)
00132 {
00133     for(int idim=0;idim<pTem->GetDimension();++idim)
00134     {
00135         pDim[idim].NewImage(pTem->GetDimension(),pTem->GetImageSize(),pTem->GetImageSpacing(),pTem->GetImageInfo() );
00136     }
00137     pMag->NewImage(pTem->GetDimension(),pTem->GetImageSize(),pTem->GetImageSpacing(),pTem->GetImageInfo() );
00138 }
00139 
00140 
00141 
00142 }//endof namespace zxh
00143 
00144 #endif //zxhValidation_h
 All Classes Namespaces Functions Variables Typedefs