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
|
#ifndef IMAGEWRAPPERTRAITS_H
#define IMAGEWRAPPERTRAITS_H
#include "SNAPCommon.h"
#include "ImageWrapperBase.h"
#include "RLEImageRegionIterator.h"
#include "CommonRepresentationPolicy.h"
#include "DisplayMappingPolicy.h"
#include "NativeIntensityMappingPolicy.h"
#include "ScalarImageWrapper.h"
#include "VectorImageWrapper.h"
#include "ColorMap.h"
namespace itk
{
template <class TPixel, unsigned int VDim> class Image;
template <class TPixel, unsigned int VDim> class VectorImage;
template <class TPixel, unsigned int VDim> class VectorImageToImageAdaptor;
}
/*
class ScalarImageWrapperBase;
class VectorImageWrapperBase;
template <class TImage, class TBase> class VectorImageWrapper;
template <class TImage, class TBase> class ScalarImageWrapper;
*/
/**
* Each of the traits classes below defines types and policies for a specific
* type of image wrapper.
*/
class LabelImageWrapperTraits
{
public:
typedef LabelImageWrapperTraits Self;
typedef ScalarImageWrapper<LabelImageWrapperTraits> WrapperType;
typedef LabelType ComponentType;
typedef RLEImage<ComponentType> ImageType;
typedef itk::Image<ComponentType, 2> SliceType;
typedef IdentityInternalToNativeIntensityMapping NativeIntensityMapping;
typedef ColorLabelTableDisplayMappingPolicy<Self> DisplayMapping;
typedef NullScalarImageWrapperCommonRepresentation<GreyType, Self> CommonRepresentationPolicy;
// Whether this image is shown on top of all other layers by default
itkStaticConstMacro(StickyByDefault, bool, true);
// Whether this image is produced from another by a pipeline (e.g., speed image)
itkStaticConstMacro(PipelineOutput, bool, false);
};
class SpeedImageWrapperTraits
{
public:
typedef SpeedImageWrapperTraits Self;
typedef ScalarImageWrapper<SpeedImageWrapperTraits> WrapperType;
typedef GreyType ComponentType;
typedef itk::Image<ComponentType, 3> ImageType;
typedef itk::Image<ComponentType, 2> SliceType;
typedef SpeedImageInternalToNativeIntensityMapping NativeIntensityMapping;
typedef LinearColorMapDisplayMappingPolicy<Self> DisplayMapping;
typedef NullScalarImageWrapperCommonRepresentation<GreyType, Self> CommonRepresentationPolicy;
static void GetFixedIntensityRange(float &min, float &max)
{ min = -0x7fff; max = 0x7fff; }
itkStaticConstMacro(DefaultColorMap, ColorMap::SystemPreset, ColorMap::COLORMAP_SPEED);
// Whether this image is shown on top of all other layers by default
itkStaticConstMacro(StickyByDefault, bool, false);
// Whether this image is produced from another by a pipeline (e.g., speed image)
itkStaticConstMacro(PipelineOutput, bool, true);
};
class LevelSetImageWrapperTraits
{
public:
typedef LevelSetImageWrapperTraits Self;
typedef ScalarImageWrapper<LevelSetImageWrapperTraits> WrapperType;
typedef float ComponentType;
typedef itk::Image<ComponentType, 3> ImageType;
typedef itk::Image<ComponentType, 2> SliceType;
typedef IdentityInternalToNativeIntensityMapping NativeIntensityMapping;
typedef LinearColorMapDisplayMappingPolicy<Self> DisplayMapping;
typedef NullScalarImageWrapperCommonRepresentation<GreyType, Self> CommonRepresentationPolicy;
static void GetFixedIntensityRange(float &min, float &max)
{ min = -4.0; max = 4.0; }
itkStaticConstMacro(DefaultColorMap, ColorMap::SystemPreset, ColorMap::COLORMAP_LEVELSET);
// Whether this image is shown on top of all other layers by default
itkStaticConstMacro(StickyByDefault, bool, true);
// Whether this image is produced from another by a pipeline (e.g., speed image)
itkStaticConstMacro(PipelineOutput, bool, true);
};
/**
* This helper traits class is used to select the appropriate common representation
* policy depending on the internal pixel type
*/
template <class TPixel, class TWrapperTraits>
class DefaultCommonRepresentationPolicy
{
public:
typedef CastingScalarImageWrapperCommonRepresentation<GreyType, TWrapperTraits> Policy;
};
template <class TWrapperTraits>
class DefaultCommonRepresentationPolicy<GreyType, TWrapperTraits>
{
public:
typedef InPlaceScalarImageWrapperCommonRepresentation<GreyType, TWrapperTraits> Policy;
};
template <class TPixel>
class ComponentImageWrapperTraits
{
public:
typedef ComponentImageWrapperTraits<TPixel> Self;
typedef ScalarImageWrapper<Self> WrapperType;
typedef TPixel ComponentType;
typedef itk::VectorImageToImageAdaptor<ComponentType, 3> ImageType;
typedef itk::Image<ComponentType, 2> SliceType;
typedef LinearInternalToNativeIntensityMapping NativeIntensityMapping;
typedef CachingCurveAndColorMapDisplayMappingPolicy<Self> DisplayMapping;
typedef CastingScalarImageWrapperCommonRepresentation<GreyType, Self> CommonRepresentationPolicy;
itkStaticConstMacro(DefaultColorMap, ColorMap::SystemPreset, ColorMap::COLORMAP_GREY);
// Whether this image is shown on top of all other layers by default
itkStaticConstMacro(StickyByDefault, bool, false);
// Whether this image is produced from another by a pipeline (e.g., speed image)
itkStaticConstMacro(PipelineOutput, bool, false);
};
template <class TFunctor>
class VectorDerivedQuantityImageWrapperTraits
{
public:
typedef VectorDerivedQuantityImageWrapperTraits<TFunctor> Self;
typedef ScalarImageWrapper<Self> WrapperType;
typedef typename TFunctor::OutputPixelType ComponentType;
typedef typename TFunctor::InputPixelType InternalComponentType;
typedef itk::VectorImage<InternalComponentType, 3> InternalImageType;
typedef VectorToScalarImageAccessor<TFunctor> AccessorType;
typedef itk::ImageAdaptor<InternalImageType, AccessorType> ImageType;
typedef itk::Image<ComponentType, 2> SliceType;
typedef IdentityInternalToNativeIntensityMapping NativeIntensityMapping;
typedef CachingCurveAndColorMapDisplayMappingPolicy<Self> DisplayMapping;
typedef CastingScalarImageWrapperCommonRepresentation<GreyType, Self> CommonRepresentationPolicy;
itkStaticConstMacro(DefaultColorMap, ColorMap::SystemPreset, ColorMap::COLORMAP_GREY);
// Whether this image is shown on top of all other layers by default
itkStaticConstMacro(StickyByDefault, bool, false);
// Whether this image is produced from another by a pipeline (e.g., speed image)
itkStaticConstMacro(PipelineOutput, bool, false);
};
template <class TPixel>
class AnatomicImageWrapperTraits
{
public:
typedef AnatomicImageWrapperTraits<TPixel> Self;
typedef VectorImageWrapper<Self> WrapperType;
// Component stuff
typedef TPixel ComponentType;
typedef ComponentImageWrapperTraits<ComponentType> ComponentWrapperTraits;
typedef ScalarImageWrapper<ComponentWrapperTraits> ComponentWrapperType;
typedef itk::VectorImage<ComponentType, 3> ImageType;
typedef itk::VectorImage<ComponentType, 2> SliceType;
typedef LinearInternalToNativeIntensityMapping NativeIntensityMapping;
typedef MultiChannelDisplayMappingPolicy<Self> DisplayMapping;
// Whether this image is shown on top of all other layers by default
itkStaticConstMacro(StickyByDefault, bool, false);
// Whether this image is produced from another by a pipeline (e.g., speed image)
itkStaticConstMacro(PipelineOutput, bool, false);
};
template <class TPixel>
class AnatomicScalarImageWrapperTraits
{
public:
typedef AnatomicScalarImageWrapperTraits<TPixel> Self;
typedef ScalarImageWrapper<Self> WrapperType;
typedef TPixel ComponentType;
typedef itk::Image<ComponentType, 3> ImageType;
typedef itk::Image<ComponentType, 2> SliceType;
typedef LinearInternalToNativeIntensityMapping NativeIntensityMapping;
typedef CachingCurveAndColorMapDisplayMappingPolicy<Self> DisplayMapping;
typedef typename DefaultCommonRepresentationPolicy<TPixel, Self>::Policy CommonRepresentationPolicy;
// Default color map
itkStaticConstMacro(DefaultColorMap, ColorMap::SystemPreset, ColorMap::COLORMAP_GREY);
// Whether this image is shown on top of all other layers by default
itkStaticConstMacro(StickyByDefault, bool, false);
// Whether this image is produced from another by a pipeline (e.g., speed image)
itkStaticConstMacro(PipelineOutput, bool, false);
};
// Global typedefs for traits with GreyType
typedef AnatomicScalarImageWrapperTraits<GreyType> GreyAnatomicScalarImageWrapperTraits;
typedef ComponentImageWrapperTraits<GreyType> GreyComponentImageWrapperTraits;
typedef VectorDerivedQuantityImageWrapperTraits<GreyVectorToScalarMagnitudeFunctor>
GreyVectorMagnitudeImageWrapperTraits;
typedef VectorDerivedQuantityImageWrapperTraits<GreyVectorToScalarMaxFunctor>
GreyVectorMaxImageWrapperTraits;
typedef VectorDerivedQuantityImageWrapperTraits<GreyVectorToScalarMeanFunctor>
GreyVectorMeanImageWrapperTraits;
// Some global typedefs
typedef AnatomicImageWrapperTraits<GreyType>::WrapperType AnatomicImageWrapper;
typedef AnatomicScalarImageWrapperTraits<GreyType>::WrapperType AnatomicScalarImageWrapper;
typedef LabelImageWrapperTraits::WrapperType LabelImageWrapper;
typedef SpeedImageWrapperTraits::WrapperType SpeedImageWrapper;
typedef LevelSetImageWrapperTraits::WrapperType LevelSetImageWrapper;
#endif // IMAGEWRAPPERTRAITS_H
|