Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkTIFFImageIO.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkTIFFImageIO.h,v $
00005   Language:  C++
00006   Date:      $Date: 2007-03-29 18:39:28 $
00007   Version:   $Revision: 1.14 $
00008 
00009   Copyright (c) Insight Software Consortium. All rights reserved.
00010   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
00011 
00012      This software is distributed WITHOUT ANY WARRANTY; without even 
00013      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00014      PURPOSE.  See the above copyright notices for more information.
00015 
00016 =========================================================================*/
00017 #ifndef __itkTIFFImageIO_h
00018 #define __itkTIFFImageIO_h
00019 
00020 #include "itkImageIOBase.h"
00021 #include <fstream>
00022 
00023 namespace itk
00024 {
00025 
00026 //BTX
00027 class TIFFReaderInternal;
00028 //ETX
00029 
00030 
00038 class ITK_EXPORT TIFFImageIO : public ImageIOBase
00039 {
00040 public:
00042   typedef TIFFImageIO        Self;
00043   typedef ImageIOBase        Superclass;
00044   typedef SmartPointer<Self> Pointer;
00045 
00047   itkNewMacro(Self);
00048 
00050   itkTypeMacro(TIFFImageIO, ImageIOBase);
00051 
00052   /*-------- This part of the interface deals with reading data. ------ */
00053 
00056   virtual bool CanReadFile(const char*);
00057 
00059   virtual void ReadImageInformation();
00060 
00062   virtual void Read(void* buffer);
00063 
00065   virtual void ReadVolume(void* buffer);
00066 
00068   virtual void ReadTiles(void* buffer);
00069 
00070   /*-------- This part of the interfaces deals with writing data. ----- */
00071 
00074   virtual bool CanWriteFile(const char*);
00075 
00078   virtual void WriteImageInformation();
00079 
00082   virtual void Write(const void* buffer);
00083 
00084   enum { NOFORMAT, RGB_, GRAYSCALE, PALETTE_RGB, PALETTE_GRAYSCALE, OTHER };
00085 
00086   //BTX
00087   enum
00088     { // Compression types
00089     NoCompression,
00090     PackBits,
00091     JPEG,
00092     Deflate,
00093     LZW
00094     };
00095   //ETX
00096 
00097   // Description:
00098   // Set compression type. Sinze LZW compression is patented outside US, the
00099   // additional work steps have to be taken in order to use that compression.
00100   void SetCompressionToNoCompression() { this->SetCompression(NoCompression); }
00101   void SetCompressionToPackBits()      { this->SetCompression(PackBits); }
00102   void SetCompressionToJPEG()          { this->SetCompression(JPEG); }
00103   void SetCompressionToDeflate()       { this->SetCompression(Deflate); }
00104   void SetCompressionToLZW()           { this->SetCompression(LZW); }
00105 
00106   void SetCompression(int compression) 
00107     {
00108     m_Compression = compression;
00109  
00110     // This If block isn't strictly necessary:
00111     // SetCompression(true); would be sufficient.  However, it reads strangely
00112     // for SetCompression(NoCompression) to then set SetCompression(true).
00113     // Doing it this way is probaly also less likely to break in the future.
00114     if (compression == NoCompression)
00115       {
00116       this->SetUseCompression(false); // this is for the ImageIOBase class
00117       }
00118     else
00119       {
00120       this->SetUseCompression(true);  // this is for the ImageIOBase class
00121       }
00122     }
00123 
00124 
00125 protected:
00126   TIFFImageIO();
00127   ~TIFFImageIO();
00128   void PrintSelf(std::ostream& os, Indent indent) const;
00129 
00130   void InternalWrite(const void* buffer);
00131 
00132   void InitializeColors();
00133   void ReadGenericImage( void *out, 
00134                          unsigned int itkNotUsed(width), 
00135                          unsigned int height );
00136 
00137   // To support Zeiss images
00138   void ReadTwoSamplesPerPixelImage( void *out, 
00139                          unsigned int itkNotUsed(width), 
00140                          unsigned int height );
00141 
00142 
00143   int EvaluateImageAt( void* out, void* in );
00144 
00145   unsigned int  GetFormat();
00146 
00147   void GetColor( int index, unsigned short *red, 
00148                  unsigned short *green, unsigned short *blue );
00149   // Check that tag t can be found
00150   bool  CanFindTIFFTag(unsigned int t);
00151   // Read and returns the raw bytes of tag t
00152   void *ReadRawByteFromTag( unsigned int t, short &value_count );
00153 
00154   TIFFReaderInternal * m_InternalImage;
00155   int                  m_Compression;
00156 private:
00157   TIFFImageIO(const Self&); //purposely not implemented
00158   void operator=(const Self&); //purposely not implemented
00159 
00160   unsigned short *m_ColorRed;
00161   unsigned short *m_ColorGreen;
00162   unsigned short *m_ColorBlue;
00163   int             m_TotalColors;
00164   unsigned int    m_ImageFormat;
00165 };
00166 
00167 } // end namespace itk
00168 
00169 #endif // __itkTIFFImageIO_h
00170 

Generated at Tue Sep 15 05:09:14 2009 for ITK by doxygen 1.5.8 written by Dimitri van Heesch, © 1997-2000