17 #ifndef __itkQBallToRgbImageFilter_h
18 #define __itkQBallToRgbImageFilter_h
20 #include "itkUnaryFunctorImageFilter.h"
22 #include "itkRGBAPixel.h"
23 #include "itkImageRegionConstIterator.h"
24 #include "itkImageRegionIterator.h"
29 #define __IMG_DAT_ITEM__CEIL_ZERO_ONE__(val) (val) = \
30 ( (val) < 0 ) ? ( 0 ) : ( ( (val)>1 ) ? ( 1 ) : ( (val) ) );
36 template <
typename TInputImage,
37 typename TOutputImage=itk::Image<itk::RGBAPixel<unsigned char>,3> >
39 public ImageToImageFilter<TInputImage,TOutputImage>
44 typedef ImageToImageFilter<TInputImage,TOutputImage>
59 itkFactorylessNewMacro(Self)
64 { this->Superclass::PrintSelf( os, indent ); }
66 #ifdef ITK_USE_CONCEPT_CHECKING
68 itkConceptMacro(InputHasNumericTraitsCheck,
69 (Concept::HasNumericTraits<InputValueType>));
80 typename InputImageType::Pointer qballImage =
static_cast< InputImageType *
>( this->ProcessObject::GetInput(0) );
83 static_cast< OutputImageType *
>(this->ProcessObject::GetPrimaryOutput());
85 typename InputImageType::RegionType region = qballImage->GetLargestPossibleRegion();
87 outputImage->SetSpacing( qballImage->GetSpacing() );
88 outputImage->SetOrigin( qballImage->GetOrigin() );
89 outputImage->SetDirection( qballImage->GetDirection() );
90 outputImage->SetRegions( qballImage->GetLargestPossibleRegion());
91 outputImage->Allocate();
93 typedef ImageRegionConstIterator< InputImageType > QBallImageIteratorType;
94 QBallImageIteratorType qballIt(qballImage, qballImage->GetLargestPossibleRegion());
96 typedef ImageRegionIterator< OutputImageType > OutputImageIteratorType;
97 OutputImageIteratorType outputIt(outputImage, outputImage->GetLargestPossibleRegion());
100 outputIt.GoToBegin();
102 while(!qballIt.IsAtEnd() && !outputIt.IsAtEnd()){
104 InputPixelType x = qballIt.Get();
106 OdfType odf(x.GetDataPointer());
110 MITK_ERROR <<
"ODF corrupted: GetPrincipleDiffusionDirection returned -1";
112 vnl_vector_fixed<double,3> dir = OdfType::GetDirection(pd);
114 const float fa = odf.GetGeneralizedFractionalAnisotropy();
115 float r = fabs(dir[0]) * fa;
116 float g = fabs(dir[1]) * fa;
117 float b = fabs(dir[2]) * fa;
127 out.SetRed( r * 255.0f);
128 out.SetGreen( g * 255.0f);
129 out.SetBlue( b * 255.0f);
130 out.SetAlpha( a * 255.0f);
142 void operator=(
const Self&);
SmartPointer< Self > Pointer
itk::SmartPointer< Self > Pointer
virtual ~QBallToRgbImageFilter()
#define __IMG_DAT_ITEM__CEIL_ZERO_ONE__(val)
InputPixelType::ValueType InputValueType
TInputImage::PixelType InputPixelType
void PrintSelf(std::ostream &os, Indent indent) const
OutputImageType::PixelType OutputPixelType
itk::Image< double, 3 > InputImageType
ValueType
Type of the value held by a Value object.
SmartPointer< const Self > ConstPointer
Superclass::OutputImageType OutputImageType
Superclass::InputImageType InputImageType
QBallToRgbImageFilter Self
ImageToImageFilter< TInputImage, TOutputImage > Superclass
int GetPrincipleDiffusionDirection() const