File: ImageWrapperBase.h

package info (click to toggle)
itksnap 3.6.0-5
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 22,132 kB
  • sloc: cpp: 91,089; ansic: 1,994; sh: 327; makefile: 16
file content (647 lines) | stat: -rw-r--r-- 24,196 bytes parent folder | download | duplicates (2)
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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
#ifndef IMAGEWRAPPERBASE_H
#define IMAGEWRAPPERBASE_H

#include "SNAPCommon.h"
#include "ImageCoordinateTransform.h"
#include "itkImageRegion.h"
#include "itkObject.h"
#include "SNAPEvents.h"

namespace itk {
  template <unsigned int VDim> class ImageBase;
  template <class TPixel, unsigned int VDim> class Image;
  template <class TPixel, unsigned int VDim> class VectorImage;
  template <class TPixel> class RGBAPixel;
  template <class TOutputImage> class ImageSource;
  template <class TScalar, unsigned int V1, unsigned int V2> class Transform;

  namespace Statistics {
    class DenseFrequencyContainer;
    template <class TReal, unsigned int VDim, class TContainer> class Histogram;
  }
}

class ScalarImageWrapperBase;
class VectorImageWrapperBase;
class IntensityCurveInterface;
class ScalarImageHistogram;
class ColorMap;
class ImageCoordinateGeometry;
class AbstractNativeIntensityMapping;
class AbstractDisplayMappingPolicy;
class SNAPSegmentationROISettings;
class GuidedNativeImageIO;
class Registry;
class vtkImageImport;
struct IRISDisplayGeometry;

/**
 * Supported ways of extracting a scalar value from vector-valued data.
 * These modes allow the image to be cast to a scalar image and used in
 * single-modality pipelines
 */
enum ScalarRepresentation
{
  SCALAR_REP_COMPONENT = 0,
  SCALAR_REP_MAGNITUDE,
  SCALAR_REP_MAX,
  SCALAR_REP_AVERAGE,
  NUMBER_OF_SCALAR_REPS
};


/**
 \class ImageWrapperBase
 \brief Abstract parent class for all image wrappers

 This class is at the head of the ImageWrapper hierarchy. In fact, there are
 two parallel hierarchies: the untyped hierarchy (xxxWrapperBase) and the
 hierarchy templated over a type (xxxWrapper).

 The idea is that most SNAP code will work with the untyped hierarches. Thus,
 the code will not know what the underlying format of the image is. The typed
 hierarchy is invisible to most of the SNAP classes, and accessed on special
 occasions, where the raw data of the image is needed.
 */
class ImageWrapperBase : public itk::Object
{
public:

  // Definition for the display slice type
  typedef itk::RGBAPixel<unsigned char>                       DisplayPixelType;
  typedef itk::Image<DisplayPixelType,2>                      DisplaySliceType;
  typedef SmartPtr<DisplaySliceType>                       DisplaySlicePointer;

  // Image base
  typedef itk::ImageBase<3> ImageBaseType;

  // Transform matrices
  typedef vnl_matrix_fixed<double, 4, 4>                         TransformType;

  // ITK's coordinate transform (rigid, affine, etc)
  typedef itk::Transform<double, 3, 3>                        ITKTransformType;

  /**
   * The image wrapper fires a WrapperMetadataChangeEvent when properties
   * such as nickname are modified. It fires a WrapperDisplayMappingChangeEvent
   * when the factors affecting the mapping from internal data to the slice
   * display (e.g., color map) are modified.
   */
  FIRES(WrapperMetadataChangeEvent)
  FIRES(WrapperDisplayMappingChangeEvent)

  virtual ~ImageWrapperBase() { }

  /**
    Get a unique id for this wrapper. All wrappers ever created have
    different ids.
    */
  virtual unsigned long GetUniqueId() const = 0;

  /**
   * Every wrapper, whether it is a scalar wrapper or a vector wrapper, has a
   * scalar representation. For scalar wrappers, this function just returns a
   * pointer to itself. For vector wrappers, the behavior of this function
   * depends on which scalar representation has been selected as the default
   * scalar representation (e.g., one of the components, magnitude, max, mean).
   */
  virtual ScalarImageWrapperBase *GetDefaultScalarRepresentation() = 0;

  /**
   * Get the parent wrapper for this wrapper. For 'normal' wrappers, this method
   * returns NULL, indicating that the wrapper is a top-level wrapper. For derived
   * wrappers (i.e., components and scalar representations of vector wrappers),
   * this method returns the vector wrapper from which the wrapper is derived
   */
  virtual ImageWrapperBase *GetParentWrapper() const = 0;

  /** Set the parent wrapper */
  virtual void SetParentWrapper(ImageWrapperBase *parent) = 0;

  /** Get the coordinate transform for each display slice */
  virtual const ImageCoordinateTransform *GetImageToDisplayTransform(
    unsigned int) const = 0;

  /**
   * Set the coordinate transformation between the display coordinates and
   * the anatomical coordinates. This affects the behavior of the slicers
   */
  virtual void SetDisplayGeometry(const IRISDisplayGeometry &dispGeom) = 0;

  /** Get the display to anatomy coordinate mapping */
  virtual const IRISDisplayGeometry &GetDisplayGeometry() const = 0;

  /** Set the direction matrix of the image */
  virtual void SetDirectionMatrix(const vnl_matrix<double> &direction) = 0;

  /**
   * Set the image coordinate transform (origin, spacing, direction) to
   * match those of a reference wrapper
   */
  virtual void CopyImageCoordinateTransform(const ImageWrapperBase *source) = 0;

  /**
   * Get the image geometry from the wrapper. The image geometry captures
   * the transforms between each of the display slices and the 3D image.
   */
  virtual const ImageCoordinateGeometry &GetImageGeometry() const = 0;

  /** Get the current slice index */
  irisVirtualGetMacro(SliceIndex, Vector3ui)

  /**
   * Set the current slice index in all three dimensions.  The index should
   * be specified in the image coordinates, the slices will be generated
   * in accordance with the transforms that are specified
   */
  virtual void SetSliceIndex(const Vector3ui &) = 0;

  /**
   * Set the viewport rectangle onto which the three display slices
   * will be rendered
   */
  virtual void SetDisplayViewportGeometry(
      unsigned int index,
      const ImageBaseType *viewport_image) = 0;


  /** Return some image info independently of pixel type */
  irisVirtualGetMacro(ImageBase, ImageBaseType *)

  /**
   * Is the image initialized?
   */
  irisVirtualIsMacro(Initialized)

  /**
   * If the image wrapper is an output of a preview pipeline, is the pipeline ready?
   */
  irisVirtualIsMacro(PipelineReady)
  irisVirtualSetMacro(PipelineReady, bool)

  /** Is this image of scalar type? */
  virtual bool IsScalar() const = 0;

  /**
   * Get the size of the image
   */
  virtual Vector3ui GetSize() const = 0;

  /** Get layer transparency */
  irisVirtualSetMacro(Alpha, double)

  /** Set layer transparency */
  irisVirtualGetMacro(Alpha, double)

  /**
   * Get layer stickiness. A sticky layer always is shown 'on top' of other
   * layers, e.g., the segmentation layer, or the level set image. A layer that
   * is not sticky is shown in its own tile when the display is in tiled mode
   */
  irisVirtualSetMacro(Sticky, bool)

  /** Set layer stickiness */
  irisVirtualIsMacro(Sticky)

  /**
   * Whether the layer is drawable. Some layers may be initialized, but not
   * yet computed, in which case they should not yet be drawn.
   */
  irisVirtualIsMacro(Drawable)

  /**
   * Whether the layer is initialized to use orthogonal slicing or non-orthogonal
   * slicing. There are two slicing pipelines, one for the images whose slicing
   * directions are parallel to the display planes, and one for the opposite case.
   */
  irisVirtualIsMacro(SlicingOrthogonal)

  /**
   * Get the buffered region of the image
   */
  virtual itk::ImageRegion<3> GetBufferedRegion() const = 0;

