Commit 1fd42d60 authored by Marcus D. Hanwell's avatar Marcus D. Hanwell

Refactored the TIFF reader, add support for floats

Fairly big refactoring of the TIFF reader, use templated methods in
many more places, avoid loss of type after it is determined, added
support for reading in 32 bit float TIFFs.

Change-Id: I4abf61179461acfa04c2c17c4e6d20467587c984
parent 63b17d65
This diff is collapsed.
/*=========================================================================
Program: Visualization Toolkit
Module: vtkTIFFReader.h,v
Module: vtkTIFFReader.h
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
......@@ -23,22 +23,17 @@
#ifndef __vtkTIFFReader_h
#define __vtkTIFFReader_h
#include "vtkIOImageModule.h" // For export macro
#include "vtkImageReader2.h"
//BTX
class vtkTIFFReaderInternal;
//ETX
class VTKIOIMAGE_EXPORT vtkTIFFReader : public vtkImageReader2
{
public:
static vtkTIFFReader *New();
vtkTypeMacro(vtkTIFFReader,vtkImageReader2);
vtkTypeMacro(vtkTIFFReader, vtkImageReader2)
virtual void PrintSelf(ostream& os, vtkIndent indent);
// Description:
// Is the given file name a tiff file file?
// Is the given file name a tiff file?
virtual int CanReadFile(const char* fname);
// Description:
......@@ -58,18 +53,6 @@ public:
return "TIFF";
}
// Description:
// Auxiliary methods used by the reader internally.
void InitializeColors();
// Description:
// Reads 3D data from multi-pages tiff.
virtual void ReadVolume(void* buffer);
// Description:
// Reads 3D data from tiled tiff
virtual void ReadTiles(void* buffer);
// Description:
// Set orientation type
// ORIENTATION_TOPLEFT 1 (row 0 top, col 0 lhs)
......@@ -81,30 +64,24 @@ public:
// ORIENTATION_RIGHTBOT 7 (row 0 rhs, col 0 bottom)
// ORIENTATION_LEFTBOT 8 (row 0 lhs, col 0 bottom)
// User need to explicitly include vtk_tiff.h header to have access to those #define
void SetOrientationType( unsigned int orientationType );
vtkGetMacro( OrientationType, unsigned int );
// Description:
// Get method to check if orientation type is specified
vtkGetMacro( OrientationTypeSpecifiedFlag, bool );
void SetOrientationType(unsigned int orientationType);
vtkGetMacro(OrientationType, unsigned int)
// Description:
// Set/get methods to see if manual Origin/Spacing have
// been set.
vtkSetMacro( OriginSpecifiedFlag, bool );
vtkGetMacro( OriginSpecifiedFlag, bool );
vtkBooleanMacro( OriginSpecifiedFlag, bool );
// Get method to check if orientation type is specified.
vtkGetMacro(OrientationTypeSpecifiedFlag, bool)
// Description:
//
vtkSetMacro( SpacingSpecifiedFlag, bool );
vtkGetMacro( SpacingSpecifiedFlag, bool );
vtkBooleanMacro( SpacingSpecifiedFlag, bool );
// Set/get methods to see if manual origin has been set.
vtkSetMacro(OriginSpecifiedFlag, bool)
vtkGetMacro(OriginSpecifiedFlag, bool)
vtkBooleanMacro(OriginSpecifiedFlag, bool)
// Description:
// Internal method, do not use.
void ReadImageInternal( void *, void *outPtr,
int *outExt, unsigned int size );
// Set/get if the spacing flag has been specified.
vtkSetMacro(SpacingSpecifiedFlag, bool)
vtkGetMacro(SpacingSpecifiedFlag, bool)
vtkBooleanMacro(SpacingSpecifiedFlag, bool)
protected:
vtkTIFFReader();
......@@ -112,29 +89,64 @@ protected:
enum { NOFORMAT, RGB, GRAYSCALE, PALETTE_RGB, PALETTE_GRAYSCALE, OTHER };
vtkTIFFReaderInternal *GetInternalImage() { return this->InternalImage; }
virtual void ExecuteInformation();
virtual void ExecuteDataWithInformation(vtkDataObject *out, vtkInformation *outInfo);
int EvaluateImageAt( void*, void* );
private:
vtkTIFFReader(const vtkTIFFReader&); // Not implemented.
void operator=(const vtkTIFFReader&); // Not implemented.
void GetColor( int index,
unsigned short *r, unsigned short *g, unsigned short *b );
// Description:
// Evaluates the image at a single pixel location.
template<typename T>
int EvaluateImageAt(T* out, T* in);
void ReadGenericImage( void *out,
unsigned int vtkNotUsed(width),
unsigned int height );
// Description:
// Look up color paletter values.
void GetColor(int index,
unsigned short *r, unsigned short *g, unsigned short *b);
// To support Zeiss images
void ReadTwoSamplesPerPixelImage( void *out,
unsigned int vtkNotUsed(width),
unsigned int height );
void ReadTwoSamplesPerPixelImage(void *out,
unsigned int vtkNotUsed(width),
unsigned int height);
unsigned int GetFormat();
virtual void ExecuteInformation();
virtual void ExecuteDataWithInformation(vtkDataObject *out, vtkInformation *outInfo);
unsigned int GetFormat();
private:
vtkTIFFReader(const vtkTIFFReader&); // Not implemented.
void operator=(const vtkTIFFReader&); // Not implemented.
// Description:
// Auxiliary methods used by the reader internally.
void Initialize();
// Description:
// Internal method, do not use.
template<typename T>
void ReadImageInternal(T* buffer);
// Description:
// Reads 3D data from multi-pages tiff.
template<typename T>
void ReadVolume(T* buffer);
// Description:
// Reads 3D data from tiled tiff
void ReadTiles(void* buffer);
// Description:
// Reads a generic image.
template<typename T>
void ReadGenericImage(T* out, unsigned int width, unsigned int height);
// Description:
// Dispatch template to determine pixel type and decide on reader actions.
template <typename T>
void Process(T *outPtr, int outExtent[6], vtkIdType outIncr[3]);
// Description:
// Second layer of dispatch necessary for some TIFF types.
template <typename T>
void Process2(T *outPtr, int *outExt);
class vtkTIFFReaderInternal;
unsigned short *ColorRed;
unsigned short *ColorGreen;
......@@ -149,4 +161,5 @@ private:
bool OriginSpecifiedFlag;
bool SpacingSpecifiedFlag;
};
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment