File: vtkTIFFReader.h

package info (click to toggle)
paraview 5.13.2%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 544,220 kB
  • sloc: cpp: 3,374,605; ansic: 1,332,409; python: 150,381; xml: 122,166; sql: 65,887; sh: 7,317; javascript: 5,262; yacc: 4,417; java: 3,977; perl: 2,363; lex: 1,929; f90: 1,397; makefile: 170; objc: 153; tcl: 59; pascal: 50; fortran: 29
file content (189 lines) | stat: -rw-r--r-- 4,807 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
// SPDX-License-Identifier: BSD-3-Clause
/**
 * @class   vtkTIFFReader
 * @brief   read TIFF files
 *
 * vtkTIFFReader is a source object that reads TIFF files.
 * It should be able to read almost any TIFF file
 *
 * @sa
 * vtkTIFFWriter
 */

#ifndef vtkTIFFReader_h
#define vtkTIFFReader_h

#include "vtkImageReader2.h"

VTK_ABI_NAMESPACE_BEGIN
class VTKIOIMAGE_EXPORT vtkTIFFReader : public vtkImageReader2
{
public:
  static vtkTIFFReader* New();
  vtkTypeMacro(vtkTIFFReader, vtkImageReader2);
  void PrintSelf(ostream& os, vtkIndent indent) override;

  /**
   * Is the given file name a tiff file?
   */
  int CanReadFile(VTK_FILEPATH const char* fname) override;

  /**
   * Get the file extensions for this format.
   * Returns a string with a space separated list of extensions in
   * the format .extension
   */
  const char* GetFileExtensions() override { return ".tif .tiff"; }

  /**
   * Return a descriptive name for the file format that might be useful
   * in a GUI.
   */
  const char* GetDescriptiveName() override { return "TIFF"; }

  /**
   * Set orientation type
   * ORIENTATION_TOPLEFT         1       (row 0 top, col 0 lhs)
   * ORIENTATION_TOPRIGHT        2       (row 0 top, col 0 rhs)
   * ORIENTATION_BOTRIGHT        3       (row 0 bottom, col 0 rhs)
   * ORIENTATION_BOTLEFT         4       (row 0 bottom, col 0 lhs)
   * ORIENTATION_LEFTTOP         5       (row 0 lhs, col 0 top)
   * ORIENTATION_RIGHTTOP        6       (row 0 rhs, col 0 top)
   * 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 these macros
   */
  void SetOrientationType(unsigned int orientationType);
  vtkGetMacro(OrientationType, unsigned int);

  ///@{
  /**
   * Get method to check if orientation type is specified.
   */
  vtkGetMacro(OrientationTypeSpecifiedFlag, bool);
  ///@}

  ///@{
  /**
   * Set/get methods to see if manual origin has been set.
   */
  vtkSetMacro(OriginSpecifiedFlag, bool);
  vtkGetMacro(OriginSpecifiedFlag, bool);
  vtkBooleanMacro(OriginSpecifiedFlag, bool);
  ///@}

  ///@{
  /**
   * Set/get if the spacing flag has been specified.
   */
  vtkSetMacro(SpacingSpecifiedFlag, bool);
  vtkGetMacro(SpacingSpecifiedFlag, bool);
  vtkBooleanMacro(SpacingSpecifiedFlag, bool);
  ///@}

  ///@{
  /**
   * When set to true (default false), TIFFTAG_COLORMAP, if any, will be
   * ignored.
   */
  vtkSetMacro(IgnoreColorMap, bool);
  vtkGetMacro(IgnoreColorMap, bool);
  vtkBooleanMacro(IgnoreColorMap, bool);
  ///@}
protected:
  vtkTIFFReader();
  ~vtkTIFFReader() override;

  enum
  {
    NOFORMAT,
    RGB,
    GRAYSCALE,
    PALETTE_RGB,
    PALETTE_GRAYSCALE,
    OTHER
  };

  void ExecuteInformation() override;
  void ExecuteDataWithInformation(vtkDataObject* out, vtkInformation* outInfo) override;

  class vtkTIFFReaderInternal;
  vtkTIFFReaderInternal* InternalImage;

private:
  vtkTIFFReader(const vtkTIFFReader&) = delete;
  void operator=(const vtkTIFFReader&) = delete;

  /**
   * Evaluates the image at a single pixel location.
   */
  template <typename T>
  int EvaluateImageAt(T* out, T* in);

  /**
   * 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);

  unsigned int GetFormat();

  /**
   * Auxiliary methods used by the reader internally.
   */
  void Initialize();

  /**
   * Internal method, do not use.
   */
  template <typename T>
  void ReadImageInternal(T* buffer);

  /**
   * Reads 3D data from multi-pages tiff.
   */
  template <typename T>
  void ReadVolume(T* buffer);

  /**
   * Reads 3D data from tiled tiff
   */
  void ReadTiles(void* buffer);

  /**
   * Reads a generic image.
   */
  template <typename T>
  void ReadGenericImage(T* out, unsigned int width, unsigned int height);

  /**
   * Dispatch template to determine pixel type and decide on reader actions.
   */
  template <typename T>
  void Process(T* outPtr, int outExtent[6], vtkIdType outIncr[3]);

  /**
   * Second layer of dispatch necessary for some TIFF types.
   */
  template <typename T>
  void Process2(T* outPtr, int* outExt);

  unsigned short* ColorRed;
  unsigned short* ColorGreen;
  unsigned short* ColorBlue;
  int TotalColors;
  unsigned int ImageFormat;
  int OutputExtent[6];
  vtkIdType OutputIncrements[3];
  unsigned int OrientationType;
  bool OrientationTypeSpecifiedFlag;
  bool OriginSpecifiedFlag;
  bool SpacingSpecifiedFlag;
  bool IgnoreColorMap;
};

VTK_ABI_NAMESPACE_END
#endif