  /**
   * Extract a region of interest from the image wrapper, as a new wrapper of
   * the same type
   */
  virtual SmartPtr<ImageWrapperBase> ExtractROI(
      const SNAPSegmentationROISettings &roi, itk::Command *progressCommand) const = 0;

  /** Transform a voxel index into a spatial position */
  virtual Vector3d TransformVoxelIndexToPosition(const Vector3i &iVoxel) const = 0;

  /** Transform a voxel index into a spatial position */
  virtual Vector3d TransformVoxelCIndexToPosition(const Vector3d &iVoxel) const = 0;

  /** Transform spatial position to voxel continuous index (LPS) */
  virtual Vector3d TransformPositionToVoxelCIndex(const Vector3d &vLPS) const = 0;

  /** Transform spatial position to voxel index (LPS) */
  virtual Vector3i TransformPositionToVoxelIndex(const Vector3d &vLPS) const = 0;

  /** Transform a voxel index into NIFTI coordinates (RAS) */
  virtual Vector3d TransformVoxelCIndexToNIFTICoordinates(const Vector3d &iVoxel) const = 0;

  /** Transform NIFTI coordinates to a continuous voxel index */
  virtual Vector3d TransformNIFTICoordinatesToVoxelCIndex(const Vector3d &vNifti) const = 0;

  /** Get the NIFTI s-form matrix for this image */
  irisVirtualGetMacro(NiftiSform, TransformType)

  /** Get the inverse NIFTI s-form matrix for this image */
  irisVirtualGetMacro(NiftiInvSform, TransformType)

  /** Get a display slice correpsponding to the current index */
  virtual DisplaySlicePointer GetDisplaySlice(unsigned int dim) = 0;

  /** For each slicer, find out which image dimension does is slice along */
  virtual unsigned int GetDisplaySliceImageAxis(unsigned int slice) = 0;

  /** Get the number of voxels */
  virtual size_t GetNumberOfVoxels() const = 0;

  /** Get the number of components per voxel */
  virtual size_t GetNumberOfComponents() const = 0;

  /** Get voxel at index as an array of double components */
  virtual void GetVoxelAsDouble(const Vector3ui &x, double *out) const = 0;

  /** Get voxel at index as an array of double components */
  virtual void GetVoxelAsDouble(const itk::Index<3> &idx, double *out) const = 0;

  /** Get voxel intensity in native space. These methods are not recommended
      for iterating over the entire image, since there is a virutal method
      being resolved at each iteration. */
  virtual void GetVoxelMappedToNative(const Vector3ui &vec, double *out) const = 0;
  virtual void GetVoxelMappedToNative(const itk::Index<3> &idx, double *out) const = 0;

  /** Return componentwise minimum cast to double, without mapping to native range */
  virtual double GetImageMinAsDouble() = 0;

  /** Return componentwise maximum cast to double, without mapping to native range */
  virtual double GetImageMaxAsDouble() = 0;

  /** Return componentwise minimum cast to double, after mapping to native range */
  virtual double GetImageMinNative() = 0;

  /** Return componentwise maximum cast to double, after mapping to native range */
  virtual double GetImageMaxNative() = 0;

  /**
    Compute the image histogram. The histogram is cached inside of the
    object, so repeated calls to this function with the same nBins parameter
    will not require additional computation.

    Calling with default parameter (0) will use the same number of bins that
    is currently in the histogram (i.e., return/recompute current histogram).
    If there is no current histogram, a default histogram with 128 entries
    will be generated.

    For multi-component data, the histogram is pooled over all components.
    */
  virtual const ScalarImageHistogram *GetHistogram(size_t nBins) = 0;

  /** Compute statistics over a run of voxels in the image starting at the index
   * startIdx. Appends the statistics to a running sum and sum of squared. The
   * statistics are returned in internal (not native mapped) format */
  virtual void GetRunLengthIntensityStatistics(
      const itk::ImageRegion<3> &region,
      const itk::Index<3> &startIdx, long runlength,
      double *out_sum, double *out_sumsq) const = 0;

  /**
   * This method returns a vector of values for the voxel under the cursor.
   * This is the natural value or set of values that should be displayed to
   * the user. The value depends on the current display mode. For scalar
   * images, it's just the value of the voxel, but for multi-component images,
   * it's the value of the selected component (if there is one) or the value
   * of the multiple components when the mode is RGB. In the second parameter,
   * the method returns the RGB appearance of the voxel under the cursor
   */
  virtual void GetVoxelUnderCursorDisplayedValueAndAppearance(
      vnl_vector<double> &out_value, DisplayPixelType &out_appearance) = 0;

  /** Clear the data associated with storing an image */
  virtual void Reset() = 0;

  /**
   * Get the mapping between the internal data type and the 'native' range,
   * i.e., the range of values shown to the user. This may be a linear mapping
   * or an identity mapping.
   */
  virtual const AbstractNativeIntensityMapping *GetNativeIntensityMapping() const = 0;

  /**
   * Get the display mapping policy. This policy differs from wrapper to wrapper
   * and may involve using color labels or color maps.
   */
  virtual AbstractDisplayMappingPolicy *GetDisplayMapping() = 0;

  /**
   * Get the display mapping policy. This policy differs from wrapper to wrapper
   * and may involve using color labels or color maps.
   */
  virtual const AbstractDisplayMappingPolicy *GetDisplayMapping() const = 0;

  // Access the filename
  irisVirtualGetStringMacro(FileName)
  irisVirtualSetStringMacro(FileName)

  // Access the nickname - which may be a custom nickname or derived from the
  // filename if there is no custom nickname
  irisVirtualGetMacro(Nickname, const std::string &)

  // Set the custom nickname - precedence over the filename
  irisVirtualGetMacro(CustomNickname, const std::string &)
  irisVirtualSetMacro(CustomNickname, const std::string &)

  // Fallback nickname - shown if no filename and no custom nickname set.
  irisVirtualGetMacro(DefaultNickname, const std::string &)
  irisVirtualSetMacro(DefaultNickname, const std::string &)

  /**
    Export one of the slices as a thumbnail (e.g., PNG file)
    */
  virtual void WriteThumbnail(const char *filename, unsigned int maxdim) = 0;

  /**
   * Access the "IO hints" registry associated with this wrapper. The IO hints
   * are used to help read the image when the filename alone is not sufficient.
   * For example, it may contain the DICOM series ID of the image, or for a raw
   * image the dimensions.
   */
  virtual const Registry &GetIOHints() const = 0;

  /**
   * Set the IO hints
   */
  virtual void SetIOHints(const Registry &io_hints) = 0;

  /**
   * Write the image to disk with the help of the GuidedNativeImageIO object
   */
  virtual void WriteToFile(const char *filename, Registry &hints) = 0;

  /**
   * Check if the image has unsaved changes
   */
  virtual bool HasUnsavedChanges() const = 0;

  /**
   * Save metadata to a Registry file. The metadata are data that are not
   * contained in the image header are need to be restored when the image
   * is reloaded. Currently, this mainly includes the display mapping, but
   * also the transparency, etc.
   */
  virtual void WriteMetaData(Registry &reg) = 0;

  /**
   * Restore metadata from a registry
   */
  virtual void ReadMetaData(Registry &reg) = 0;

  /**
   * This static function constructs a NIFTI matrix from the ITK direction
   * cosines matrix and Spacing and Origin vectors
   */
  static TransformType ConstructNiftiSform(
    vnl_matrix<double> m_dir,
    vnl_vector<double> v_origin,
    vnl_vector<double> v_spacing);

  static TransformType ConstructVTKtoNiftiTransform(
    vnl_matrix<double> m_dir,
    vnl_vector<double> v_origin,
    vnl_vector<double> v_spacing);

  typedef itk::Image<short, 3> ShortImageType;

