cmtkVolumeFromSlices.h

Go to the documentation of this file.
00001 /*
00002 //
00003 //  Copyright 1997-2009 Torsten Rohlfing
00004 //
00005 //  Copyright 2004-2011 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: 2752 $
00026 //
00027 //  $LastChangedDate: 2011-01-17 11:33:31 -0800 (Mon, 17 Jan 2011) $
00028 //
00029 //  $LastChangedBy: torstenrohlfing $
00030 //
00031 */
00032 
00037 #ifndef __cmtkVolumeFromSlices_h_included_
00038 #define __cmtkVolumeFromSlices_h_included_
00039 
00040 #include <cmtkconfig.h>
00041 
00042 #include <Base/cmtkTypes.h>
00043 #include <Base/cmtkVolume.h>
00044 #include <Base/cmtkUniformVolume.h>
00045 #include <Base/cmtkScalarImage.h>
00046 
00047 #include <stdio.h>
00048 
00052 
00053 #define CMTK_MAX_CALIB_ERROR 1e-5
00054 
00060 #define CMTK_MAX_ANGLE_ERROR 1e-3
00061 
00066 #define CMTK_MAX_LOCALIZE_ERROR 1e-2
00067 
00068 
00069 namespace
00070 cmtk
00071 {
00072 
00075 
00077 class VolumeFromSlices 
00078 {
00079 public:
00081   VolumeFromSlices() : VolumeDataArray( NULL ) {}
00082 
00084   virtual ~VolumeFromSlices() {}
00085 
00086 protected:
00089   void InitSequence( const ScalarImage* image, const unsigned int numberOfSlices );
00090 
00093   virtual char* AllocDataArray( const int bytesperpixel, const int data_size ) const;
00094 
00099   virtual TypedArray::SmartPtr EncapDataArray( const ScalarDataType dtype, void *const data, const int data_size ) const;
00100   
00106   const char* FillPlane ( unsigned int& plane, const ScalarImage* image );
00107 
00118   UniformVolume::SmartPtr FinishVolume( Types::Coordinate& sliceOffset, int& sliceDirection );
00119 
00124   UniformVolume::SmartPtr FinishVolume () 
00125   {
00126     Types::Coordinate dummy_c;
00127     int dummy_i;
00128     
00129     return FinishVolume( dummy_c, dummy_i );
00130   }
00131   
00154   virtual UniformVolume::SmartPtr ConstructVolume( const DataGrid::IndexType& Dims, const UniformVolume::CoordinateVectorType& Size, const Types::Coordinate *Points[3], TypedArray::SmartPtr& Data ) const;
00155 
00166   const char* CheckImage ( const int plane, const ScalarImage* image, const unsigned int frame = 0 );
00167 
00176   virtual void HandleError ( const char* message ) const 
00177   {
00178     fputs ( message, stderr );
00179   }
00180   
00181 private:
00185   DataGrid::IndexType Dims;
00186 
00191   UniformVolume::CoordinateVectorType Size;
00192 
00197   Types::Coordinate* Points[3];
00198 
00200   unsigned int DataSize;
00201 
00203   char *RawData;
00204 
00206   TypedArray::SmartPtr VolumeDataArray;
00207 
00209   int BytesPerPixel;
00210 
00212   bool SignBit;
00213 
00215   ScalarDataType DataType;
00216 
00218   Types::Coordinate Spacing[2];
00219 
00221   ScalarImage::SpaceVectorType FirstImagePosition;
00222 
00224   ScalarImage::SpaceVectorType ImagePosition;
00225 
00227   ScalarImage::SpaceVectorType ImageOrientation[2];
00228 
00230   int IncX;
00231 
00233   int IncY;
00234 
00236   int BlockSize;
00237 
00244   ScalarImage::SpaceVectorType IncrementVector;
00245 
00250   bool Padding;
00251 
00254   union {
00255     unsigned char int8;
00256     unsigned short int16;
00257     unsigned int int32;
00258   } PaddingValue;
00259 };
00260 
00262 
00263 } // namespace cmtk
00264 
00265 #endif // #ifndef __cmtkVolumeFromSlices_h_included_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines