ITK  4.5.0
Insight Segmentation and Registration Toolkit
itkTIFFImageIO.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef __itkTIFFImageIO_h
19 #define __itkTIFFImageIO_h
20 
21 #include "itkImageIOBase.h"
22 #include <fstream>
23 
24 namespace itk
25 {
26 //BTX
27 class TIFFReaderInternal;
28 //ETX
29 
43 {
44 public:
46  typedef TIFFImageIO Self;
49 
51  itkNewMacro(Self);
52 
54  itkTypeMacro(TIFFImageIO, ImageIOBase);
55 
56  /*-------- This part of the interface deals with reading data. ------ */
57 
60  virtual bool CanReadFile(const char *);
61 
63  virtual void ReadImageInformation();
64 
66  virtual void Read(void *buffer);
67 
69  virtual void ReadVolume(void *buffer);
70 
72  virtual void ReadTiles(void *buffer);
73 
74  /*-------- This part of the interfaces deals with writing data. ----- */
75 
78  virtual bool CanWriteFile(const char *);
79 
82  virtual void WriteImageInformation();
83 
86  virtual void Write(const void *buffer);
87 
89 
90  //BTX
91  enum { // Compression types
97  };
98  //ETX
99 
100  // Description:
101  // Set compression type. Sinze LZW compression is patented outside US, the
102  // additional work steps have to be taken in order to use that compression.
108 
109  void SetCompression(int compression)
110  {
111  m_Compression = compression;
112 
113  // This If block isn't strictly necessary:
114  // SetCompression(true); would be sufficient. However, it reads strangely
115  // for SetCompression(NoCompression) to then set SetCompression(true).
116  // Doing it this way is probably also less likely to break in the future.
117  if ( compression == NoCompression )
118  {
119  this->SetUseCompression(false); // this is for the ImageIOBase class
120  }
121  else
122  {
123  this->SetUseCompression(true); // this is for the ImageIOBase class
124  }
125  }
126 
127 protected:
128  TIFFImageIO();
129  ~TIFFImageIO();
130  void PrintSelf(std::ostream & os, Indent indent) const;
131 
132  void InternalWrite(const void *buffer);
133 
134  void InitializeColors();
135 
136  void ReadGenericImage(void *out,
137  unsigned int itkNotUsed(width),
138  unsigned int height);
139 
140  // To support Zeiss images
141  void ReadTwoSamplesPerPixelImage(void *out,
142  unsigned int itkNotUsed(width),
143  unsigned int height);
144 
145  int EvaluateImageAt(void *out, void *in);
146 
147  unsigned int GetFormat();
148 
149  void GetColor(int index, unsigned short *red,
150  unsigned short *green, unsigned short *blue);
151 
152  // Check that tag t can be found
153  bool CanFindTIFFTag(unsigned int t);
154 
155  // Read and returns the raw bytes of tag t
156  void * ReadRawByteFromTag(unsigned int t, unsigned int & value_count);
157 
158  TIFFReaderInternal *m_InternalImage;
159 
161 
162 private:
163  TIFFImageIO(const Self &); //purposely not implemented
164  void operator=(const Self &); //purposely not implemented
165 
166  unsigned short *m_ColorRed;
167  unsigned short *m_ColorGreen;
168  unsigned short *m_ColorBlue;
170  unsigned int m_ImageFormat;
171 };
172 } // end namespace itk
173 
174 #endif // __itkTIFFImageIO_h
ImageIOBase Superclass
void PrintSelf(std::ostream &os, Indent indent) const
Light weight base class for most itk classes.
virtual void ReadVolume(void *buffer)
virtual void Write(const void *buffer)
virtual void Read(void *buffer)
void SetCompressionToLZW()
Abstract superclass defines image IO interface.
ImageIO object for reading and writing TIFF images.
void SetCompression(int compression)
void SetCompressionToDeflate()
unsigned short * m_ColorGreen
void GetColor(int index, unsigned short *red, unsigned short *green, unsigned short *blue)
void operator=(const Self &)
void SetCompressionToNoCompression()
void ReadGenericImage(void *out, unsigned int, unsigned int height)
unsigned int GetFormat()
TIFFReaderInternal * m_InternalImage
unsigned short * m_ColorRed
virtual bool CanWriteFile(const char *)
virtual bool CanReadFile(const char *)
void SetCompressionToJPEG()
virtual void ReadImageInformation()
TIFFImageIO Self
void InternalWrite(const void *buffer)
void InitializeColors()
unsigned short * m_ColorBlue
virtual void SetUseCompression(bool _arg)
int EvaluateImageAt(void *out, void *in)
unsigned int m_ImageFormat
virtual void ReadTiles(void *buffer)
Control indentation during Print() invocation.
Definition: itkIndent.h:49
virtual void WriteImageInformation()
bool CanFindTIFFTag(unsigned int t)
SmartPointer< Self > Pointer
void ReadTwoSamplesPerPixelImage(void *out, unsigned int, unsigned int height)
void * ReadRawByteFromTag(unsigned int t, unsigned int &value_count)
void SetCompressionToPackBits()