  /**
   * The image wrapper has a generic mechanism for associating data with it.
   * For example, we can associate some parameter values for a specific
   * image processing algorithm with each layer. Do do that, we simply
   * assign a pointer to the data to a specific string role. Internally,
   * a smart pointer is used to point to the associated data.
   *
   * Users of this method might also want to rebroadcast events from the
   * associated object as events of type WrapperUserChangeEvent(). These
   * events will then propagate all the way up to the IRISApplication.
   */
  virtual void SetUserData(const std::string &role, itk::Object *data) = 0;

  /**
   * Get the user data associated with this wrapper for a specific role. If
   * no association exists, NULL is returned.
   */
  virtual itk::Object* GetUserData(const std::string &role) const = 0;

  //

  /**
   * Set an ITK transform between this image and a reference image.
   */
  virtual void SetITKTransform(ImageBaseType *referenceSpace, ITKTransformType *transform) = 0;

  /**
   * Get the ITK transform between this image and the reference space
   */
  virtual const ITKTransformType *GetITKTransform() const = 0;

  /**
   * Get the reference space space in which this image is defined
   */
  virtual ImageBaseType* GetReferenceSpace() const = 0;

protected:

};

class ScalarImageWrapperBase : public virtual ImageWrapperBase
{
public:

  // A common image format to which the contents of the scalar image wrapper
  // may be cast for downstream processing
  typedef itk::Image<GreyType, 3>                      CommonFormatImageType;

  typedef itk::Image<float, 3>                                FloatImageType;
  typedef itk::ImageSource<FloatImageType>                  FloatImageSource;
  typedef itk::Image<double, 3>                              DoubleImageType;
  typedef itk::ImageSource<DoubleImageType>                DoubleImageSource;

  typedef itk::VectorImage<float, 3>                    FloatVectorImageType;
  typedef itk::ImageSource<FloatVectorImageType>      FloatVectorImageSource;
  typedef itk::VectorImage<double, 3>                  DoubleVectorImageType;
  typedef itk::ImageSource<DoubleVectorImageType>    DoubleVectorImageSource;

  /**
   * An enum of export channel types. Export channels are used to present the
   * internal image as an itk::Image of a fixed type. For efficient memory
   * management, there are separate channels for downstream filters that
   * operate on the whole image and filters that generate single-slice previews
   * in the orthogonal slicing directions
   */
  enum ExportChannel {
    WHOLE_IMAGE=0, PREVIEW_X, PREVIEW_Y, PREVIEW_Z, CHANNEL_COUNT
  };

  /**
   * Get the scaling factor used to convert between intensities stored
   * in this image and the 'true' image intensities
   */
  virtual double GetImageScaleFactor() = 0;

  /** Get voxel at index as a single double value */
  virtual double GetVoxelAsDouble(const Vector3ui &x) const = 0;

  /** Get voxel at index as a single double value */
  virtual double GetVoxelAsDouble(const itk::Index<3> &idx) const = 0;

  /** Get voxel intensity in native space. These methods are not recommended
      for iterating over the entire image, since there is a virutal method
      being resolved at each iteration. */
  virtual double GetVoxelMappedToNative(const Vector3ui &vec) const = 0;
  virtual double GetVoxelMappedToNative(const itk::Index<3> &idx) const = 0;

  /**
    Get the maximum possible value of the gradient magnitude. This will
    compute the gradient magnitude of the image (without Gaussian smoothing)
    and return the maximum. The value will be cached so repeated calls to
    this are not expensive.
    */
  virtual double GetImageGradientMagnitudeUpperLimit() = 0;

  /**
    Get the maximum possible value of the gradient magnitude in native units
    */
  virtual double GetImageGradientMagnitudeUpperLimitNative() = 0;

  /**
   * Extract a GreyType representation from the image wrapper. Note that
   * internally, the scalar image wrapper can be of many itk types, e.g.,
   * it could be a component of a vector image computed dynamically. In
   * order to use the scalar image in downstream filters, we must have a
   * way to map it to some common datatype. If not, we would have to template
   * the downstream filter on the type of the image in the wrapper, which would
   * lead to an exponential explosion of types.
   *
   * There are actually four representations for each image wrapper, one of
   * which is intended for pipelines that act on entire image volumes and the
   * other three intended for use in preview-capable pipelines, which generate
   * output for just one slice. Since ITK only allocates the requested image
   * region, these four representations should not really use much extra memory.
   *
   * However, it is very important that downstream filters use the itk streaming
   * image filter to break up operations into pieces. Without that, there would
   * be unnecessary large memory allocation.
   */
  virtual CommonFormatImageType* GetCommonFormatImage(
      ExportChannel channel = WHOLE_IMAGE) = 0;

