ZTrackerTransform.h

Go to the documentation of this file.
00001 /*=auto========================================================================
00002 
00003   (c) Copyright 2006 Brigham and Women's Hospital (BWH) All Rights Reserved.
00004 
00005   Project:    ZTrackerTransform
00006   Author:     Simon DiMaio, simond@bwh.harvard.edu
00007   Version:    $Id: ZTrackerTransform.h,v 1.8 2007/01/17 12:44:08 simond Exp $
00008 
00009 =========================================================================auto=*/
00010 // .NAME ZTrackerTransform
00011 // .SECTION Description
00012 // OpenTracker transformation node for computing the position and orientation
00013 // of a fiducial frame relative to a stream of incoming images.
00014 
00015 
00016 /*= INCLUDE ==================================================================*/
00017 
00018 #ifndef _ZTRACKERTRANSFORM_H
00019 #define _ZTRACKERTRANSFORM_H
00020 
00021 #include <OpenTracker/OpenTracker.h>
00022 #include <OpenTracker/dllinclude.h>
00023 #include <OpenTracker/input/ZLinAlg.h>
00024 //#include <OpenTracker/input/ZLogger.h>
00025 #include <newmat/newmat.h>
00026 
00027 
00028 /*= DEFINE ===================================================================*/
00029 
00030 #define FORCE_SIZEX     256
00031 #define FORCE_SIZEY     256
00032 #define FORCE_FOV       160.0
00033 #define MEPSILON        (1e-10)
00034 
00035 
00036 /*= NAME SPACE ===============================================================*/
00037 
00038 namespace ot {
00039 
00040 
00041 /*= CLASSES ==================================================================*/
00042 
00043   class OPENTRACKER_API ZTrackerTransform : public Node
00044   {
00045     public: 
00046       // Constructor Method.
00047       ZTrackerTransform(int xsize, int ysize);
00048 
00049     public:
00053       virtual int isEventGenerator()
00054       {
00055           return 1;
00056       }
00057 
00058       // Method called by an SPL-OpenTracker child node.
00059       virtual void onEventGenerated( Event& event, Node & generator);
00060 
00061       friend class CommonNodeFactory;
00062 
00063     private:
00064       short  *InputImage;
00065       int    imgxsize;
00066       int    imgysize;
00067 
00068       Matrix SourceImage, MaskImage;
00069       Matrix IFreal, IFimag, MFreal, MFimag, zeroimag;
00070       Matrix PFreal, PFimag;
00071       Matrix PIreal, PIimag;
00072 
00073       // Methods related to finding the fiducial artifacts in the MR images.
00074       void LocateFiducials(Matrix &image, int xsize, int ysize, 
00075                            int Zcoordinates[7][2]);
00076       void FindFidCentre(int points[7][2], int &rmid, int &cmid);
00077       void FindFidCorners(int points[7][2], int *pmid);
00078       void OrderFidPoints(int points[7][2], int rmid, int cmid);
00079 
00080       // Methods related to solving for the frame pose w.r.t. the imaging plane.
00081       void LocalizeFrame(float Zcoordinates[7][2], Column3Vector &Zposition,
00082                          Quaternion &Zorientation);
00083       void SolveZ(Column3Vector P1, Column3Vector P2, Column3Vector P3,
00084                   Column3Vector Oz, Column3Vector Vz, Column3Vector &P2f);
00085 
00086       // Method for computing the imaging plane update.
00087       void Update_Scan_Plane(Column3Vector &pcurrent, Quaternion &ocurrent,
00088                              Column3Vector Zposition, Quaternion Zorientation);
00089 
00090       // Methods for finding matrix maxima.
00091       Real ComplexMax(Matrix &realmat, Matrix &imagmat);
00092       Real RealMax(Matrix &realmat);
00093       Real FindMax(Matrix &inmatrix, int &row, int &col);
00094 
00095       float CoordDistance(int *p1, int *p2);
00096   };
00097 
00098 } // namespace ot
00099 
00100 #endif
00101 
00102 /*= END ZTrackerTransform.h ==================================================*/

Generated on Wed Feb 28 15:18:50 2007 for NaviTrack by  doxygen 1.4.6