  /**
    Cast the internally stored image to a floating point image. The returned
    image is connected to the internally stored image by a mini-pipeline that
    may include a cast filter or a scale/shift filter, depending on the internal
    format of the image and the internal-to-native intensity mapping. This mini
    pipeline is not memory managed by the wrapper, and as soon as the returned
    image smartpointer goes out of scope, the mini-pipeline is deallocated.

    The method is intended for use with external pipelines that don't know what
    the internal data representation is for the image. There is a cost with using
    this method in terms of memory, so the recommended use is in conjunction with
    streaming filters, so that the cast mini-pipeline does not allocate the whole
    floating point image all at once.

    The mini-pipeline should not be kept around in memory after it's used. This would
    result in unnecessary duplication of memory.
    */
  virtual SmartPtr<FloatImageSource> CreateCastToFloatPipeline() const = 0;

  /** Same as CreateCastToFloatPipeline, but for double precision */
  virtual SmartPtr<DoubleImageSource> CreateCastToDoublePipeline() const = 0;

  /** Same as CreateCastToFloatPipeline, but for vector images of single dimension */
  virtual SmartPtr<FloatVectorImageSource> CreateCastToFloatVectorPipeline() const = 0;

  /** Same as CreateCastToFloatPipeline, but for vector images of single dimension */
  virtual SmartPtr<DoubleVectorImageSource> CreateCastToDoubleVectorPipeline() const = 0;

  /**
   * Get the intensity curve used to map raw intensities to color map inputs.
   * The intensity curve is only used by some wrappers (anatomic, speed) and
   * so this method may return NULL for some layers.
   */
  virtual IntensityCurveInterface *GetIntensityCurve() const = 0;

  /**
   * Get the color map used to present image intensities as RGBA.
   */
  virtual ColorMap *GetColorMap() const = 0;

  /** Get a version of this image that is usable in VTK pipelines */
  virtual vtkImageImport *GetVTKImporter() = 0;
};




/**
 * A class that can be used to iterate over scalar representations.
 * Within some of the scalar representations (for now just SCALAR_REP_COMPONENT)
 * there are multiple indexed scalar components. The iterator iterates over the
 * components before proceeding to the next component.
 */
class ScalarRepresentationIterator
{
public:
  ScalarRepresentationIterator(const VectorImageWrapperBase *wrapper);

  ScalarRepresentationIterator& operator ++();
  bool IsAtEnd() const;

  irisGetMacro(Index, int)

  ScalarRepresentation GetCurrent() const
    { return static_cast<ScalarRepresentation>(m_Current); }

protected:
  int m_Current;
  int m_Index;

  // Depth of each scalar representation
  std::vector<int> m_Depth;

  friend class VectorImageWrapperBase;
};

/**
 * A base class for wrappers around vector-valued images
 */
class VectorImageWrapperBase : public virtual ImageWrapperBase
{
public:

  /**
   * Get a pointer to the given scalar representation of this vector image.
   */
  virtual ScalarImageWrapperBase *GetScalarRepresentation(
      ScalarRepresentation type, int index = 0) = 0;


  /**
   * Access a scalar representation using an iterator
   */
  virtual ScalarImageWrapperBase *GetScalarRepresentation(
      const ScalarRepresentationIterator &it) = 0;

  /**
   * If scalar_rep is a scalar representation of the vector image wrapper, find
   * the type of the representation and the index. Otherwise return false;
   */
  virtual bool FindScalarRepresentation(
      ImageWrapperBase *scalar_rep, ScalarRepresentation &type, int &index) const = 0;
};


#endif // IMAGEWRAPPERBASE_H